babylon.module.d.ts 5.0 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030
  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 the Color3 values to linear space and stores the result in "convertedColor"
  466. * @param convertedColor defines the Color3 object where to store the linear space version
  467. * @returns the unmodified Color3
  468. */
  469. toLinearSpaceToRef(convertedColor: Color3): Color3;
  470. /**
  471. * Computes a new Color3 converted from the current one to gamma space
  472. * @returns a new Color3 object
  473. */
  474. toGammaSpace(): Color3;
  475. /**
  476. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  477. * @param convertedColor defines the Color3 object where to store the gamma space version
  478. * @returns the unmodified Color3
  479. */
  480. toGammaSpaceToRef(convertedColor: Color3): Color3;
  481. private static _BlackReadOnly;
  482. /**
  483. * Creates a new Color3 from the string containing valid hexadecimal values
  484. * @param hex defines a string containing valid hexadecimal values
  485. * @returns a new Color3 object
  486. */
  487. static FromHexString(hex: string): Color3;
  488. /**
  489. * Creates a new Vector3 from the starting index of the given array
  490. * @param array defines the source array
  491. * @param offset defines an offset in the source array
  492. * @returns a new Color3 object
  493. */
  494. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  495. /**
  496. * Creates a new Color3 from integer values (< 256)
  497. * @param r defines the red component to read from (value between 0 and 255)
  498. * @param g defines the green component to read from (value between 0 and 255)
  499. * @param b defines the blue component to read from (value between 0 and 255)
  500. * @returns a new Color3 object
  501. */
  502. static FromInts(r: number, g: number, b: number): Color3;
  503. /**
  504. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  505. * @param start defines the start Color3 value
  506. * @param end defines the end Color3 value
  507. * @param amount defines the gradient value between start and end
  508. * @returns a new Color3 object
  509. */
  510. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  511. /**
  512. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  513. * @param left defines the start value
  514. * @param right defines the end value
  515. * @param amount defines the gradient factor
  516. * @param result defines the Color3 object where to store the result
  517. */
  518. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  519. /**
  520. * Returns a Color3 value containing a red color
  521. * @returns a new Color3 object
  522. */
  523. static Red(): Color3;
  524. /**
  525. * Returns a Color3 value containing a green color
  526. * @returns a new Color3 object
  527. */
  528. static Green(): Color3;
  529. /**
  530. * Returns a Color3 value containing a blue color
  531. * @returns a new Color3 object
  532. */
  533. static Blue(): Color3;
  534. /**
  535. * Returns a Color3 value containing a black color
  536. * @returns a new Color3 object
  537. */
  538. static Black(): Color3;
  539. /**
  540. * Gets a Color3 value containing a black color that must not be updated
  541. */
  542. static readonly BlackReadOnly: DeepImmutable<Color3>;
  543. /**
  544. * Returns a Color3 value containing a white color
  545. * @returns a new Color3 object
  546. */
  547. static White(): Color3;
  548. /**
  549. * Returns a Color3 value containing a purple color
  550. * @returns a new Color3 object
  551. */
  552. static Purple(): Color3;
  553. /**
  554. * Returns a Color3 value containing a magenta color
  555. * @returns a new Color3 object
  556. */
  557. static Magenta(): Color3;
  558. /**
  559. * Returns a Color3 value containing a yellow color
  560. * @returns a new Color3 object
  561. */
  562. static Yellow(): Color3;
  563. /**
  564. * Returns a Color3 value containing a gray color
  565. * @returns a new Color3 object
  566. */
  567. static Gray(): Color3;
  568. /**
  569. * Returns a Color3 value containing a teal color
  570. * @returns a new Color3 object
  571. */
  572. static Teal(): Color3;
  573. /**
  574. * Returns a Color3 value containing a random color
  575. * @returns a new Color3 object
  576. */
  577. static Random(): Color3;
  578. }
  579. /**
  580. * Class used to hold a RBGA color
  581. */
  582. export class Color4 {
  583. /**
  584. * Defines the red component (between 0 and 1, default is 0)
  585. */
  586. r: number;
  587. /**
  588. * Defines the green component (between 0 and 1, default is 0)
  589. */
  590. g: number;
  591. /**
  592. * Defines the blue component (between 0 and 1, default is 0)
  593. */
  594. b: number;
  595. /**
  596. * Defines the alpha component (between 0 and 1, default is 1)
  597. */
  598. a: number;
  599. /**
  600. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  601. * @param r defines the red component (between 0 and 1, default is 0)
  602. * @param g defines the green component (between 0 and 1, default is 0)
  603. * @param b defines the blue component (between 0 and 1, default is 0)
  604. * @param a defines the alpha component (between 0 and 1, default is 1)
  605. */
  606. constructor(
  607. /**
  608. * Defines the red component (between 0 and 1, default is 0)
  609. */
  610. r?: number,
  611. /**
  612. * Defines the green component (between 0 and 1, default is 0)
  613. */
  614. g?: number,
  615. /**
  616. * Defines the blue component (between 0 and 1, default is 0)
  617. */
  618. b?: number,
  619. /**
  620. * Defines the alpha component (between 0 and 1, default is 1)
  621. */
  622. a?: number);
  623. /**
  624. * Adds in place the given Color4 values to the current Color4 object
  625. * @param right defines the second operand
  626. * @returns the current updated Color4 object
  627. */
  628. addInPlace(right: DeepImmutable<Color4>): Color4;
  629. /**
  630. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  631. * @returns the new array
  632. */
  633. asArray(): number[];
  634. /**
  635. * Stores from the starting index in the given array the Color4 successive values
  636. * @param array defines the array where to store the r,g,b components
  637. * @param index defines an optional index in the target array to define where to start storing values
  638. * @returns the current Color4 object
  639. */
  640. toArray(array: number[], index?: number): Color4;
  641. /**
  642. * Determines equality between Color4 objects
  643. * @param otherColor defines the second operand
  644. * @returns true if the rgba values are equal to the given ones
  645. */
  646. equals(otherColor: DeepImmutable<Color4>): boolean;
  647. /**
  648. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  649. * @param right defines the second operand
  650. * @returns a new Color4 object
  651. */
  652. add(right: DeepImmutable<Color4>): Color4;
  653. /**
  654. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  655. * @param right defines the second operand
  656. * @returns a new Color4 object
  657. */
  658. subtract(right: DeepImmutable<Color4>): Color4;
  659. /**
  660. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  661. * @param right defines the second operand
  662. * @param result defines the Color4 object where to store the result
  663. * @returns the current Color4 object
  664. */
  665. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  666. /**
  667. * Creates a new Color4 with the current Color4 values multiplied by scale
  668. * @param scale defines the scaling factor to apply
  669. * @returns a new Color4 object
  670. */
  671. scale(scale: number): Color4;
  672. /**
  673. * Multiplies the current Color4 values by scale and stores the result in "result"
  674. * @param scale defines the scaling factor to apply
  675. * @param result defines the Color4 object where to store the result
  676. * @returns the current unmodified Color4
  677. */
  678. scaleToRef(scale: number, result: Color4): Color4;
  679. /**
  680. * Scale the current Color4 values by a factor and add the result to a given Color4
  681. * @param scale defines the scale factor
  682. * @param result defines the Color4 object where to store the result
  683. * @returns the unmodified current Color4
  684. */
  685. scaleAndAddToRef(scale: number, result: Color4): Color4;
  686. /**
  687. * Clamps the rgb values by the min and max values and stores the result into "result"
  688. * @param min defines minimum clamping value (default is 0)
  689. * @param max defines maximum clamping value (default is 1)
  690. * @param result defines color to store the result into.
  691. * @returns the cuurent Color4
  692. */
  693. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  694. /**
  695. * Multipy an Color4 value by another and return a new Color4 object
  696. * @param color defines the Color4 value to multiply by
  697. * @returns a new Color4 object
  698. */
  699. multiply(color: Color4): Color4;
  700. /**
  701. * Multipy a Color4 value by another and push the result in a reference value
  702. * @param color defines the Color4 value to multiply by
  703. * @param result defines the Color4 to fill the result in
  704. * @returns the result Color4
  705. */
  706. multiplyToRef(color: Color4, result: Color4): Color4;
  707. /**
  708. * Creates a string with the Color4 current values
  709. * @returns the string representation of the Color4 object
  710. */
  711. toString(): string;
  712. /**
  713. * Returns the string "Color4"
  714. * @returns "Color4"
  715. */
  716. getClassName(): string;
  717. /**
  718. * Compute the Color4 hash code
  719. * @returns an unique number that can be used to hash Color4 objects
  720. */
  721. getHashCode(): number;
  722. /**
  723. * Creates a new Color4 copied from the current one
  724. * @returns a new Color4 object
  725. */
  726. clone(): Color4;
  727. /**
  728. * Copies the given Color4 values into the current one
  729. * @param source defines the source Color4 object
  730. * @returns the current updated Color4 object
  731. */
  732. copyFrom(source: Color4): Color4;
  733. /**
  734. * Copies the given float values into the current one
  735. * @param r defines the red component to read from
  736. * @param g defines the green component to read from
  737. * @param b defines the blue component to read from
  738. * @param a defines the alpha component to read from
  739. * @returns the current updated Color4 object
  740. */
  741. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  742. /**
  743. * Copies the given float values into the current one
  744. * @param r defines the red component to read from
  745. * @param g defines the green component to read from
  746. * @param b defines the blue component to read from
  747. * @param a defines the alpha component to read from
  748. * @returns the current updated Color4 object
  749. */
  750. set(r: number, g: number, b: number, a: number): Color4;
  751. /**
  752. * Compute the Color4 hexadecimal code as a string
  753. * @returns a string containing the hexadecimal representation of the Color4 object
  754. */
  755. toHexString(): string;
  756. /**
  757. * Computes a new Color4 converted from the current one to linear space
  758. * @returns a new Color4 object
  759. */
  760. toLinearSpace(): Color4;
  761. /**
  762. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  763. * @param convertedColor defines the Color4 object where to store the linear space version
  764. * @returns the unmodified Color4
  765. */
  766. toLinearSpaceToRef(convertedColor: Color4): Color4;
  767. /**
  768. * Computes a new Color4 converted from the current one to gamma space
  769. * @returns a new Color4 object
  770. */
  771. toGammaSpace(): Color4;
  772. /**
  773. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  774. * @param convertedColor defines the Color4 object where to store the gamma space version
  775. * @returns the unmodified Color4
  776. */
  777. toGammaSpaceToRef(convertedColor: Color4): Color4;
  778. /**
  779. * Creates a new Color4 from the string containing valid hexadecimal values
  780. * @param hex defines a string containing valid hexadecimal values
  781. * @returns a new Color4 object
  782. */
  783. static FromHexString(hex: string): Color4;
  784. /**
  785. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  786. * @param left defines the start value
  787. * @param right defines the end value
  788. * @param amount defines the gradient factor
  789. * @returns a new Color4 object
  790. */
  791. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  792. /**
  793. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  794. * @param left defines the start value
  795. * @param right defines the end value
  796. * @param amount defines the gradient factor
  797. * @param result defines the Color4 object where to store data
  798. */
  799. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  800. /**
  801. * Creates a new Color4 from a Color3 and an alpha value
  802. * @param color3 defines the source Color3 to read from
  803. * @param alpha defines the alpha component (1.0 by default)
  804. * @returns a new Color4 object
  805. */
  806. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  807. /**
  808. * Creates a new Color4 from the starting index element of the given array
  809. * @param array defines the source array to read from
  810. * @param offset defines the offset in the source array
  811. * @returns a new Color4 object
  812. */
  813. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  814. /**
  815. * Creates a new Color3 from integer values (< 256)
  816. * @param r defines the red component to read from (value between 0 and 255)
  817. * @param g defines the green component to read from (value between 0 and 255)
  818. * @param b defines the blue component to read from (value between 0 and 255)
  819. * @param a defines the alpha component to read from (value between 0 and 255)
  820. * @returns a new Color3 object
  821. */
  822. static FromInts(r: number, g: number, b: number, a: number): Color4;
  823. /**
  824. * Check the content of a given array and convert it to an array containing RGBA data
  825. * If the original array was already containing count * 4 values then it is returned directly
  826. * @param colors defines the array to check
  827. * @param count defines the number of RGBA data to expect
  828. * @returns an array containing count * 4 values (RGBA)
  829. */
  830. static CheckColors4(colors: number[], count: number): number[];
  831. }
  832. /**
  833. * Class representing a vector containing 2 coordinates
  834. */
  835. export class Vector2 {
  836. /** defines the first coordinate */
  837. x: number;
  838. /** defines the second coordinate */
  839. y: number;
  840. /**
  841. * Creates a new Vector2 from the given x and y coordinates
  842. * @param x defines the first coordinate
  843. * @param y defines the second coordinate
  844. */
  845. constructor(
  846. /** defines the first coordinate */
  847. x?: number,
  848. /** defines the second coordinate */
  849. y?: number);
  850. /**
  851. * Gets a string with the Vector2 coordinates
  852. * @returns a string with the Vector2 coordinates
  853. */
  854. toString(): string;
  855. /**
  856. * Gets class name
  857. * @returns the string "Vector2"
  858. */
  859. getClassName(): string;
  860. /**
  861. * Gets current vector hash code
  862. * @returns the Vector2 hash code as a number
  863. */
  864. getHashCode(): number;
  865. /**
  866. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  867. * @param array defines the source array
  868. * @param index defines the offset in source array
  869. * @returns the current Vector2
  870. */
  871. toArray(array: FloatArray, index?: number): Vector2;
  872. /**
  873. * Copy the current vector to an array
  874. * @returns a new array with 2 elements: the Vector2 coordinates.
  875. */
  876. asArray(): number[];
  877. /**
  878. * Sets the Vector2 coordinates with the given Vector2 coordinates
  879. * @param source defines the source Vector2
  880. * @returns the current updated Vector2
  881. */
  882. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  883. /**
  884. * Sets the Vector2 coordinates with the given floats
  885. * @param x defines the first coordinate
  886. * @param y defines the second coordinate
  887. * @returns the current updated Vector2
  888. */
  889. copyFromFloats(x: number, y: number): Vector2;
  890. /**
  891. * Sets the Vector2 coordinates with the given floats
  892. * @param x defines the first coordinate
  893. * @param y defines the second coordinate
  894. * @returns the current updated Vector2
  895. */
  896. set(x: number, y: number): Vector2;
  897. /**
  898. * Add another vector with the current one
  899. * @param otherVector defines the other vector
  900. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  901. */
  902. add(otherVector: DeepImmutable<Vector2>): Vector2;
  903. /**
  904. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  905. * @param otherVector defines the other vector
  906. * @param result defines the target vector
  907. * @returns the unmodified current Vector2
  908. */
  909. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  910. /**
  911. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  912. * @param otherVector defines the other vector
  913. * @returns the current updated Vector2
  914. */
  915. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  916. /**
  917. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  918. * @param otherVector defines the other vector
  919. * @returns a new Vector2
  920. */
  921. addVector3(otherVector: Vector3): Vector2;
  922. /**
  923. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  924. * @param otherVector defines the other vector
  925. * @returns a new Vector2
  926. */
  927. subtract(otherVector: Vector2): Vector2;
  928. /**
  929. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  930. * @param otherVector defines the other vector
  931. * @param result defines the target vector
  932. * @returns the unmodified current Vector2
  933. */
  934. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  935. /**
  936. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  937. * @param otherVector defines the other vector
  938. * @returns the current updated Vector2
  939. */
  940. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  941. /**
  942. * Multiplies in place the current Vector2 coordinates by the given ones
  943. * @param otherVector defines the other vector
  944. * @returns the current updated Vector2
  945. */
  946. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  947. /**
  948. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  949. * @param otherVector defines the other vector
  950. * @returns a new Vector2
  951. */
  952. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  953. /**
  954. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  955. * @param otherVector defines the other vector
  956. * @param result defines the target vector
  957. * @returns the unmodified current Vector2
  958. */
  959. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  960. /**
  961. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  962. * @param x defines the first coordinate
  963. * @param y defines the second coordinate
  964. * @returns a new Vector2
  965. */
  966. multiplyByFloats(x: number, y: number): Vector2;
  967. /**
  968. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  969. * @param otherVector defines the other vector
  970. * @returns a new Vector2
  971. */
  972. divide(otherVector: Vector2): Vector2;
  973. /**
  974. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  975. * @param otherVector defines the other vector
  976. * @param result defines the target vector
  977. * @returns the unmodified current Vector2
  978. */
  979. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  980. /**
  981. * Divides the current Vector2 coordinates by the given ones
  982. * @param otherVector defines the other vector
  983. * @returns the current updated Vector2
  984. */
  985. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  986. /**
  987. * Gets a new Vector2 with current Vector2 negated coordinates
  988. * @returns a new Vector2
  989. */
  990. negate(): Vector2;
  991. /**
  992. * Multiply the Vector2 coordinates by scale
  993. * @param scale defines the scaling factor
  994. * @returns the current updated Vector2
  995. */
  996. scaleInPlace(scale: number): Vector2;
  997. /**
  998. * Returns a new Vector2 scaled by "scale" from the current Vector2
  999. * @param scale defines the scaling factor
  1000. * @returns a new Vector2
  1001. */
  1002. scale(scale: number): Vector2;
  1003. /**
  1004. * Scale the current Vector2 values by a factor to a given Vector2
  1005. * @param scale defines the scale factor
  1006. * @param result defines the Vector2 object where to store the result
  1007. * @returns the unmodified current Vector2
  1008. */
  1009. scaleToRef(scale: number, result: Vector2): Vector2;
  1010. /**
  1011. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  1012. * @param scale defines the scale factor
  1013. * @param result defines the Vector2 object where to store the result
  1014. * @returns the unmodified current Vector2
  1015. */
  1016. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  1017. /**
  1018. * Gets a boolean if two vectors are equals
  1019. * @param otherVector defines the other vector
  1020. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  1021. */
  1022. equals(otherVector: DeepImmutable<Vector2>): boolean;
  1023. /**
  1024. * Gets a boolean if two vectors are equals (using an epsilon value)
  1025. * @param otherVector defines the other vector
  1026. * @param epsilon defines the minimal distance to consider equality
  1027. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  1028. */
  1029. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  1030. /**
  1031. * Gets a new Vector2 from current Vector2 floored values
  1032. * @returns a new Vector2
  1033. */
  1034. floor(): Vector2;
  1035. /**
  1036. * Gets a new Vector2 from current Vector2 floored values
  1037. * @returns a new Vector2
  1038. */
  1039. fract(): Vector2;
  1040. /**
  1041. * Gets the length of the vector
  1042. * @returns the vector length (float)
  1043. */
  1044. length(): number;
  1045. /**
  1046. * Gets the vector squared length
  1047. * @returns the vector squared length (float)
  1048. */
  1049. lengthSquared(): number;
  1050. /**
  1051. * Normalize the vector
  1052. * @returns the current updated Vector2
  1053. */
  1054. normalize(): Vector2;
  1055. /**
  1056. * Gets a new Vector2 copied from the Vector2
  1057. * @returns a new Vector2
  1058. */
  1059. clone(): Vector2;
  1060. /**
  1061. * Gets a new Vector2(0, 0)
  1062. * @returns a new Vector2
  1063. */
  1064. static Zero(): Vector2;
  1065. /**
  1066. * Gets a new Vector2(1, 1)
  1067. * @returns a new Vector2
  1068. */
  1069. static One(): Vector2;
  1070. /**
  1071. * Gets a new Vector2 set from the given index element of the given array
  1072. * @param array defines the data source
  1073. * @param offset defines the offset in the data source
  1074. * @returns a new Vector2
  1075. */
  1076. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  1077. /**
  1078. * Sets "result" from the given index element of the given array
  1079. * @param array defines the data source
  1080. * @param offset defines the offset in the data source
  1081. * @param result defines the target vector
  1082. */
  1083. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  1084. /**
  1085. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  1086. * @param value1 defines 1st point of control
  1087. * @param value2 defines 2nd point of control
  1088. * @param value3 defines 3rd point of control
  1089. * @param value4 defines 4th point of control
  1090. * @param amount defines the interpolation factor
  1091. * @returns a new Vector2
  1092. */
  1093. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  1094. /**
  1095. * 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".
  1096. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  1097. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  1098. * @param value defines the value to clamp
  1099. * @param min defines the lower limit
  1100. * @param max defines the upper limit
  1101. * @returns a new Vector2
  1102. */
  1103. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  1104. /**
  1105. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  1106. * @param value1 defines the 1st control point
  1107. * @param tangent1 defines the outgoing tangent
  1108. * @param value2 defines the 2nd control point
  1109. * @param tangent2 defines the incoming tangent
  1110. * @param amount defines the interpolation factor
  1111. * @returns a new Vector2
  1112. */
  1113. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  1114. /**
  1115. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  1116. * @param start defines the start vector
  1117. * @param end defines the end vector
  1118. * @param amount defines the interpolation factor
  1119. * @returns a new Vector2
  1120. */
  1121. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  1122. /**
  1123. * Gets the dot product of the vector "left" and the vector "right"
  1124. * @param left defines first vector
  1125. * @param right defines second vector
  1126. * @returns the dot product (float)
  1127. */
  1128. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  1129. /**
  1130. * Returns a new Vector2 equal to the normalized given vector
  1131. * @param vector defines the vector to normalize
  1132. * @returns a new Vector2
  1133. */
  1134. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  1135. /**
  1136. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  1137. * @param left defines 1st vector
  1138. * @param right defines 2nd vector
  1139. * @returns a new Vector2
  1140. */
  1141. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1142. /**
  1143. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  1144. * @param left defines 1st vector
  1145. * @param right defines 2nd vector
  1146. * @returns a new Vector2
  1147. */
  1148. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1149. /**
  1150. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  1151. * @param vector defines the vector to transform
  1152. * @param transformation defines the matrix to apply
  1153. * @returns a new Vector2
  1154. */
  1155. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  1156. /**
  1157. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  1158. * @param vector defines the vector to transform
  1159. * @param transformation defines the matrix to apply
  1160. * @param result defines the target vector
  1161. */
  1162. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  1163. /**
  1164. * Determines if a given vector is included in a triangle
  1165. * @param p defines the vector to test
  1166. * @param p0 defines 1st triangle point
  1167. * @param p1 defines 2nd triangle point
  1168. * @param p2 defines 3rd triangle point
  1169. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  1170. */
  1171. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  1172. /**
  1173. * Gets the distance between the vectors "value1" and "value2"
  1174. * @param value1 defines first vector
  1175. * @param value2 defines second vector
  1176. * @returns the distance between vectors
  1177. */
  1178. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1179. /**
  1180. * Returns the squared distance between the vectors "value1" and "value2"
  1181. * @param value1 defines first vector
  1182. * @param value2 defines second vector
  1183. * @returns the squared distance between vectors
  1184. */
  1185. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1186. /**
  1187. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  1188. * @param value1 defines first vector
  1189. * @param value2 defines second vector
  1190. * @returns a new Vector2
  1191. */
  1192. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  1193. /**
  1194. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  1195. * @param p defines the middle point
  1196. * @param segA defines one point of the segment
  1197. * @param segB defines the other point of the segment
  1198. * @returns the shortest distance
  1199. */
  1200. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  1201. }
  1202. /**
  1203. * Classed used to store (x,y,z) vector representation
  1204. * A Vector3 is the main object used in 3D geometry
  1205. * It can represent etiher the coordinates of a point the space, either a direction
  1206. * Reminder: js uses a left handed forward facing system
  1207. */
  1208. export class Vector3 {
  1209. /**
  1210. * Defines the first coordinates (on X axis)
  1211. */
  1212. x: number;
  1213. /**
  1214. * Defines the second coordinates (on Y axis)
  1215. */
  1216. y: number;
  1217. /**
  1218. * Defines the third coordinates (on Z axis)
  1219. */
  1220. z: number;
  1221. private static _UpReadOnly;
  1222. /**
  1223. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  1224. * @param x defines the first coordinates (on X axis)
  1225. * @param y defines the second coordinates (on Y axis)
  1226. * @param z defines the third coordinates (on Z axis)
  1227. */
  1228. constructor(
  1229. /**
  1230. * Defines the first coordinates (on X axis)
  1231. */
  1232. x?: number,
  1233. /**
  1234. * Defines the second coordinates (on Y axis)
  1235. */
  1236. y?: number,
  1237. /**
  1238. * Defines the third coordinates (on Z axis)
  1239. */
  1240. z?: number);
  1241. /**
  1242. * Creates a string representation of the Vector3
  1243. * @returns a string with the Vector3 coordinates.
  1244. */
  1245. toString(): string;
  1246. /**
  1247. * Gets the class name
  1248. * @returns the string "Vector3"
  1249. */
  1250. getClassName(): string;
  1251. /**
  1252. * Creates the Vector3 hash code
  1253. * @returns a number which tends to be unique between Vector3 instances
  1254. */
  1255. getHashCode(): number;
  1256. /**
  1257. * Creates an array containing three elements : the coordinates of the Vector3
  1258. * @returns a new array of numbers
  1259. */
  1260. asArray(): number[];
  1261. /**
  1262. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  1263. * @param array defines the destination array
  1264. * @param index defines the offset in the destination array
  1265. * @returns the current Vector3
  1266. */
  1267. toArray(array: FloatArray, index?: number): Vector3;
  1268. /**
  1269. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  1270. * @returns a new Quaternion object, computed from the Vector3 coordinates
  1271. */
  1272. toQuaternion(): Quaternion;
  1273. /**
  1274. * Adds the given vector to the current Vector3
  1275. * @param otherVector defines the second operand
  1276. * @returns the current updated Vector3
  1277. */
  1278. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1279. /**
  1280. * Adds the given coordinates to the current Vector3
  1281. * @param x defines the x coordinate of the operand
  1282. * @param y defines the y coordinate of the operand
  1283. * @param z defines the z coordinate of the operand
  1284. * @returns the current updated Vector3
  1285. */
  1286. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1287. /**
  1288. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  1289. * @param otherVector defines the second operand
  1290. * @returns the resulting Vector3
  1291. */
  1292. add(otherVector: DeepImmutable<Vector3>): Vector3;
  1293. /**
  1294. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  1295. * @param otherVector defines the second operand
  1296. * @param result defines the Vector3 object where to store the result
  1297. * @returns the current Vector3
  1298. */
  1299. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1300. /**
  1301. * Subtract the given vector from the current Vector3
  1302. * @param otherVector defines the second operand
  1303. * @returns the current updated Vector3
  1304. */
  1305. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1306. /**
  1307. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  1308. * @param otherVector defines the second operand
  1309. * @returns the resulting Vector3
  1310. */
  1311. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  1312. /**
  1313. * Subtracts the given vector from the current Vector3 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. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1319. /**
  1320. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  1321. * @param x defines the x coordinate of the operand
  1322. * @param y defines the y coordinate of the operand
  1323. * @param z defines the z coordinate of the operand
  1324. * @returns the resulting Vector3
  1325. */
  1326. subtractFromFloats(x: number, y: number, z: number): Vector3;
  1327. /**
  1328. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  1329. * @param x defines the x coordinate of the operand
  1330. * @param y defines the y coordinate of the operand
  1331. * @param z defines the z coordinate of the operand
  1332. * @param result defines the Vector3 object where to store the result
  1333. * @returns the current Vector3
  1334. */
  1335. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  1336. /**
  1337. * Gets a new Vector3 set with the current Vector3 negated coordinates
  1338. * @returns a new Vector3
  1339. */
  1340. negate(): Vector3;
  1341. /**
  1342. * Multiplies the Vector3 coordinates by the float "scale"
  1343. * @param scale defines the multiplier factor
  1344. * @returns the current updated Vector3
  1345. */
  1346. scaleInPlace(scale: number): Vector3;
  1347. /**
  1348. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  1349. * @param scale defines the multiplier factor
  1350. * @returns a new Vector3
  1351. */
  1352. scale(scale: number): Vector3;
  1353. /**
  1354. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  1355. * @param scale defines the multiplier factor
  1356. * @param result defines the Vector3 object where to store the result
  1357. * @returns the current Vector3
  1358. */
  1359. scaleToRef(scale: number, result: Vector3): Vector3;
  1360. /**
  1361. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  1362. * @param scale defines the scale factor
  1363. * @param result defines the Vector3 object where to store the result
  1364. * @returns the unmodified current Vector3
  1365. */
  1366. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  1367. /**
  1368. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  1369. * @param otherVector defines the second operand
  1370. * @returns true if both vectors are equals
  1371. */
  1372. equals(otherVector: DeepImmutable<Vector3>): boolean;
  1373. /**
  1374. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  1375. * @param otherVector defines the second operand
  1376. * @param epsilon defines the minimal distance to define values as equals
  1377. * @returns true if both vectors are distant less than epsilon
  1378. */
  1379. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  1380. /**
  1381. * Returns true if the current Vector3 coordinates equals the given floats
  1382. * @param x defines the x coordinate of the operand
  1383. * @param y defines the y coordinate of the operand
  1384. * @param z defines the z coordinate of the operand
  1385. * @returns true if both vectors are equals
  1386. */
  1387. equalsToFloats(x: number, y: number, z: number): boolean;
  1388. /**
  1389. * Multiplies the current Vector3 coordinates by the given ones
  1390. * @param otherVector defines the second operand
  1391. * @returns the current updated Vector3
  1392. */
  1393. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1394. /**
  1395. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  1396. * @param otherVector defines the second operand
  1397. * @returns the new Vector3
  1398. */
  1399. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  1400. /**
  1401. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  1402. * @param otherVector defines the second operand
  1403. * @param result defines the Vector3 object where to store the result
  1404. * @returns the current Vector3
  1405. */
  1406. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1407. /**
  1408. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  1409. * @param x defines the x coordinate of the operand
  1410. * @param y defines the y coordinate of the operand
  1411. * @param z defines the z coordinate of the operand
  1412. * @returns the new Vector3
  1413. */
  1414. multiplyByFloats(x: number, y: number, z: number): Vector3;
  1415. /**
  1416. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  1417. * @param otherVector defines the second operand
  1418. * @returns the new Vector3
  1419. */
  1420. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  1421. /**
  1422. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  1423. * @param otherVector defines the second operand
  1424. * @param result defines the Vector3 object where to store the result
  1425. * @returns the current Vector3
  1426. */
  1427. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1428. /**
  1429. * Divides the current Vector3 coordinates by the given ones.
  1430. * @param otherVector defines the second operand
  1431. * @returns the current updated Vector3
  1432. */
  1433. divideInPlace(otherVector: Vector3): Vector3;
  1434. /**
  1435. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  1436. * @param other defines the second operand
  1437. * @returns the current updated Vector3
  1438. */
  1439. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  1440. /**
  1441. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  1442. * @param other defines the second operand
  1443. * @returns the current updated Vector3
  1444. */
  1445. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  1446. /**
  1447. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  1448. * @param x defines the x coordinate of the operand
  1449. * @param y defines the y coordinate of the operand
  1450. * @param z defines the z coordinate of the operand
  1451. * @returns the current updated Vector3
  1452. */
  1453. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1454. /**
  1455. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  1456. * @param x defines the x coordinate of the operand
  1457. * @param y defines the y coordinate of the operand
  1458. * @param z defines the z coordinate of the operand
  1459. * @returns the current updated Vector3
  1460. */
  1461. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1462. /**
  1463. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  1464. * Check if is non uniform within a certain amount of decimal places to account for this
  1465. * @param epsilon the amount the values can differ
  1466. * @returns if the the vector is non uniform to a certain number of decimal places
  1467. */
  1468. isNonUniformWithinEpsilon(epsilon: number): boolean;
  1469. /**
  1470. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  1471. */
  1472. readonly isNonUniform: boolean;
  1473. /**
  1474. * Gets a new Vector3 from current Vector3 floored values
  1475. * @returns a new Vector3
  1476. */
  1477. floor(): Vector3;
  1478. /**
  1479. * Gets a new Vector3 from current Vector3 floored values
  1480. * @returns a new Vector3
  1481. */
  1482. fract(): Vector3;
  1483. /**
  1484. * Gets the length of the Vector3
  1485. * @returns the length of the Vecto3
  1486. */
  1487. length(): number;
  1488. /**
  1489. * Gets the squared length of the Vector3
  1490. * @returns squared length of the Vector3
  1491. */
  1492. lengthSquared(): number;
  1493. /**
  1494. * Normalize the current Vector3.
  1495. * Please note that this is an in place operation.
  1496. * @returns the current updated Vector3
  1497. */
  1498. normalize(): Vector3;
  1499. /**
  1500. * Reorders the x y z properties of the vector in place
  1501. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  1502. * @returns the current updated vector
  1503. */
  1504. reorderInPlace(order: string): this;
  1505. /**
  1506. * Rotates the vector around 0,0,0 by a quaternion
  1507. * @param quaternion the rotation quaternion
  1508. * @param result vector to store the result
  1509. * @returns the resulting vector
  1510. */
  1511. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  1512. /**
  1513. * Rotates a vector around a given point
  1514. * @param quaternion the rotation quaternion
  1515. * @param point the point to rotate around
  1516. * @param result vector to store the result
  1517. * @returns the resulting vector
  1518. */
  1519. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  1520. /**
  1521. * Normalize the current Vector3 with the given input length.
  1522. * Please note that this is an in place operation.
  1523. * @param len the length of the vector
  1524. * @returns the current updated Vector3
  1525. */
  1526. normalizeFromLength(len: number): Vector3;
  1527. /**
  1528. * Normalize the current Vector3 to a new vector
  1529. * @returns the new Vector3
  1530. */
  1531. normalizeToNew(): Vector3;
  1532. /**
  1533. * Normalize the current Vector3 to the reference
  1534. * @param reference define the Vector3 to update
  1535. * @returns the updated Vector3
  1536. */
  1537. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  1538. /**
  1539. * Creates a new Vector3 copied from the current Vector3
  1540. * @returns the new Vector3
  1541. */
  1542. clone(): Vector3;
  1543. /**
  1544. * Copies the given vector coordinates to the current Vector3 ones
  1545. * @param source defines the source Vector3
  1546. * @returns the current updated Vector3
  1547. */
  1548. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  1549. /**
  1550. * Copies the given floats to the current Vector3 coordinates
  1551. * @param x defines the x coordinate of the operand
  1552. * @param y defines the y coordinate of the operand
  1553. * @param z defines the z coordinate of the operand
  1554. * @returns the current updated Vector3
  1555. */
  1556. copyFromFloats(x: number, y: number, z: number): Vector3;
  1557. /**
  1558. * Copies the given floats to the current Vector3 coordinates
  1559. * @param x defines the x coordinate of the operand
  1560. * @param y defines the y coordinate of the operand
  1561. * @param z defines the z coordinate of the operand
  1562. * @returns the current updated Vector3
  1563. */
  1564. set(x: number, y: number, z: number): Vector3;
  1565. /**
  1566. * Copies the given float to the current Vector3 coordinates
  1567. * @param v defines the x, y and z coordinates of the operand
  1568. * @returns the current updated Vector3
  1569. */
  1570. setAll(v: number): Vector3;
  1571. /**
  1572. * Get the clip factor between two vectors
  1573. * @param vector0 defines the first operand
  1574. * @param vector1 defines the second operand
  1575. * @param axis defines the axis to use
  1576. * @param size defines the size along the axis
  1577. * @returns the clip factor
  1578. */
  1579. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  1580. /**
  1581. * Get angle between two vectors
  1582. * @param vector0 angle between vector0 and vector1
  1583. * @param vector1 angle between vector0 and vector1
  1584. * @param normal direction of the normal
  1585. * @return the angle between vector0 and vector1
  1586. */
  1587. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  1588. /**
  1589. * Returns a new Vector3 set from the index "offset" of the given array
  1590. * @param array defines the source array
  1591. * @param offset defines the offset in the source array
  1592. * @returns the new Vector3
  1593. */
  1594. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  1595. /**
  1596. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  1597. * This function is deprecated. Use FromArray instead
  1598. * @param array defines the source array
  1599. * @param offset defines the offset in the source array
  1600. * @returns the new Vector3
  1601. */
  1602. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  1603. /**
  1604. * Sets the given vector "result" with the element values from the index "offset" of the given array
  1605. * @param array defines the source array
  1606. * @param offset defines the offset in the source array
  1607. * @param result defines the Vector3 where to store the result
  1608. */
  1609. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  1610. /**
  1611. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  1612. * This function is deprecated. Use FromArrayToRef instead.
  1613. * @param array defines the source array
  1614. * @param offset defines the offset in the source array
  1615. * @param result defines the Vector3 where to store the result
  1616. */
  1617. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  1618. /**
  1619. * Sets the given vector "result" with the given floats.
  1620. * @param x defines the x coordinate of the source
  1621. * @param y defines the y coordinate of the source
  1622. * @param z defines the z coordinate of the source
  1623. * @param result defines the Vector3 where to store the result
  1624. */
  1625. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  1626. /**
  1627. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  1628. * @returns a new empty Vector3
  1629. */
  1630. static Zero(): Vector3;
  1631. /**
  1632. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  1633. * @returns a new unit Vector3
  1634. */
  1635. static One(): Vector3;
  1636. /**
  1637. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  1638. * @returns a new up Vector3
  1639. */
  1640. static Up(): Vector3;
  1641. /**
  1642. * Gets a up Vector3 that must not be updated
  1643. */
  1644. static readonly UpReadOnly: DeepImmutable<Vector3>;
  1645. /**
  1646. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  1647. * @returns a new down Vector3
  1648. */
  1649. static Down(): Vector3;
  1650. /**
  1651. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  1652. * @returns a new forward Vector3
  1653. */
  1654. static Forward(): Vector3;
  1655. /**
  1656. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  1657. * @returns a new forward Vector3
  1658. */
  1659. static Backward(): Vector3;
  1660. /**
  1661. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  1662. * @returns a new right Vector3
  1663. */
  1664. static Right(): Vector3;
  1665. /**
  1666. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  1667. * @returns a new left Vector3
  1668. */
  1669. static Left(): Vector3;
  1670. /**
  1671. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  1672. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  1673. * @param vector defines the Vector3 to transform
  1674. * @param transformation defines the transformation matrix
  1675. * @returns the transformed Vector3
  1676. */
  1677. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  1678. /**
  1679. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  1680. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  1681. * @param vector defines the Vector3 to transform
  1682. * @param transformation defines the transformation matrix
  1683. * @param result defines the Vector3 where to store the result
  1684. */
  1685. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1686. /**
  1687. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  1688. * This method computes tranformed coordinates only, not transformed direction vectors
  1689. * @param x define the x coordinate of the source vector
  1690. * @param y define the y coordinate of the source vector
  1691. * @param z define the z coordinate of the source vector
  1692. * @param transformation defines the transformation matrix
  1693. * @param result defines the Vector3 where to store the result
  1694. */
  1695. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1696. /**
  1697. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  1698. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1699. * @param vector defines the Vector3 to transform
  1700. * @param transformation defines the transformation matrix
  1701. * @returns the new Vector3
  1702. */
  1703. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  1704. /**
  1705. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  1706. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1707. * @param vector defines the Vector3 to transform
  1708. * @param transformation defines the transformation matrix
  1709. * @param result defines the Vector3 where to store the result
  1710. */
  1711. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1712. /**
  1713. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  1714. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1715. * @param x define the x coordinate of the source vector
  1716. * @param y define the y coordinate of the source vector
  1717. * @param z define the z coordinate of the source vector
  1718. * @param transformation defines the transformation matrix
  1719. * @param result defines the Vector3 where to store the result
  1720. */
  1721. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1722. /**
  1723. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  1724. * @param value1 defines the first control point
  1725. * @param value2 defines the second control point
  1726. * @param value3 defines the third control point
  1727. * @param value4 defines the fourth control point
  1728. * @param amount defines the amount on the spline to use
  1729. * @returns the new Vector3
  1730. */
  1731. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  1732. /**
  1733. * 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"
  1734. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  1735. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  1736. * @param value defines the current value
  1737. * @param min defines the lower range value
  1738. * @param max defines the upper range value
  1739. * @returns the new Vector3
  1740. */
  1741. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  1742. /**
  1743. * 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"
  1744. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  1745. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  1746. * @param value defines the current value
  1747. * @param min defines the lower range value
  1748. * @param max defines the upper range value
  1749. * @param result defines the Vector3 where to store the result
  1750. */
  1751. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  1752. /**
  1753. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  1754. * @param value1 defines the first control point
  1755. * @param tangent1 defines the first tangent vector
  1756. * @param value2 defines the second control point
  1757. * @param tangent2 defines the second tangent vector
  1758. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  1759. * @returns the new Vector3
  1760. */
  1761. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  1762. /**
  1763. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  1764. * @param start defines the start value
  1765. * @param end defines the end value
  1766. * @param amount max defines amount between both (between 0 and 1)
  1767. * @returns the new Vector3
  1768. */
  1769. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  1770. /**
  1771. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  1772. * @param start defines the start value
  1773. * @param end defines the end value
  1774. * @param amount max defines amount between both (between 0 and 1)
  1775. * @param result defines the Vector3 where to store the result
  1776. */
  1777. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  1778. /**
  1779. * Returns the dot product (float) between the vectors "left" and "right"
  1780. * @param left defines the left operand
  1781. * @param right defines the right operand
  1782. * @returns the dot product
  1783. */
  1784. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  1785. /**
  1786. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  1787. * The cross product is then orthogonal to both "left" and "right"
  1788. * @param left defines the left operand
  1789. * @param right defines the right operand
  1790. * @returns the cross product
  1791. */
  1792. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1793. /**
  1794. * Sets the given vector "result" with the cross product of "left" and "right"
  1795. * The cross product is then orthogonal to both "left" and "right"
  1796. * @param left defines the left operand
  1797. * @param right defines the right operand
  1798. * @param result defines the Vector3 where to store the result
  1799. */
  1800. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  1801. /**
  1802. * Returns a new Vector3 as the normalization of the given vector
  1803. * @param vector defines the Vector3 to normalize
  1804. * @returns the new Vector3
  1805. */
  1806. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  1807. /**
  1808. * Sets the given vector "result" with the normalization of the given first vector
  1809. * @param vector defines the Vector3 to normalize
  1810. * @param result defines the Vector3 where to store the result
  1811. */
  1812. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  1813. /**
  1814. * Project a Vector3 onto screen space
  1815. * @param vector defines the Vector3 to project
  1816. * @param world defines the world matrix to use
  1817. * @param transform defines the transform (view x projection) matrix to use
  1818. * @param viewport defines the screen viewport to use
  1819. * @returns the new Vector3
  1820. */
  1821. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  1822. /** @hidden */
  1823. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  1824. /**
  1825. * Unproject from screen space to object space
  1826. * @param source defines the screen space Vector3 to use
  1827. * @param viewportWidth defines the current width of the viewport
  1828. * @param viewportHeight defines the current height of the viewport
  1829. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1830. * @param transform defines the transform (view x projection) matrix to use
  1831. * @returns the new Vector3
  1832. */
  1833. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  1834. /**
  1835. * Unproject from screen space to object space
  1836. * @param source defines the screen space Vector3 to use
  1837. * @param viewportWidth defines the current width of the viewport
  1838. * @param viewportHeight defines the current height of the viewport
  1839. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1840. * @param view defines the view matrix to use
  1841. * @param projection defines the projection matrix to use
  1842. * @returns the new Vector3
  1843. */
  1844. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  1845. /**
  1846. * Unproject from screen space to object space
  1847. * @param source defines the screen space Vector3 to use
  1848. * @param viewportWidth defines the current width of the viewport
  1849. * @param viewportHeight defines the current height of the viewport
  1850. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1851. * @param view defines the view matrix to use
  1852. * @param projection defines the projection matrix to use
  1853. * @param result defines the Vector3 where to store the result
  1854. */
  1855. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  1856. /**
  1857. * Unproject from screen space to object space
  1858. * @param sourceX defines the screen space x coordinate to use
  1859. * @param sourceY defines the screen space y coordinate to use
  1860. * @param sourceZ defines the screen space z coordinate to use
  1861. * @param viewportWidth defines the current width of the viewport
  1862. * @param viewportHeight defines the current height of the viewport
  1863. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1864. * @param view defines the view matrix to use
  1865. * @param projection defines the projection matrix to use
  1866. * @param result defines the Vector3 where to store the result
  1867. */
  1868. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  1869. /**
  1870. * Gets the minimal coordinate values between two Vector3
  1871. * @param left defines the first operand
  1872. * @param right defines the second operand
  1873. * @returns the new Vector3
  1874. */
  1875. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1876. /**
  1877. * Gets the maximal coordinate values between two Vector3
  1878. * @param left defines the first operand
  1879. * @param right defines the second operand
  1880. * @returns the new Vector3
  1881. */
  1882. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1883. /**
  1884. * Returns the distance between the vectors "value1" and "value2"
  1885. * @param value1 defines the first operand
  1886. * @param value2 defines the second operand
  1887. * @returns the distance
  1888. */
  1889. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  1890. /**
  1891. * Returns the squared distance between the vectors "value1" and "value2"
  1892. * @param value1 defines the first operand
  1893. * @param value2 defines the second operand
  1894. * @returns the squared distance
  1895. */
  1896. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  1897. /**
  1898. * Returns a new Vector3 located at the center between "value1" and "value2"
  1899. * @param value1 defines the first operand
  1900. * @param value2 defines the second operand
  1901. * @returns the new Vector3
  1902. */
  1903. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  1904. /**
  1905. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  1906. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  1907. * to something in order to rotate it from its local system to the given target system
  1908. * Note: axis1, axis2 and axis3 are normalized during this operation
  1909. * @param axis1 defines the first axis
  1910. * @param axis2 defines the second axis
  1911. * @param axis3 defines the third axis
  1912. * @returns a new Vector3
  1913. */
  1914. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  1915. /**
  1916. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  1917. * @param axis1 defines the first axis
  1918. * @param axis2 defines the second axis
  1919. * @param axis3 defines the third axis
  1920. * @param ref defines the Vector3 where to store the result
  1921. */
  1922. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  1923. }
  1924. /**
  1925. * Vector4 class created for EulerAngle class conversion to Quaternion
  1926. */
  1927. export class Vector4 {
  1928. /** x value of the vector */
  1929. x: number;
  1930. /** y value of the vector */
  1931. y: number;
  1932. /** z value of the vector */
  1933. z: number;
  1934. /** w value of the vector */
  1935. w: number;
  1936. /**
  1937. * Creates a Vector4 object from the given floats.
  1938. * @param x x value of the vector
  1939. * @param y y value of the vector
  1940. * @param z z value of the vector
  1941. * @param w w value of the vector
  1942. */
  1943. constructor(
  1944. /** x value of the vector */
  1945. x: number,
  1946. /** y value of the vector */
  1947. y: number,
  1948. /** z value of the vector */
  1949. z: number,
  1950. /** w value of the vector */
  1951. w: number);
  1952. /**
  1953. * Returns the string with the Vector4 coordinates.
  1954. * @returns a string containing all the vector values
  1955. */
  1956. toString(): string;
  1957. /**
  1958. * Returns the string "Vector4".
  1959. * @returns "Vector4"
  1960. */
  1961. getClassName(): string;
  1962. /**
  1963. * Returns the Vector4 hash code.
  1964. * @returns a unique hash code
  1965. */
  1966. getHashCode(): number;
  1967. /**
  1968. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  1969. * @returns the resulting array
  1970. */
  1971. asArray(): number[];
  1972. /**
  1973. * Populates the given array from the given index with the Vector4 coordinates.
  1974. * @param array array to populate
  1975. * @param index index of the array to start at (default: 0)
  1976. * @returns the Vector4.
  1977. */
  1978. toArray(array: FloatArray, index?: number): Vector4;
  1979. /**
  1980. * Adds the given vector to the current Vector4.
  1981. * @param otherVector the vector to add
  1982. * @returns the updated Vector4.
  1983. */
  1984. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  1985. /**
  1986. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  1987. * @param otherVector the vector to add
  1988. * @returns the resulting vector
  1989. */
  1990. add(otherVector: DeepImmutable<Vector4>): Vector4;
  1991. /**
  1992. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  1993. * @param otherVector the vector to add
  1994. * @param result the vector to store the result
  1995. * @returns the current Vector4.
  1996. */
  1997. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  1998. /**
  1999. * Subtract in place the given vector from the current Vector4.
  2000. * @param otherVector the vector to subtract
  2001. * @returns the updated Vector4.
  2002. */
  2003. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2004. /**
  2005. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  2006. * @param otherVector the vector to add
  2007. * @returns the new vector with the result
  2008. */
  2009. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  2010. /**
  2011. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  2012. * @param otherVector the vector to subtract
  2013. * @param result the vector to store the result
  2014. * @returns the current Vector4.
  2015. */
  2016. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2017. /**
  2018. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2019. */
  2020. /**
  2021. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2022. * @param x value to subtract
  2023. * @param y value to subtract
  2024. * @param z value to subtract
  2025. * @param w value to subtract
  2026. * @returns new vector containing the result
  2027. */
  2028. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2029. /**
  2030. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2031. * @param x value to subtract
  2032. * @param y value to subtract
  2033. * @param z value to subtract
  2034. * @param w value to subtract
  2035. * @param result the vector to store the result in
  2036. * @returns the current Vector4.
  2037. */
  2038. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  2039. /**
  2040. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  2041. * @returns a new vector with the negated values
  2042. */
  2043. negate(): Vector4;
  2044. /**
  2045. * Multiplies the current Vector4 coordinates by scale (float).
  2046. * @param scale the number to scale with
  2047. * @returns the updated Vector4.
  2048. */
  2049. scaleInPlace(scale: number): Vector4;
  2050. /**
  2051. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  2052. * @param scale the number to scale with
  2053. * @returns a new vector with the result
  2054. */
  2055. scale(scale: number): Vector4;
  2056. /**
  2057. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  2058. * @param scale the number to scale with
  2059. * @param result a vector to store the result in
  2060. * @returns the current Vector4.
  2061. */
  2062. scaleToRef(scale: number, result: Vector4): Vector4;
  2063. /**
  2064. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  2065. * @param scale defines the scale factor
  2066. * @param result defines the Vector4 object where to store the result
  2067. * @returns the unmodified current Vector4
  2068. */
  2069. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  2070. /**
  2071. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  2072. * @param otherVector the vector to compare against
  2073. * @returns true if they are equal
  2074. */
  2075. equals(otherVector: DeepImmutable<Vector4>): boolean;
  2076. /**
  2077. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  2078. * @param otherVector vector to compare against
  2079. * @param epsilon (Default: very small number)
  2080. * @returns true if they are equal
  2081. */
  2082. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  2083. /**
  2084. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  2085. * @param x x value to compare against
  2086. * @param y y value to compare against
  2087. * @param z z value to compare against
  2088. * @param w w value to compare against
  2089. * @returns true if equal
  2090. */
  2091. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  2092. /**
  2093. * Multiplies in place the current Vector4 by the given one.
  2094. * @param otherVector vector to multiple with
  2095. * @returns the updated Vector4.
  2096. */
  2097. multiplyInPlace(otherVector: Vector4): Vector4;
  2098. /**
  2099. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  2100. * @param otherVector vector to multiple with
  2101. * @returns resulting new vector
  2102. */
  2103. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  2104. /**
  2105. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  2106. * @param otherVector vector to multiple with
  2107. * @param result vector to store the result
  2108. * @returns the current Vector4.
  2109. */
  2110. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2111. /**
  2112. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  2113. * @param x x value multiply with
  2114. * @param y y value multiply with
  2115. * @param z z value multiply with
  2116. * @param w w value multiply with
  2117. * @returns resulting new vector
  2118. */
  2119. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  2120. /**
  2121. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  2122. * @param otherVector vector to devide with
  2123. * @returns resulting new vector
  2124. */
  2125. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  2126. /**
  2127. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  2128. * @param otherVector vector to devide with
  2129. * @param result vector to store the result
  2130. * @returns the current Vector4.
  2131. */
  2132. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2133. /**
  2134. * Divides the current Vector3 coordinates by the given ones.
  2135. * @param otherVector vector to devide with
  2136. * @returns the updated Vector3.
  2137. */
  2138. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2139. /**
  2140. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  2141. * @param other defines the second operand
  2142. * @returns the current updated Vector4
  2143. */
  2144. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2145. /**
  2146. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  2147. * @param other defines the second operand
  2148. * @returns the current updated Vector4
  2149. */
  2150. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2151. /**
  2152. * Gets a new Vector4 from current Vector4 floored values
  2153. * @returns a new Vector4
  2154. */
  2155. floor(): Vector4;
  2156. /**
  2157. * Gets a new Vector4 from current Vector3 floored values
  2158. * @returns a new Vector4
  2159. */
  2160. fract(): Vector4;
  2161. /**
  2162. * Returns the Vector4 length (float).
  2163. * @returns the length
  2164. */
  2165. length(): number;
  2166. /**
  2167. * Returns the Vector4 squared length (float).
  2168. * @returns the length squared
  2169. */
  2170. lengthSquared(): number;
  2171. /**
  2172. * Normalizes in place the Vector4.
  2173. * @returns the updated Vector4.
  2174. */
  2175. normalize(): Vector4;
  2176. /**
  2177. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  2178. * @returns this converted to a new vector3
  2179. */
  2180. toVector3(): Vector3;
  2181. /**
  2182. * Returns a new Vector4 copied from the current one.
  2183. * @returns the new cloned vector
  2184. */
  2185. clone(): Vector4;
  2186. /**
  2187. * Updates the current Vector4 with the given one coordinates.
  2188. * @param source the source vector to copy from
  2189. * @returns the updated Vector4.
  2190. */
  2191. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  2192. /**
  2193. * Updates the current Vector4 coordinates with the given floats.
  2194. * @param x float to copy from
  2195. * @param y float to copy from
  2196. * @param z float to copy from
  2197. * @param w float to copy from
  2198. * @returns the updated Vector4.
  2199. */
  2200. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2201. /**
  2202. * Updates the current Vector4 coordinates with the given floats.
  2203. * @param x float to set from
  2204. * @param y float to set from
  2205. * @param z float to set from
  2206. * @param w float to set from
  2207. * @returns the updated Vector4.
  2208. */
  2209. set(x: number, y: number, z: number, w: number): Vector4;
  2210. /**
  2211. * Copies the given float to the current Vector3 coordinates
  2212. * @param v defines the x, y, z and w coordinates of the operand
  2213. * @returns the current updated Vector3
  2214. */
  2215. setAll(v: number): Vector4;
  2216. /**
  2217. * Returns a new Vector4 set from the starting index of the given array.
  2218. * @param array the array to pull values from
  2219. * @param offset the offset into the array to start at
  2220. * @returns the new vector
  2221. */
  2222. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  2223. /**
  2224. * Updates the given vector "result" from the starting index of the given array.
  2225. * @param array the array to pull values from
  2226. * @param offset the offset into the array to start at
  2227. * @param result the vector to store the result in
  2228. */
  2229. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  2230. /**
  2231. * Updates the given vector "result" from the starting index of the given Float32Array.
  2232. * @param array the array to pull values from
  2233. * @param offset the offset into the array to start at
  2234. * @param result the vector to store the result in
  2235. */
  2236. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  2237. /**
  2238. * Updates the given vector "result" coordinates from the given floats.
  2239. * @param x float to set from
  2240. * @param y float to set from
  2241. * @param z float to set from
  2242. * @param w float to set from
  2243. * @param result the vector to the floats in
  2244. */
  2245. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  2246. /**
  2247. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  2248. * @returns the new vector
  2249. */
  2250. static Zero(): Vector4;
  2251. /**
  2252. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  2253. * @returns the new vector
  2254. */
  2255. static One(): Vector4;
  2256. /**
  2257. * Returns a new normalized Vector4 from the given one.
  2258. * @param vector the vector to normalize
  2259. * @returns the vector
  2260. */
  2261. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  2262. /**
  2263. * Updates the given vector "result" from the normalization of the given one.
  2264. * @param vector the vector to normalize
  2265. * @param result the vector to store the result in
  2266. */
  2267. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  2268. /**
  2269. * Returns a vector with the minimum values from the left and right vectors
  2270. * @param left left vector to minimize
  2271. * @param right right vector to minimize
  2272. * @returns a new vector with the minimum of the left and right vector values
  2273. */
  2274. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2275. /**
  2276. * Returns a vector with the maximum values from the left and right vectors
  2277. * @param left left vector to maximize
  2278. * @param right right vector to maximize
  2279. * @returns a new vector with the maximum of the left and right vector values
  2280. */
  2281. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2282. /**
  2283. * Returns the distance (float) between the vectors "value1" and "value2".
  2284. * @param value1 value to calulate the distance between
  2285. * @param value2 value to calulate the distance between
  2286. * @return the distance between the two vectors
  2287. */
  2288. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2289. /**
  2290. * Returns the squared distance (float) between the vectors "value1" and "value2".
  2291. * @param value1 value to calulate the distance between
  2292. * @param value2 value to calulate the distance between
  2293. * @return the distance between the two vectors squared
  2294. */
  2295. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2296. /**
  2297. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  2298. * @param value1 value to calulate the center between
  2299. * @param value2 value to calulate the center between
  2300. * @return the center between the two vectors
  2301. */
  2302. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  2303. /**
  2304. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  2305. * This methods computes transformed normalized direction vectors only.
  2306. * @param vector the vector to transform
  2307. * @param transformation the transformation matrix to apply
  2308. * @returns the new vector
  2309. */
  2310. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  2311. /**
  2312. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  2313. * This methods computes transformed normalized direction vectors only.
  2314. * @param vector the vector to transform
  2315. * @param transformation the transformation matrix to apply
  2316. * @param result the vector to store the result in
  2317. */
  2318. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2319. /**
  2320. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  2321. * This methods computes transformed normalized direction vectors only.
  2322. * @param x value to transform
  2323. * @param y value to transform
  2324. * @param z value to transform
  2325. * @param w value to transform
  2326. * @param transformation the transformation matrix to apply
  2327. * @param result the vector to store the results in
  2328. */
  2329. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2330. /**
  2331. * Creates a new Vector4 from a Vector3
  2332. * @param source defines the source data
  2333. * @param w defines the 4th component (default is 0)
  2334. * @returns a new Vector4
  2335. */
  2336. static FromVector3(source: Vector3, w?: number): Vector4;
  2337. }
  2338. /**
  2339. * Interface for the size containing width and height
  2340. */
  2341. export interface ISize {
  2342. /**
  2343. * Width
  2344. */
  2345. width: number;
  2346. /**
  2347. * Heighht
  2348. */
  2349. height: number;
  2350. }
  2351. /**
  2352. * Size containing widht and height
  2353. */
  2354. export class Size implements ISize {
  2355. /**
  2356. * Width
  2357. */
  2358. width: number;
  2359. /**
  2360. * Height
  2361. */
  2362. height: number;
  2363. /**
  2364. * Creates a Size object from the given width and height (floats).
  2365. * @param width width of the new size
  2366. * @param height height of the new size
  2367. */
  2368. constructor(width: number, height: number);
  2369. /**
  2370. * Returns a string with the Size width and height
  2371. * @returns a string with the Size width and height
  2372. */
  2373. toString(): string;
  2374. /**
  2375. * "Size"
  2376. * @returns the string "Size"
  2377. */
  2378. getClassName(): string;
  2379. /**
  2380. * Returns the Size hash code.
  2381. * @returns a hash code for a unique width and height
  2382. */
  2383. getHashCode(): number;
  2384. /**
  2385. * Updates the current size from the given one.
  2386. * @param src the given size
  2387. */
  2388. copyFrom(src: Size): void;
  2389. /**
  2390. * Updates in place the current Size from the given floats.
  2391. * @param width width of the new size
  2392. * @param height height of the new size
  2393. * @returns the updated Size.
  2394. */
  2395. copyFromFloats(width: number, height: number): Size;
  2396. /**
  2397. * Updates in place the current Size from the given floats.
  2398. * @param width width to set
  2399. * @param height height to set
  2400. * @returns the updated Size.
  2401. */
  2402. set(width: number, height: number): Size;
  2403. /**
  2404. * Multiplies the width and height by numbers
  2405. * @param w factor to multiple the width by
  2406. * @param h factor to multiple the height by
  2407. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  2408. */
  2409. multiplyByFloats(w: number, h: number): Size;
  2410. /**
  2411. * Clones the size
  2412. * @returns a new Size copied from the given one.
  2413. */
  2414. clone(): Size;
  2415. /**
  2416. * True if the current Size and the given one width and height are strictly equal.
  2417. * @param other the other size to compare against
  2418. * @returns True if the current Size and the given one width and height are strictly equal.
  2419. */
  2420. equals(other: Size): boolean;
  2421. /**
  2422. * The surface of the Size : width * height (float).
  2423. */
  2424. readonly surface: number;
  2425. /**
  2426. * Create a new size of zero
  2427. * @returns a new Size set to (0.0, 0.0)
  2428. */
  2429. static Zero(): Size;
  2430. /**
  2431. * Sums the width and height of two sizes
  2432. * @param otherSize size to add to this size
  2433. * @returns a new Size set as the addition result of the current Size and the given one.
  2434. */
  2435. add(otherSize: Size): Size;
  2436. /**
  2437. * Subtracts the width and height of two
  2438. * @param otherSize size to subtract to this size
  2439. * @returns a new Size set as the subtraction result of the given one from the current Size.
  2440. */
  2441. subtract(otherSize: Size): Size;
  2442. /**
  2443. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  2444. * @param start starting size to lerp between
  2445. * @param end end size to lerp between
  2446. * @param amount amount to lerp between the start and end values
  2447. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  2448. */
  2449. static Lerp(start: Size, end: Size, amount: number): Size;
  2450. }
  2451. /**
  2452. * Class used to store quaternion data
  2453. * @see https://en.wikipedia.org/wiki/Quaternion
  2454. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  2455. */
  2456. export class Quaternion {
  2457. /** defines the first component (0 by default) */
  2458. x: number;
  2459. /** defines the second component (0 by default) */
  2460. y: number;
  2461. /** defines the third component (0 by default) */
  2462. z: number;
  2463. /** defines the fourth component (1.0 by default) */
  2464. w: number;
  2465. /**
  2466. * Creates a new Quaternion from the given floats
  2467. * @param x defines the first component (0 by default)
  2468. * @param y defines the second component (0 by default)
  2469. * @param z defines the third component (0 by default)
  2470. * @param w defines the fourth component (1.0 by default)
  2471. */
  2472. constructor(
  2473. /** defines the first component (0 by default) */
  2474. x?: number,
  2475. /** defines the second component (0 by default) */
  2476. y?: number,
  2477. /** defines the third component (0 by default) */
  2478. z?: number,
  2479. /** defines the fourth component (1.0 by default) */
  2480. w?: number);
  2481. /**
  2482. * Gets a string representation for the current quaternion
  2483. * @returns a string with the Quaternion coordinates
  2484. */
  2485. toString(): string;
  2486. /**
  2487. * Gets the class name of the quaternion
  2488. * @returns the string "Quaternion"
  2489. */
  2490. getClassName(): string;
  2491. /**
  2492. * Gets a hash code for this quaternion
  2493. * @returns the quaternion hash code
  2494. */
  2495. getHashCode(): number;
  2496. /**
  2497. * Copy the quaternion to an array
  2498. * @returns a new array populated with 4 elements from the quaternion coordinates
  2499. */
  2500. asArray(): number[];
  2501. /**
  2502. * Check if two quaternions are equals
  2503. * @param otherQuaternion defines the second operand
  2504. * @return true if the current quaternion and the given one coordinates are strictly equals
  2505. */
  2506. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  2507. /**
  2508. * Clone the current quaternion
  2509. * @returns a new quaternion copied from the current one
  2510. */
  2511. clone(): Quaternion;
  2512. /**
  2513. * Copy a quaternion to the current one
  2514. * @param other defines the other quaternion
  2515. * @returns the updated current quaternion
  2516. */
  2517. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  2518. /**
  2519. * Updates the current quaternion with the given float coordinates
  2520. * @param x defines the x coordinate
  2521. * @param y defines the y coordinate
  2522. * @param z defines the z coordinate
  2523. * @param w defines the w coordinate
  2524. * @returns the updated current quaternion
  2525. */
  2526. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  2527. /**
  2528. * Updates the current quaternion from the given float coordinates
  2529. * @param x defines the x coordinate
  2530. * @param y defines the y coordinate
  2531. * @param z defines the z coordinate
  2532. * @param w defines the w coordinate
  2533. * @returns the updated current quaternion
  2534. */
  2535. set(x: number, y: number, z: number, w: number): Quaternion;
  2536. /**
  2537. * Adds two quaternions
  2538. * @param other defines the second operand
  2539. * @returns a new quaternion as the addition result of the given one and the current quaternion
  2540. */
  2541. add(other: DeepImmutable<Quaternion>): Quaternion;
  2542. /**
  2543. * Add a quaternion to the current one
  2544. * @param other defines the quaternion to add
  2545. * @returns the current quaternion
  2546. */
  2547. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  2548. /**
  2549. * Subtract two quaternions
  2550. * @param other defines the second operand
  2551. * @returns a new quaternion as the subtraction result of the given one from the current one
  2552. */
  2553. subtract(other: Quaternion): Quaternion;
  2554. /**
  2555. * Multiplies the current quaternion by a scale factor
  2556. * @param value defines the scale factor
  2557. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  2558. */
  2559. scale(value: number): Quaternion;
  2560. /**
  2561. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  2562. * @param scale defines the scale factor
  2563. * @param result defines the Quaternion object where to store the result
  2564. * @returns the unmodified current quaternion
  2565. */
  2566. scaleToRef(scale: number, result: Quaternion): Quaternion;
  2567. /**
  2568. * Multiplies in place the current quaternion by a scale factor
  2569. * @param value defines the scale factor
  2570. * @returns the current modified quaternion
  2571. */
  2572. scaleInPlace(value: number): Quaternion;
  2573. /**
  2574. * Scale the current quaternion values by a factor and add the result to a given quaternion
  2575. * @param scale defines the scale factor
  2576. * @param result defines the Quaternion object where to store the result
  2577. * @returns the unmodified current quaternion
  2578. */
  2579. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  2580. /**
  2581. * Multiplies two quaternions
  2582. * @param q1 defines the second operand
  2583. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  2584. */
  2585. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  2586. /**
  2587. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  2588. * @param q1 defines the second operand
  2589. * @param result defines the target quaternion
  2590. * @returns the current quaternion
  2591. */
  2592. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  2593. /**
  2594. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  2595. * @param q1 defines the second operand
  2596. * @returns the currentupdated quaternion
  2597. */
  2598. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  2599. /**
  2600. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  2601. * @param ref defines the target quaternion
  2602. * @returns the current quaternion
  2603. */
  2604. conjugateToRef(ref: Quaternion): Quaternion;
  2605. /**
  2606. * Conjugates in place (1-q) the current quaternion
  2607. * @returns the current updated quaternion
  2608. */
  2609. conjugateInPlace(): Quaternion;
  2610. /**
  2611. * Conjugates in place (1-q) the current quaternion
  2612. * @returns a new quaternion
  2613. */
  2614. conjugate(): Quaternion;
  2615. /**
  2616. * Gets length of current quaternion
  2617. * @returns the quaternion length (float)
  2618. */
  2619. length(): number;
  2620. /**
  2621. * Normalize in place the current quaternion
  2622. * @returns the current updated quaternion
  2623. */
  2624. normalize(): Quaternion;
  2625. /**
  2626. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  2627. * @param order is a reserved parameter and is ignore for now
  2628. * @returns a new Vector3 containing the Euler angles
  2629. */
  2630. toEulerAngles(order?: string): Vector3;
  2631. /**
  2632. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  2633. * @param result defines the vector which will be filled with the Euler angles
  2634. * @param order is a reserved parameter and is ignore for now
  2635. * @returns the current unchanged quaternion
  2636. */
  2637. toEulerAnglesToRef(result: Vector3): Quaternion;
  2638. /**
  2639. * Updates the given rotation matrix with the current quaternion values
  2640. * @param result defines the target matrix
  2641. * @returns the current unchanged quaternion
  2642. */
  2643. toRotationMatrix(result: Matrix): Quaternion;
  2644. /**
  2645. * Updates the current quaternion from the given rotation matrix values
  2646. * @param matrix defines the source matrix
  2647. * @returns the current updated quaternion
  2648. */
  2649. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  2650. /**
  2651. * Creates a new quaternion from a rotation matrix
  2652. * @param matrix defines the source matrix
  2653. * @returns a new quaternion created from the given rotation matrix values
  2654. */
  2655. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  2656. /**
  2657. * Updates the given quaternion with the given rotation matrix values
  2658. * @param matrix defines the source matrix
  2659. * @param result defines the target quaternion
  2660. */
  2661. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  2662. /**
  2663. * Returns the dot product (float) between the quaternions "left" and "right"
  2664. * @param left defines the left operand
  2665. * @param right defines the right operand
  2666. * @returns the dot product
  2667. */
  2668. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  2669. /**
  2670. * Checks if the two quaternions are close to each other
  2671. * @param quat0 defines the first quaternion to check
  2672. * @param quat1 defines the second quaternion to check
  2673. * @returns true if the two quaternions are close to each other
  2674. */
  2675. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  2676. /**
  2677. * Creates an empty quaternion
  2678. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  2679. */
  2680. static Zero(): Quaternion;
  2681. /**
  2682. * Inverse a given quaternion
  2683. * @param q defines the source quaternion
  2684. * @returns a new quaternion as the inverted current quaternion
  2685. */
  2686. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  2687. /**
  2688. * Inverse a given quaternion
  2689. * @param q defines the source quaternion
  2690. * @param result the quaternion the result will be stored in
  2691. * @returns the result quaternion
  2692. */
  2693. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  2694. /**
  2695. * Creates an identity quaternion
  2696. * @returns the identity quaternion
  2697. */
  2698. static Identity(): Quaternion;
  2699. /**
  2700. * Gets a boolean indicating if the given quaternion is identity
  2701. * @param quaternion defines the quaternion to check
  2702. * @returns true if the quaternion is identity
  2703. */
  2704. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  2705. /**
  2706. * Creates a quaternion from a rotation around an axis
  2707. * @param axis defines the axis to use
  2708. * @param angle defines the angle to use
  2709. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  2710. */
  2711. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  2712. /**
  2713. * Creates a rotation around an axis and stores it into the given quaternion
  2714. * @param axis defines the axis to use
  2715. * @param angle defines the angle to use
  2716. * @param result defines the target quaternion
  2717. * @returns the target quaternion
  2718. */
  2719. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  2720. /**
  2721. * Creates a new quaternion from data stored into an array
  2722. * @param array defines the data source
  2723. * @param offset defines the offset in the source array where the data starts
  2724. * @returns a new quaternion
  2725. */
  2726. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  2727. /**
  2728. * Create a quaternion from Euler rotation angles
  2729. * @param x Pitch
  2730. * @param y Yaw
  2731. * @param z Roll
  2732. * @returns the new Quaternion
  2733. */
  2734. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  2735. /**
  2736. * Updates a quaternion from Euler rotation angles
  2737. * @param x Pitch
  2738. * @param y Yaw
  2739. * @param z Roll
  2740. * @param result the quaternion to store the result
  2741. * @returns the updated quaternion
  2742. */
  2743. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  2744. /**
  2745. * Create a quaternion from Euler rotation vector
  2746. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  2747. * @returns the new Quaternion
  2748. */
  2749. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  2750. /**
  2751. * Updates a quaternion from Euler rotation vector
  2752. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  2753. * @param result the quaternion to store the result
  2754. * @returns the updated quaternion
  2755. */
  2756. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  2757. /**
  2758. * Creates a new quaternion from the given Euler float angles (y, x, z)
  2759. * @param yaw defines the rotation around Y axis
  2760. * @param pitch defines the rotation around X axis
  2761. * @param roll defines the rotation around Z axis
  2762. * @returns the new quaternion
  2763. */
  2764. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  2765. /**
  2766. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  2767. * @param yaw defines the rotation around Y axis
  2768. * @param pitch defines the rotation around X axis
  2769. * @param roll defines the rotation around Z axis
  2770. * @param result defines the target quaternion
  2771. */
  2772. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  2773. /**
  2774. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  2775. * @param alpha defines the rotation around first axis
  2776. * @param beta defines the rotation around second axis
  2777. * @param gamma defines the rotation around third axis
  2778. * @returns the new quaternion
  2779. */
  2780. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  2781. /**
  2782. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  2783. * @param alpha defines the rotation around first axis
  2784. * @param beta defines the rotation around second axis
  2785. * @param gamma defines the rotation around third axis
  2786. * @param result defines the target quaternion
  2787. */
  2788. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  2789. /**
  2790. * 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)
  2791. * @param axis1 defines the first axis
  2792. * @param axis2 defines the second axis
  2793. * @param axis3 defines the third axis
  2794. * @returns the new quaternion
  2795. */
  2796. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  2797. /**
  2798. * 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
  2799. * @param axis1 defines the first axis
  2800. * @param axis2 defines the second axis
  2801. * @param axis3 defines the third axis
  2802. * @param ref defines the target quaternion
  2803. */
  2804. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  2805. /**
  2806. * Interpolates between two quaternions
  2807. * @param left defines first quaternion
  2808. * @param right defines second quaternion
  2809. * @param amount defines the gradient to use
  2810. * @returns the new interpolated quaternion
  2811. */
  2812. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  2813. /**
  2814. * Interpolates between two quaternions and stores it into a target quaternion
  2815. * @param left defines first quaternion
  2816. * @param right defines second quaternion
  2817. * @param amount defines the gradient to use
  2818. * @param result defines the target quaternion
  2819. */
  2820. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  2821. /**
  2822. * Interpolate between two quaternions using Hermite interpolation
  2823. * @param value1 defines first quaternion
  2824. * @param tangent1 defines the incoming tangent
  2825. * @param value2 defines second quaternion
  2826. * @param tangent2 defines the outgoing tangent
  2827. * @param amount defines the target quaternion
  2828. * @returns the new interpolated quaternion
  2829. */
  2830. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  2831. }
  2832. /**
  2833. * Class used to store matrix data (4x4)
  2834. */
  2835. export class Matrix {
  2836. private static _updateFlagSeed;
  2837. private static _identityReadOnly;
  2838. private _isIdentity;
  2839. private _isIdentityDirty;
  2840. private _isIdentity3x2;
  2841. private _isIdentity3x2Dirty;
  2842. /**
  2843. * Gets the update flag of the matrix which is an unique number for the matrix.
  2844. * It will be incremented every time the matrix data change.
  2845. * You can use it to speed the comparison between two versions of the same matrix.
  2846. */
  2847. updateFlag: number;
  2848. private readonly _m;
  2849. /**
  2850. * Gets the internal data of the matrix
  2851. */
  2852. readonly m: DeepImmutable<Float32Array>;
  2853. /** @hidden */
  2854. _markAsUpdated(): void;
  2855. /** @hidden */
  2856. private _updateIdentityStatus;
  2857. /**
  2858. * Creates an empty matrix (filled with zeros)
  2859. */
  2860. constructor();
  2861. /**
  2862. * Check if the current matrix is identity
  2863. * @returns true is the matrix is the identity matrix
  2864. */
  2865. isIdentity(): boolean;
  2866. /**
  2867. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  2868. * @returns true is the matrix is the identity matrix
  2869. */
  2870. isIdentityAs3x2(): boolean;
  2871. /**
  2872. * Gets the determinant of the matrix
  2873. * @returns the matrix determinant
  2874. */
  2875. determinant(): number;
  2876. /**
  2877. * Returns the matrix as a Float32Array
  2878. * @returns the matrix underlying array
  2879. */
  2880. toArray(): DeepImmutable<Float32Array>;
  2881. /**
  2882. * Returns the matrix as a Float32Array
  2883. * @returns the matrix underlying array.
  2884. */
  2885. asArray(): DeepImmutable<Float32Array>;
  2886. /**
  2887. * Inverts the current matrix in place
  2888. * @returns the current inverted matrix
  2889. */
  2890. invert(): Matrix;
  2891. /**
  2892. * Sets all the matrix elements to zero
  2893. * @returns the current matrix
  2894. */
  2895. reset(): Matrix;
  2896. /**
  2897. * Adds the current matrix with a second one
  2898. * @param other defines the matrix to add
  2899. * @returns a new matrix as the addition of the current matrix and the given one
  2900. */
  2901. add(other: DeepImmutable<Matrix>): Matrix;
  2902. /**
  2903. * Sets the given matrix "result" to the addition of the current matrix and the given one
  2904. * @param other defines the matrix to add
  2905. * @param result defines the target matrix
  2906. * @returns the current matrix
  2907. */
  2908. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  2909. /**
  2910. * Adds in place the given matrix to the current matrix
  2911. * @param other defines the second operand
  2912. * @returns the current updated matrix
  2913. */
  2914. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  2915. /**
  2916. * Sets the given matrix to the current inverted Matrix
  2917. * @param other defines the target matrix
  2918. * @returns the unmodified current matrix
  2919. */
  2920. invertToRef(other: Matrix): Matrix;
  2921. /**
  2922. * add a value at the specified position in the current Matrix
  2923. * @param index the index of the value within the matrix. between 0 and 15.
  2924. * @param value the value to be added
  2925. * @returns the current updated matrix
  2926. */
  2927. addAtIndex(index: number, value: number): Matrix;
  2928. /**
  2929. * mutiply the specified position in the current Matrix by a value
  2930. * @param index the index of the value within the matrix. between 0 and 15.
  2931. * @param value the value to be added
  2932. * @returns the current updated matrix
  2933. */
  2934. multiplyAtIndex(index: number, value: number): Matrix;
  2935. /**
  2936. * Inserts the translation vector (using 3 floats) in the current matrix
  2937. * @param x defines the 1st component of the translation
  2938. * @param y defines the 2nd component of the translation
  2939. * @param z defines the 3rd component of the translation
  2940. * @returns the current updated matrix
  2941. */
  2942. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  2943. /**
  2944. * Adds the translation vector (using 3 floats) in the current matrix
  2945. * @param x defines the 1st component of the translation
  2946. * @param y defines the 2nd component of the translation
  2947. * @param z defines the 3rd component of the translation
  2948. * @returns the current updated matrix
  2949. */
  2950. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  2951. /**
  2952. * Inserts the translation vector in the current matrix
  2953. * @param vector3 defines the translation to insert
  2954. * @returns the current updated matrix
  2955. */
  2956. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  2957. /**
  2958. * Gets the translation value of the current matrix
  2959. * @returns a new Vector3 as the extracted translation from the matrix
  2960. */
  2961. getTranslation(): Vector3;
  2962. /**
  2963. * Fill a Vector3 with the extracted translation from the matrix
  2964. * @param result defines the Vector3 where to store the translation
  2965. * @returns the current matrix
  2966. */
  2967. getTranslationToRef(result: Vector3): Matrix;
  2968. /**
  2969. * Remove rotation and scaling part from the matrix
  2970. * @returns the updated matrix
  2971. */
  2972. removeRotationAndScaling(): Matrix;
  2973. /**
  2974. * Multiply two matrices
  2975. * @param other defines the second operand
  2976. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  2977. */
  2978. multiply(other: DeepImmutable<Matrix>): Matrix;
  2979. /**
  2980. * Copy the current matrix from the given one
  2981. * @param other defines the source matrix
  2982. * @returns the current updated matrix
  2983. */
  2984. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  2985. /**
  2986. * Populates the given array from the starting index with the current matrix values
  2987. * @param array defines the target array
  2988. * @param offset defines the offset in the target array where to start storing values
  2989. * @returns the current matrix
  2990. */
  2991. copyToArray(array: Float32Array, offset?: number): Matrix;
  2992. /**
  2993. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  2994. * @param other defines the second operand
  2995. * @param result defines the matrix where to store the multiplication
  2996. * @returns the current matrix
  2997. */
  2998. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  2999. /**
  3000. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  3001. * @param other defines the second operand
  3002. * @param result defines the array where to store the multiplication
  3003. * @param offset defines the offset in the target array where to start storing values
  3004. * @returns the current matrix
  3005. */
  3006. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  3007. /**
  3008. * Check equality between this matrix and a second one
  3009. * @param value defines the second matrix to compare
  3010. * @returns true is the current matrix and the given one values are strictly equal
  3011. */
  3012. equals(value: DeepImmutable<Matrix>): boolean;
  3013. /**
  3014. * Clone the current matrix
  3015. * @returns a new matrix from the current matrix
  3016. */
  3017. clone(): Matrix;
  3018. /**
  3019. * Returns the name of the current matrix class
  3020. * @returns the string "Matrix"
  3021. */
  3022. getClassName(): string;
  3023. /**
  3024. * Gets the hash code of the current matrix
  3025. * @returns the hash code
  3026. */
  3027. getHashCode(): number;
  3028. /**
  3029. * Decomposes the current Matrix into a translation, rotation and scaling components
  3030. * @param scale defines the scale vector3 given as a reference to update
  3031. * @param rotation defines the rotation quaternion given as a reference to update
  3032. * @param translation defines the translation vector3 given as a reference to update
  3033. * @returns true if operation was successful
  3034. */
  3035. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  3036. /**
  3037. * Gets specific row of the matrix
  3038. * @param index defines the number of the row to get
  3039. * @returns the index-th row of the current matrix as a new Vector4
  3040. */
  3041. getRow(index: number): Nullable<Vector4>;
  3042. /**
  3043. * Sets the index-th row of the current matrix to the vector4 values
  3044. * @param index defines the number of the row to set
  3045. * @param row defines the target vector4
  3046. * @returns the updated current matrix
  3047. */
  3048. setRow(index: number, row: Vector4): Matrix;
  3049. /**
  3050. * Compute the transpose of the matrix
  3051. * @returns the new transposed matrix
  3052. */
  3053. transpose(): Matrix;
  3054. /**
  3055. * Compute the transpose of the matrix and store it in a given matrix
  3056. * @param result defines the target matrix
  3057. * @returns the current matrix
  3058. */
  3059. transposeToRef(result: Matrix): Matrix;
  3060. /**
  3061. * Sets the index-th row of the current matrix with the given 4 x float values
  3062. * @param index defines the row index
  3063. * @param x defines the x component to set
  3064. * @param y defines the y component to set
  3065. * @param z defines the z component to set
  3066. * @param w defines the w component to set
  3067. * @returns the updated current matrix
  3068. */
  3069. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  3070. /**
  3071. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  3072. * @param scale defines the scale factor
  3073. * @returns a new matrix
  3074. */
  3075. scale(scale: number): Matrix;
  3076. /**
  3077. * Scale the current matrix values by a factor to a given result matrix
  3078. * @param scale defines the scale factor
  3079. * @param result defines the matrix to store the result
  3080. * @returns the current matrix
  3081. */
  3082. scaleToRef(scale: number, result: Matrix): Matrix;
  3083. /**
  3084. * Scale the current matrix values by a factor and add the result to a given matrix
  3085. * @param scale defines the scale factor
  3086. * @param result defines the Matrix to store the result
  3087. * @returns the current matrix
  3088. */
  3089. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  3090. /**
  3091. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  3092. * @param ref matrix to store the result
  3093. */
  3094. toNormalMatrix(ref: Matrix): void;
  3095. /**
  3096. * Gets only rotation part of the current matrix
  3097. * @returns a new matrix sets to the extracted rotation matrix from the current one
  3098. */
  3099. getRotationMatrix(): Matrix;
  3100. /**
  3101. * Extracts the rotation matrix from the current one and sets it as the given "result"
  3102. * @param result defines the target matrix to store data to
  3103. * @returns the current matrix
  3104. */
  3105. getRotationMatrixToRef(result: Matrix): Matrix;
  3106. /**
  3107. * Toggles model matrix from being right handed to left handed in place and vice versa
  3108. */
  3109. toggleModelMatrixHandInPlace(): void;
  3110. /**
  3111. * Toggles projection matrix from being right handed to left handed in place and vice versa
  3112. */
  3113. toggleProjectionMatrixHandInPlace(): void;
  3114. /**
  3115. * Creates a matrix from an array
  3116. * @param array defines the source array
  3117. * @param offset defines an offset in the source array
  3118. * @returns a new Matrix set from the starting index of the given array
  3119. */
  3120. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  3121. /**
  3122. * Copy the content of an array into a given matrix
  3123. * @param array defines the source array
  3124. * @param offset defines an offset in the source array
  3125. * @param result defines the target matrix
  3126. */
  3127. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  3128. /**
  3129. * Stores an array into a matrix after having multiplied each component by a given factor
  3130. * @param array defines the source array
  3131. * @param offset defines the offset in the source array
  3132. * @param scale defines the scaling factor
  3133. * @param result defines the target matrix
  3134. */
  3135. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  3136. /**
  3137. * Gets an identity matrix that must not be updated
  3138. */
  3139. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  3140. /**
  3141. * Stores a list of values (16) inside a given matrix
  3142. * @param initialM11 defines 1st value of 1st row
  3143. * @param initialM12 defines 2nd value of 1st row
  3144. * @param initialM13 defines 3rd value of 1st row
  3145. * @param initialM14 defines 4th value of 1st row
  3146. * @param initialM21 defines 1st value of 2nd row
  3147. * @param initialM22 defines 2nd value of 2nd row
  3148. * @param initialM23 defines 3rd value of 2nd row
  3149. * @param initialM24 defines 4th value of 2nd row
  3150. * @param initialM31 defines 1st value of 3rd row
  3151. * @param initialM32 defines 2nd value of 3rd row
  3152. * @param initialM33 defines 3rd value of 3rd row
  3153. * @param initialM34 defines 4th value of 3rd row
  3154. * @param initialM41 defines 1st value of 4th row
  3155. * @param initialM42 defines 2nd value of 4th row
  3156. * @param initialM43 defines 3rd value of 4th row
  3157. * @param initialM44 defines 4th value of 4th row
  3158. * @param result defines the target matrix
  3159. */
  3160. 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;
  3161. /**
  3162. * Creates new matrix from a list of values (16)
  3163. * @param initialM11 defines 1st value of 1st row
  3164. * @param initialM12 defines 2nd value of 1st row
  3165. * @param initialM13 defines 3rd value of 1st row
  3166. * @param initialM14 defines 4th value of 1st row
  3167. * @param initialM21 defines 1st value of 2nd row
  3168. * @param initialM22 defines 2nd value of 2nd row
  3169. * @param initialM23 defines 3rd value of 2nd row
  3170. * @param initialM24 defines 4th value of 2nd row
  3171. * @param initialM31 defines 1st value of 3rd row
  3172. * @param initialM32 defines 2nd value of 3rd row
  3173. * @param initialM33 defines 3rd value of 3rd row
  3174. * @param initialM34 defines 4th value of 3rd row
  3175. * @param initialM41 defines 1st value of 4th row
  3176. * @param initialM42 defines 2nd value of 4th row
  3177. * @param initialM43 defines 3rd value of 4th row
  3178. * @param initialM44 defines 4th value of 4th row
  3179. * @returns the new matrix
  3180. */
  3181. 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;
  3182. /**
  3183. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3184. * @param scale defines the scale vector3
  3185. * @param rotation defines the rotation quaternion
  3186. * @param translation defines the translation vector3
  3187. * @returns a new matrix
  3188. */
  3189. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  3190. /**
  3191. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3192. * @param scale defines the scale vector3
  3193. * @param rotation defines the rotation quaternion
  3194. * @param translation defines the translation vector3
  3195. * @param result defines the target matrix
  3196. */
  3197. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  3198. /**
  3199. * Creates a new identity matrix
  3200. * @returns a new identity matrix
  3201. */
  3202. static Identity(): Matrix;
  3203. /**
  3204. * Creates a new identity matrix and stores the result in a given matrix
  3205. * @param result defines the target matrix
  3206. */
  3207. static IdentityToRef(result: Matrix): void;
  3208. /**
  3209. * Creates a new zero matrix
  3210. * @returns a new zero matrix
  3211. */
  3212. static Zero(): Matrix;
  3213. /**
  3214. * Creates a new rotation matrix for "angle" radians around the X axis
  3215. * @param angle defines the angle (in radians) to use
  3216. * @return the new matrix
  3217. */
  3218. static RotationX(angle: number): Matrix;
  3219. /**
  3220. * Creates a new matrix as the invert of a given matrix
  3221. * @param source defines the source matrix
  3222. * @returns the new matrix
  3223. */
  3224. static Invert(source: DeepImmutable<Matrix>): Matrix;
  3225. /**
  3226. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  3227. * @param angle defines the angle (in radians) to use
  3228. * @param result defines the target matrix
  3229. */
  3230. static RotationXToRef(angle: number, result: Matrix): void;
  3231. /**
  3232. * Creates a new rotation matrix for "angle" radians around the Y axis
  3233. * @param angle defines the angle (in radians) to use
  3234. * @return the new matrix
  3235. */
  3236. static RotationY(angle: number): Matrix;
  3237. /**
  3238. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  3239. * @param angle defines the angle (in radians) to use
  3240. * @param result defines the target matrix
  3241. */
  3242. static RotationYToRef(angle: number, result: Matrix): void;
  3243. /**
  3244. * Creates a new rotation matrix for "angle" radians around the Z axis
  3245. * @param angle defines the angle (in radians) to use
  3246. * @return the new matrix
  3247. */
  3248. static RotationZ(angle: number): Matrix;
  3249. /**
  3250. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  3251. * @param angle defines the angle (in radians) to use
  3252. * @param result defines the target matrix
  3253. */
  3254. static RotationZToRef(angle: number, result: Matrix): void;
  3255. /**
  3256. * Creates a new rotation matrix for "angle" radians around the given axis
  3257. * @param axis defines the axis to use
  3258. * @param angle defines the angle (in radians) to use
  3259. * @return the new matrix
  3260. */
  3261. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  3262. /**
  3263. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  3264. * @param axis defines the axis to use
  3265. * @param angle defines the angle (in radians) to use
  3266. * @param result defines the target matrix
  3267. */
  3268. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  3269. /**
  3270. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  3271. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  3272. * @param from defines the vector to align
  3273. * @param to defines the vector to align to
  3274. * @param result defines the target matrix
  3275. */
  3276. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  3277. /**
  3278. * Creates a rotation matrix
  3279. * @param yaw defines the yaw angle in radians (Y axis)
  3280. * @param pitch defines the pitch angle in radians (X axis)
  3281. * @param roll defines the roll angle in radians (X axis)
  3282. * @returns the new rotation matrix
  3283. */
  3284. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  3285. /**
  3286. * Creates a rotation matrix and stores it in a given matrix
  3287. * @param yaw defines the yaw angle in radians (Y axis)
  3288. * @param pitch defines the pitch angle in radians (X axis)
  3289. * @param roll defines the roll angle in radians (X axis)
  3290. * @param result defines the target matrix
  3291. */
  3292. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  3293. /**
  3294. * Creates a scaling matrix
  3295. * @param x defines the scale factor on X axis
  3296. * @param y defines the scale factor on Y axis
  3297. * @param z defines the scale factor on Z axis
  3298. * @returns the new matrix
  3299. */
  3300. static Scaling(x: number, y: number, z: number): Matrix;
  3301. /**
  3302. * Creates a scaling matrix and stores it in a given matrix
  3303. * @param x defines the scale factor on X axis
  3304. * @param y defines the scale factor on Y axis
  3305. * @param z defines the scale factor on Z axis
  3306. * @param result defines the target matrix
  3307. */
  3308. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  3309. /**
  3310. * Creates a translation matrix
  3311. * @param x defines the translation on X axis
  3312. * @param y defines the translation on Y axis
  3313. * @param z defines the translationon Z axis
  3314. * @returns the new matrix
  3315. */
  3316. static Translation(x: number, y: number, z: number): Matrix;
  3317. /**
  3318. * Creates a translation matrix and stores it in a given matrix
  3319. * @param x defines the translation on X axis
  3320. * @param y defines the translation on Y axis
  3321. * @param z defines the translationon Z axis
  3322. * @param result defines the target matrix
  3323. */
  3324. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  3325. /**
  3326. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3327. * @param startValue defines the start value
  3328. * @param endValue defines the end value
  3329. * @param gradient defines the gradient factor
  3330. * @returns the new matrix
  3331. */
  3332. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3333. /**
  3334. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3335. * @param startValue defines the start value
  3336. * @param endValue defines the end value
  3337. * @param gradient defines the gradient factor
  3338. * @param result defines the Matrix object where to store data
  3339. */
  3340. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3341. /**
  3342. * Builds a new matrix whose values are computed by:
  3343. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3344. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3345. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3346. * @param startValue defines the first matrix
  3347. * @param endValue defines the second matrix
  3348. * @param gradient defines the gradient between the two matrices
  3349. * @returns the new matrix
  3350. */
  3351. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3352. /**
  3353. * Update a matrix to values which are computed by:
  3354. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3355. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3356. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3357. * @param startValue defines the first matrix
  3358. * @param endValue defines the second matrix
  3359. * @param gradient defines the gradient between the two matrices
  3360. * @param result defines the target matrix
  3361. */
  3362. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3363. /**
  3364. * 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"
  3365. * This function works in left handed mode
  3366. * @param eye defines the final position of the entity
  3367. * @param target defines where the entity should look at
  3368. * @param up defines the up vector for the entity
  3369. * @returns the new matrix
  3370. */
  3371. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3372. /**
  3373. * 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".
  3374. * This function works in left handed mode
  3375. * @param eye defines the final position of the entity
  3376. * @param target defines where the entity should look at
  3377. * @param up defines the up vector for the entity
  3378. * @param result defines the target matrix
  3379. */
  3380. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3381. /**
  3382. * 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"
  3383. * This function works in right handed mode
  3384. * @param eye defines the final position of the entity
  3385. * @param target defines where the entity should look at
  3386. * @param up defines the up vector for the entity
  3387. * @returns the new matrix
  3388. */
  3389. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3390. /**
  3391. * 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".
  3392. * This function works in right handed mode
  3393. * @param eye defines the final position of the entity
  3394. * @param target defines where the entity should look at
  3395. * @param up defines the up vector for the entity
  3396. * @param result defines the target matrix
  3397. */
  3398. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3399. /**
  3400. * Create a left-handed orthographic projection matrix
  3401. * @param width defines the viewport width
  3402. * @param height defines the viewport height
  3403. * @param znear defines the near clip plane
  3404. * @param zfar defines the far clip plane
  3405. * @returns a new matrix as a left-handed orthographic projection matrix
  3406. */
  3407. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3408. /**
  3409. * Store a left-handed orthographic projection to a given matrix
  3410. * @param width defines the viewport width
  3411. * @param height defines the viewport height
  3412. * @param znear defines the near clip plane
  3413. * @param zfar defines the far clip plane
  3414. * @param result defines the target matrix
  3415. */
  3416. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  3417. /**
  3418. * Create a left-handed orthographic projection matrix
  3419. * @param left defines the viewport left coordinate
  3420. * @param right defines the viewport right coordinate
  3421. * @param bottom defines the viewport bottom coordinate
  3422. * @param top defines the viewport top coordinate
  3423. * @param znear defines the near clip plane
  3424. * @param zfar defines the far clip plane
  3425. * @returns a new matrix as a left-handed orthographic projection matrix
  3426. */
  3427. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3428. /**
  3429. * Stores a left-handed orthographic projection into a given matrix
  3430. * @param left defines the viewport left coordinate
  3431. * @param right defines the viewport right coordinate
  3432. * @param bottom defines the viewport bottom coordinate
  3433. * @param top defines the viewport top coordinate
  3434. * @param znear defines the near clip plane
  3435. * @param zfar defines the far clip plane
  3436. * @param result defines the target matrix
  3437. */
  3438. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3439. /**
  3440. * Creates a right-handed orthographic projection matrix
  3441. * @param left defines the viewport left coordinate
  3442. * @param right defines the viewport right coordinate
  3443. * @param bottom defines the viewport bottom coordinate
  3444. * @param top defines the viewport top coordinate
  3445. * @param znear defines the near clip plane
  3446. * @param zfar defines the far clip plane
  3447. * @returns a new matrix as a right-handed orthographic projection matrix
  3448. */
  3449. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3450. /**
  3451. * Stores a right-handed orthographic projection into a given matrix
  3452. * @param left defines the viewport left coordinate
  3453. * @param right defines the viewport right coordinate
  3454. * @param bottom defines the viewport bottom coordinate
  3455. * @param top defines the viewport top coordinate
  3456. * @param znear defines the near clip plane
  3457. * @param zfar defines the far clip plane
  3458. * @param result defines the target matrix
  3459. */
  3460. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3461. /**
  3462. * Creates a left-handed perspective projection matrix
  3463. * @param width defines the viewport width
  3464. * @param height defines the viewport height
  3465. * @param znear defines the near clip plane
  3466. * @param zfar defines the far clip plane
  3467. * @returns a new matrix as a left-handed perspective projection matrix
  3468. */
  3469. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3470. /**
  3471. * Creates a left-handed perspective projection matrix
  3472. * @param fov defines the horizontal field of view
  3473. * @param aspect defines the aspect ratio
  3474. * @param znear defines the near clip plane
  3475. * @param zfar defines the far clip plane
  3476. * @returns a new matrix as a left-handed perspective projection matrix
  3477. */
  3478. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3479. /**
  3480. * Stores a left-handed perspective projection into a given matrix
  3481. * @param fov defines the horizontal field of view
  3482. * @param aspect defines the aspect ratio
  3483. * @param znear defines the near clip plane
  3484. * @param zfar defines the far clip plane
  3485. * @param result defines the target matrix
  3486. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3487. */
  3488. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3489. /**
  3490. * Creates a right-handed perspective projection matrix
  3491. * @param fov defines the horizontal field of view
  3492. * @param aspect defines the aspect ratio
  3493. * @param znear defines the near clip plane
  3494. * @param zfar defines the far clip plane
  3495. * @returns a new matrix as a right-handed perspective projection matrix
  3496. */
  3497. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3498. /**
  3499. * Stores a right-handed perspective projection into a given matrix
  3500. * @param fov defines the horizontal field of view
  3501. * @param aspect defines the aspect ratio
  3502. * @param znear defines the near clip plane
  3503. * @param zfar defines the far clip plane
  3504. * @param result defines the target matrix
  3505. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3506. */
  3507. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3508. /**
  3509. * Stores a perspective projection for WebVR info a given matrix
  3510. * @param fov defines the field of view
  3511. * @param znear defines the near clip plane
  3512. * @param zfar defines the far clip plane
  3513. * @param result defines the target matrix
  3514. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  3515. */
  3516. static PerspectiveFovWebVRToRef(fov: {
  3517. upDegrees: number;
  3518. downDegrees: number;
  3519. leftDegrees: number;
  3520. rightDegrees: number;
  3521. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  3522. /**
  3523. * Computes a complete transformation matrix
  3524. * @param viewport defines the viewport to use
  3525. * @param world defines the world matrix
  3526. * @param view defines the view matrix
  3527. * @param projection defines the projection matrix
  3528. * @param zmin defines the near clip plane
  3529. * @param zmax defines the far clip plane
  3530. * @returns the transformation matrix
  3531. */
  3532. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  3533. /**
  3534. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  3535. * @param matrix defines the matrix to use
  3536. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  3537. */
  3538. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  3539. /**
  3540. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  3541. * @param matrix defines the matrix to use
  3542. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  3543. */
  3544. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  3545. /**
  3546. * Compute the transpose of a given matrix
  3547. * @param matrix defines the matrix to transpose
  3548. * @returns the new matrix
  3549. */
  3550. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  3551. /**
  3552. * Compute the transpose of a matrix and store it in a target matrix
  3553. * @param matrix defines the matrix to transpose
  3554. * @param result defines the target matrix
  3555. */
  3556. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  3557. /**
  3558. * Computes a reflection matrix from a plane
  3559. * @param plane defines the reflection plane
  3560. * @returns a new matrix
  3561. */
  3562. static Reflection(plane: DeepImmutable<Plane>): Matrix;
  3563. /**
  3564. * Computes a reflection matrix from a plane
  3565. * @param plane defines the reflection plane
  3566. * @param result defines the target matrix
  3567. */
  3568. static ReflectionToRef(plane: DeepImmutable<Plane>, result: Matrix): void;
  3569. /**
  3570. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  3571. * @param xaxis defines the value of the 1st axis
  3572. * @param yaxis defines the value of the 2nd axis
  3573. * @param zaxis defines the value of the 3rd axis
  3574. * @param result defines the target matrix
  3575. */
  3576. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  3577. /**
  3578. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  3579. * @param quat defines the quaternion to use
  3580. * @param result defines the target matrix
  3581. */
  3582. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  3583. }
  3584. /**
  3585. * Represens a plane by the equation ax + by + cz + d = 0
  3586. */
  3587. export class Plane {
  3588. /**
  3589. * Normal of the plane (a,b,c)
  3590. */
  3591. normal: Vector3;
  3592. /**
  3593. * d component of the plane
  3594. */
  3595. d: number;
  3596. /**
  3597. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  3598. * @param a a component of the plane
  3599. * @param b b component of the plane
  3600. * @param c c component of the plane
  3601. * @param d d component of the plane
  3602. */
  3603. constructor(a: number, b: number, c: number, d: number);
  3604. /**
  3605. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  3606. */
  3607. asArray(): number[];
  3608. /**
  3609. * @returns a new plane copied from the current Plane.
  3610. */
  3611. clone(): Plane;
  3612. /**
  3613. * @returns the string "Plane".
  3614. */
  3615. getClassName(): string;
  3616. /**
  3617. * @returns the Plane hash code.
  3618. */
  3619. getHashCode(): number;
  3620. /**
  3621. * Normalize the current Plane in place.
  3622. * @returns the updated Plane.
  3623. */
  3624. normalize(): Plane;
  3625. /**
  3626. * Applies a transformation the plane and returns the result
  3627. * @param transformation the transformation matrix to be applied to the plane
  3628. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  3629. */
  3630. transform(transformation: DeepImmutable<Matrix>): Plane;
  3631. /**
  3632. * Calcualtte the dot product between the point and the plane normal
  3633. * @param point point to calculate the dot product with
  3634. * @returns the dot product (float) of the point coordinates and the plane normal.
  3635. */
  3636. dotCoordinate(point: DeepImmutable<Vector3>): number;
  3637. /**
  3638. * Updates the current Plane from the plane defined by the three given points.
  3639. * @param point1 one of the points used to contruct the plane
  3640. * @param point2 one of the points used to contruct the plane
  3641. * @param point3 one of the points used to contruct the plane
  3642. * @returns the updated Plane.
  3643. */
  3644. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  3645. /**
  3646. * Checks if the plane is facing a given direction
  3647. * @param direction the direction to check if the plane is facing
  3648. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  3649. * @returns True is the vector "direction" is the same side than the plane normal.
  3650. */
  3651. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  3652. /**
  3653. * Calculates the distance to a point
  3654. * @param point point to calculate distance to
  3655. * @returns the signed distance (float) from the given point to the Plane.
  3656. */
  3657. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  3658. /**
  3659. * Creates a plane from an array
  3660. * @param array the array to create a plane from
  3661. * @returns a new Plane from the given array.
  3662. */
  3663. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  3664. /**
  3665. * Creates a plane from three points
  3666. * @param point1 point used to create the plane
  3667. * @param point2 point used to create the plane
  3668. * @param point3 point used to create the plane
  3669. * @returns a new Plane defined by the three given points.
  3670. */
  3671. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  3672. /**
  3673. * Creates a plane from an origin point and a normal
  3674. * @param origin origin of the plane to be constructed
  3675. * @param normal normal of the plane to be constructed
  3676. * @returns a new Plane the normal vector to this plane at the given origin point.
  3677. * Note : the vector "normal" is updated because normalized.
  3678. */
  3679. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  3680. /**
  3681. * Calculates the distance from a plane and a point
  3682. * @param origin origin of the plane to be constructed
  3683. * @param normal normal of the plane to be constructed
  3684. * @param point point to calculate distance to
  3685. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  3686. */
  3687. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  3688. }
  3689. /**
  3690. * Class used to represent a viewport on screen
  3691. */
  3692. export class Viewport {
  3693. /** viewport left coordinate */
  3694. x: number;
  3695. /** viewport top coordinate */
  3696. y: number;
  3697. /**viewport width */
  3698. width: number;
  3699. /** viewport height */
  3700. height: number;
  3701. /**
  3702. * Creates a Viewport object located at (x, y) and sized (width, height)
  3703. * @param x defines viewport left coordinate
  3704. * @param y defines viewport top coordinate
  3705. * @param width defines the viewport width
  3706. * @param height defines the viewport height
  3707. */
  3708. constructor(
  3709. /** viewport left coordinate */
  3710. x: number,
  3711. /** viewport top coordinate */
  3712. y: number,
  3713. /**viewport width */
  3714. width: number,
  3715. /** viewport height */
  3716. height: number);
  3717. /**
  3718. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  3719. * @param renderWidth defines the rendering width
  3720. * @param renderHeight defines the rendering height
  3721. * @returns a new Viewport
  3722. */
  3723. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  3724. /**
  3725. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  3726. * @param renderWidth defines the rendering width
  3727. * @param renderHeight defines the rendering height
  3728. * @param ref defines the target viewport
  3729. * @returns the current viewport
  3730. */
  3731. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  3732. /**
  3733. * Returns a new Viewport copied from the current one
  3734. * @returns a new Viewport
  3735. */
  3736. clone(): Viewport;
  3737. }
  3738. /**
  3739. * Reprasents a camera frustum
  3740. */
  3741. export class Frustum {
  3742. /**
  3743. * Gets the planes representing the frustum
  3744. * @param transform matrix to be applied to the returned planes
  3745. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  3746. */
  3747. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  3748. /**
  3749. * Gets the near frustum plane transformed by the transform matrix
  3750. * @param transform transformation matrix to be applied to the resulting frustum plane
  3751. * @param frustumPlane the resuling frustum plane
  3752. */
  3753. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3754. /**
  3755. * Gets the far frustum plane transformed by the transform matrix
  3756. * @param transform transformation matrix to be applied to the resulting frustum plane
  3757. * @param frustumPlane the resuling frustum plane
  3758. */
  3759. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3760. /**
  3761. * Gets the left frustum plane transformed by the transform matrix
  3762. * @param transform transformation matrix to be applied to the resulting frustum plane
  3763. * @param frustumPlane the resuling frustum plane
  3764. */
  3765. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3766. /**
  3767. * Gets the right frustum plane transformed by the transform matrix
  3768. * @param transform transformation matrix to be applied to the resulting frustum plane
  3769. * @param frustumPlane the resuling frustum plane
  3770. */
  3771. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3772. /**
  3773. * Gets the top frustum plane transformed by the transform matrix
  3774. * @param transform transformation matrix to be applied to the resulting frustum plane
  3775. * @param frustumPlane the resuling frustum plane
  3776. */
  3777. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3778. /**
  3779. * Gets the bottom frustum plane transformed by the transform matrix
  3780. * @param transform transformation matrix to be applied to the resulting frustum plane
  3781. * @param frustumPlane the resuling frustum plane
  3782. */
  3783. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3784. /**
  3785. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  3786. * @param transform transformation matrix to be applied to the resulting frustum planes
  3787. * @param frustumPlanes the resuling frustum planes
  3788. */
  3789. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  3790. }
  3791. /** Defines supported spaces */
  3792. export enum Space {
  3793. /** Local (object) space */
  3794. LOCAL = 0,
  3795. /** World space */
  3796. WORLD = 1,
  3797. /** Bone space */
  3798. BONE = 2
  3799. }
  3800. /** Defines the 3 main axes */
  3801. export class Axis {
  3802. /** X axis */
  3803. static X: Vector3;
  3804. /** Y axis */
  3805. static Y: Vector3;
  3806. /** Z axis */
  3807. static Z: Vector3;
  3808. }
  3809. /** Class used to represent a Bezier curve */
  3810. export class BezierCurve {
  3811. /**
  3812. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  3813. * @param t defines the time
  3814. * @param x1 defines the left coordinate on X axis
  3815. * @param y1 defines the left coordinate on Y axis
  3816. * @param x2 defines the right coordinate on X axis
  3817. * @param y2 defines the right coordinate on Y axis
  3818. * @returns the interpolated value
  3819. */
  3820. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  3821. }
  3822. /**
  3823. * Defines potential orientation for back face culling
  3824. */
  3825. export enum Orientation {
  3826. /**
  3827. * Clockwise
  3828. */
  3829. CW = 0,
  3830. /** Counter clockwise */
  3831. CCW = 1
  3832. }
  3833. /**
  3834. * Defines angle representation
  3835. */
  3836. export class Angle {
  3837. private _radians;
  3838. /**
  3839. * Creates an Angle object of "radians" radians (float).
  3840. * @param radians the angle in radians
  3841. */
  3842. constructor(radians: number);
  3843. /**
  3844. * Get value in degrees
  3845. * @returns the Angle value in degrees (float)
  3846. */
  3847. degrees(): number;
  3848. /**
  3849. * Get value in radians
  3850. * @returns the Angle value in radians (float)
  3851. */
  3852. radians(): number;
  3853. /**
  3854. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  3855. * @param a defines first vector
  3856. * @param b defines second vector
  3857. * @returns a new Angle
  3858. */
  3859. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  3860. /**
  3861. * Gets a new Angle object from the given float in radians
  3862. * @param radians defines the angle value in radians
  3863. * @returns a new Angle
  3864. */
  3865. static FromRadians(radians: number): Angle;
  3866. /**
  3867. * Gets a new Angle object from the given float in degrees
  3868. * @param degrees defines the angle value in degrees
  3869. * @returns a new Angle
  3870. */
  3871. static FromDegrees(degrees: number): Angle;
  3872. }
  3873. /**
  3874. * This represents an arc in a 2d space.
  3875. */
  3876. export class Arc2 {
  3877. /** Defines the start point of the arc */
  3878. startPoint: Vector2;
  3879. /** Defines the mid point of the arc */
  3880. midPoint: Vector2;
  3881. /** Defines the end point of the arc */
  3882. endPoint: Vector2;
  3883. /**
  3884. * Defines the center point of the arc.
  3885. */
  3886. centerPoint: Vector2;
  3887. /**
  3888. * Defines the radius of the arc.
  3889. */
  3890. radius: number;
  3891. /**
  3892. * Defines the angle of the arc (from mid point to end point).
  3893. */
  3894. angle: Angle;
  3895. /**
  3896. * Defines the start angle of the arc (from start point to middle point).
  3897. */
  3898. startAngle: Angle;
  3899. /**
  3900. * Defines the orientation of the arc (clock wise/counter clock wise).
  3901. */
  3902. orientation: Orientation;
  3903. /**
  3904. * Creates an Arc object from the three given points : start, middle and end.
  3905. * @param startPoint Defines the start point of the arc
  3906. * @param midPoint Defines the midlle point of the arc
  3907. * @param endPoint Defines the end point of the arc
  3908. */
  3909. constructor(
  3910. /** Defines the start point of the arc */
  3911. startPoint: Vector2,
  3912. /** Defines the mid point of the arc */
  3913. midPoint: Vector2,
  3914. /** Defines the end point of the arc */
  3915. endPoint: Vector2);
  3916. }
  3917. /**
  3918. * Represents a 2D path made up of multiple 2D points
  3919. */
  3920. export class Path2 {
  3921. private _points;
  3922. private _length;
  3923. /**
  3924. * If the path start and end point are the same
  3925. */
  3926. closed: boolean;
  3927. /**
  3928. * Creates a Path2 object from the starting 2D coordinates x and y.
  3929. * @param x the starting points x value
  3930. * @param y the starting points y value
  3931. */
  3932. constructor(x: number, y: number);
  3933. /**
  3934. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  3935. * @param x the added points x value
  3936. * @param y the added points y value
  3937. * @returns the updated Path2.
  3938. */
  3939. addLineTo(x: number, y: number): Path2;
  3940. /**
  3941. * 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.
  3942. * @param midX middle point x value
  3943. * @param midY middle point y value
  3944. * @param endX end point x value
  3945. * @param endY end point y value
  3946. * @param numberOfSegments (default: 36)
  3947. * @returns the updated Path2.
  3948. */
  3949. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  3950. /**
  3951. * Closes the Path2.
  3952. * @returns the Path2.
  3953. */
  3954. close(): Path2;
  3955. /**
  3956. * Gets the sum of the distance between each sequential point in the path
  3957. * @returns the Path2 total length (float).
  3958. */
  3959. length(): number;
  3960. /**
  3961. * Gets the points which construct the path
  3962. * @returns the Path2 internal array of points.
  3963. */
  3964. getPoints(): Vector2[];
  3965. /**
  3966. * Retreives the point at the distance aways from the starting point
  3967. * @param normalizedLengthPosition the length along the path to retreive the point from
  3968. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  3969. */
  3970. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  3971. /**
  3972. * Creates a new path starting from an x and y position
  3973. * @param x starting x value
  3974. * @param y starting y value
  3975. * @returns a new Path2 starting at the coordinates (x, y).
  3976. */
  3977. static StartingAt(x: number, y: number): Path2;
  3978. }
  3979. /**
  3980. * Represents a 3D path made up of multiple 3D points
  3981. */
  3982. export class Path3D {
  3983. /**
  3984. * an array of Vector3, the curve axis of the Path3D
  3985. */
  3986. path: Vector3[];
  3987. private _curve;
  3988. private _distances;
  3989. private _tangents;
  3990. private _normals;
  3991. private _binormals;
  3992. private _raw;
  3993. /**
  3994. * new Path3D(path, normal, raw)
  3995. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  3996. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  3997. * @param path an array of Vector3, the curve axis of the Path3D
  3998. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  3999. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  4000. */
  4001. constructor(
  4002. /**
  4003. * an array of Vector3, the curve axis of the Path3D
  4004. */
  4005. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  4006. /**
  4007. * Returns the Path3D array of successive Vector3 designing its curve.
  4008. * @returns the Path3D array of successive Vector3 designing its curve.
  4009. */
  4010. getCurve(): Vector3[];
  4011. /**
  4012. * Returns an array populated with tangent vectors on each Path3D curve point.
  4013. * @returns an array populated with tangent vectors on each Path3D curve point.
  4014. */
  4015. getTangents(): Vector3[];
  4016. /**
  4017. * Returns an array populated with normal vectors on each Path3D curve point.
  4018. * @returns an array populated with normal vectors on each Path3D curve point.
  4019. */
  4020. getNormals(): Vector3[];
  4021. /**
  4022. * Returns an array populated with binormal vectors on each Path3D curve point.
  4023. * @returns an array populated with binormal vectors on each Path3D curve point.
  4024. */
  4025. getBinormals(): Vector3[];
  4026. /**
  4027. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  4028. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  4029. */
  4030. getDistances(): number[];
  4031. /**
  4032. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  4033. * @param path path which all values are copied into the curves points
  4034. * @param firstNormal which should be projected onto the curve
  4035. * @returns the same object updated.
  4036. */
  4037. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  4038. private _compute;
  4039. private _getFirstNonNullVector;
  4040. private _getLastNonNullVector;
  4041. private _normalVector;
  4042. }
  4043. /**
  4044. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4045. * A Curve3 is designed from a series of successive Vector3.
  4046. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  4047. */
  4048. export class Curve3 {
  4049. private _points;
  4050. private _length;
  4051. /**
  4052. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  4053. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  4054. * @param v1 (Vector3) the control point
  4055. * @param v2 (Vector3) the end point of the Quadratic Bezier
  4056. * @param nbPoints (integer) the wanted number of points in the curve
  4057. * @returns the created Curve3
  4058. */
  4059. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4060. /**
  4061. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  4062. * @param v0 (Vector3) the origin point of the Cubic Bezier
  4063. * @param v1 (Vector3) the first control point
  4064. * @param v2 (Vector3) the second control point
  4065. * @param v3 (Vector3) the end point of the Cubic Bezier
  4066. * @param nbPoints (integer) the wanted number of points in the curve
  4067. * @returns the created Curve3
  4068. */
  4069. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4070. /**
  4071. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  4072. * @param p1 (Vector3) the origin point of the Hermite Spline
  4073. * @param t1 (Vector3) the tangent vector at the origin point
  4074. * @param p2 (Vector3) the end point of the Hermite Spline
  4075. * @param t2 (Vector3) the tangent vector at the end point
  4076. * @param nbPoints (integer) the wanted number of points in the curve
  4077. * @returns the created Curve3
  4078. */
  4079. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4080. /**
  4081. * Returns a Curve3 object along a CatmullRom Spline curve :
  4082. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  4083. * @param nbPoints (integer) the wanted number of points between each curve control points
  4084. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  4085. * @returns the created Curve3
  4086. */
  4087. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  4088. /**
  4089. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4090. * A Curve3 is designed from a series of successive Vector3.
  4091. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  4092. * @param points points which make up the curve
  4093. */
  4094. constructor(points: Vector3[]);
  4095. /**
  4096. * @returns the Curve3 stored array of successive Vector3
  4097. */
  4098. getPoints(): Vector3[];
  4099. /**
  4100. * @returns the computed length (float) of the curve.
  4101. */
  4102. length(): number;
  4103. /**
  4104. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  4105. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  4106. * curveA and curveB keep unchanged.
  4107. * @param curve the curve to continue from this curve
  4108. * @returns the newly constructed curve
  4109. */
  4110. continue(curve: DeepImmutable<Curve3>): Curve3;
  4111. private _computeLength;
  4112. }
  4113. /**
  4114. * Contains position and normal vectors for a vertex
  4115. */
  4116. export class PositionNormalVertex {
  4117. /** the position of the vertex (defaut: 0,0,0) */
  4118. position: Vector3;
  4119. /** the normal of the vertex (defaut: 0,1,0) */
  4120. normal: Vector3;
  4121. /**
  4122. * Creates a PositionNormalVertex
  4123. * @param position the position of the vertex (defaut: 0,0,0)
  4124. * @param normal the normal of the vertex (defaut: 0,1,0)
  4125. */
  4126. constructor(
  4127. /** the position of the vertex (defaut: 0,0,0) */
  4128. position?: Vector3,
  4129. /** the normal of the vertex (defaut: 0,1,0) */
  4130. normal?: Vector3);
  4131. /**
  4132. * Clones the PositionNormalVertex
  4133. * @returns the cloned PositionNormalVertex
  4134. */
  4135. clone(): PositionNormalVertex;
  4136. }
  4137. /**
  4138. * Contains position, normal and uv vectors for a vertex
  4139. */
  4140. export class PositionNormalTextureVertex {
  4141. /** the position of the vertex (defaut: 0,0,0) */
  4142. position: Vector3;
  4143. /** the normal of the vertex (defaut: 0,1,0) */
  4144. normal: Vector3;
  4145. /** the uv of the vertex (default: 0,0) */
  4146. uv: Vector2;
  4147. /**
  4148. * Creates a PositionNormalTextureVertex
  4149. * @param position the position of the vertex (defaut: 0,0,0)
  4150. * @param normal the normal of the vertex (defaut: 0,1,0)
  4151. * @param uv the uv of the vertex (default: 0,0)
  4152. */
  4153. constructor(
  4154. /** the position of the vertex (defaut: 0,0,0) */
  4155. position?: Vector3,
  4156. /** the normal of the vertex (defaut: 0,1,0) */
  4157. normal?: Vector3,
  4158. /** the uv of the vertex (default: 0,0) */
  4159. uv?: Vector2);
  4160. /**
  4161. * Clones the PositionNormalTextureVertex
  4162. * @returns the cloned PositionNormalTextureVertex
  4163. */
  4164. clone(): PositionNormalTextureVertex;
  4165. }
  4166. /**
  4167. * @hidden
  4168. */
  4169. export class Tmp {
  4170. static Color3: Color3[];
  4171. static Color4: Color4[];
  4172. static Vector2: Vector2[];
  4173. static Vector3: Vector3[];
  4174. static Vector4: Vector4[];
  4175. static Quaternion: Quaternion[];
  4176. static Matrix: Matrix[];
  4177. }
  4178. }
  4179. declare module "babylonjs/Offline/IOfflineProvider" {
  4180. /**
  4181. * Class used to enable access to offline support
  4182. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  4183. */
  4184. export interface IOfflineProvider {
  4185. /**
  4186. * Gets a boolean indicating if scene must be saved in the database
  4187. */
  4188. enableSceneOffline: boolean;
  4189. /**
  4190. * Gets a boolean indicating if textures must be saved in the database
  4191. */
  4192. enableTexturesOffline: boolean;
  4193. /**
  4194. * Open the offline support and make it available
  4195. * @param successCallback defines the callback to call on success
  4196. * @param errorCallback defines the callback to call on error
  4197. */
  4198. open(successCallback: () => void, errorCallback: () => void): void;
  4199. /**
  4200. * Loads an image from the offline support
  4201. * @param url defines the url to load from
  4202. * @param image defines the target DOM image
  4203. */
  4204. loadImage(url: string, image: HTMLImageElement): void;
  4205. /**
  4206. * Loads a file from offline support
  4207. * @param url defines the URL to load from
  4208. * @param sceneLoaded defines a callback to call on success
  4209. * @param progressCallBack defines a callback to call when progress changed
  4210. * @param errorCallback defines a callback to call on error
  4211. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  4212. */
  4213. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  4214. }
  4215. }
  4216. declare module "babylonjs/Misc/observable" {
  4217. import { Nullable } from "babylonjs/types";
  4218. /**
  4219. * A class serves as a medium between the observable and its observers
  4220. */
  4221. export class EventState {
  4222. /**
  4223. * Create a new EventState
  4224. * @param mask defines the mask associated with this state
  4225. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  4226. * @param target defines the original target of the state
  4227. * @param currentTarget defines the current target of the state
  4228. */
  4229. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  4230. /**
  4231. * Initialize the current event state
  4232. * @param mask defines the mask associated with this state
  4233. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  4234. * @param target defines the original target of the state
  4235. * @param currentTarget defines the current target of the state
  4236. * @returns the current event state
  4237. */
  4238. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  4239. /**
  4240. * An Observer can set this property to true to prevent subsequent observers of being notified
  4241. */
  4242. skipNextObservers: boolean;
  4243. /**
  4244. * Get the mask value that were used to trigger the event corresponding to this EventState object
  4245. */
  4246. mask: number;
  4247. /**
  4248. * The object that originally notified the event
  4249. */
  4250. target?: any;
  4251. /**
  4252. * The current object in the bubbling phase
  4253. */
  4254. currentTarget?: any;
  4255. /**
  4256. * This will be populated with the return value of the last function that was executed.
  4257. * If it is the first function in the callback chain it will be the event data.
  4258. */
  4259. lastReturnValue?: any;
  4260. }
  4261. /**
  4262. * Represent an Observer registered to a given Observable object.
  4263. */
  4264. export class Observer<T> {
  4265. /**
  4266. * Defines the callback to call when the observer is notified
  4267. */
  4268. callback: (eventData: T, eventState: EventState) => void;
  4269. /**
  4270. * Defines the mask of the observer (used to filter notifications)
  4271. */
  4272. mask: number;
  4273. /**
  4274. * Defines the current scope used to restore the JS context
  4275. */
  4276. scope: any;
  4277. /** @hidden */
  4278. _willBeUnregistered: boolean;
  4279. /**
  4280. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  4281. */
  4282. unregisterOnNextCall: boolean;
  4283. /**
  4284. * Creates a new observer
  4285. * @param callback defines the callback to call when the observer is notified
  4286. * @param mask defines the mask of the observer (used to filter notifications)
  4287. * @param scope defines the current scope used to restore the JS context
  4288. */
  4289. constructor(
  4290. /**
  4291. * Defines the callback to call when the observer is notified
  4292. */
  4293. callback: (eventData: T, eventState: EventState) => void,
  4294. /**
  4295. * Defines the mask of the observer (used to filter notifications)
  4296. */
  4297. mask: number,
  4298. /**
  4299. * Defines the current scope used to restore the JS context
  4300. */
  4301. scope?: any);
  4302. }
  4303. /**
  4304. * Represent a list of observers registered to multiple Observables object.
  4305. */
  4306. export class MultiObserver<T> {
  4307. private _observers;
  4308. private _observables;
  4309. /**
  4310. * Release associated resources
  4311. */
  4312. dispose(): void;
  4313. /**
  4314. * Raise a callback when one of the observable will notify
  4315. * @param observables defines a list of observables to watch
  4316. * @param callback defines the callback to call on notification
  4317. * @param mask defines the mask used to filter notifications
  4318. * @param scope defines the current scope used to restore the JS context
  4319. * @returns the new MultiObserver
  4320. */
  4321. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  4322. }
  4323. /**
  4324. * The Observable class is a simple implementation of the Observable pattern.
  4325. *
  4326. * 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.
  4327. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  4328. * 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).
  4329. * 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.
  4330. */
  4331. export class Observable<T> {
  4332. private _observers;
  4333. private _eventState;
  4334. private _onObserverAdded;
  4335. /**
  4336. * Creates a new observable
  4337. * @param onObserverAdded defines a callback to call when a new observer is added
  4338. */
  4339. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  4340. /**
  4341. * Create a new Observer with the specified callback
  4342. * @param callback the callback that will be executed for that Observer
  4343. * @param mask the mask used to filter observers
  4344. * @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.
  4345. * @param scope optional scope for the callback to be called from
  4346. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  4347. * @returns the new observer created for the callback
  4348. */
  4349. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  4350. /**
  4351. * Create a new Observer with the specified callback and unregisters after the next notification
  4352. * @param callback the callback that will be executed for that Observer
  4353. * @returns the new observer created for the callback
  4354. */
  4355. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  4356. /**
  4357. * Remove an Observer from the Observable object
  4358. * @param observer the instance of the Observer to remove
  4359. * @returns false if it doesn't belong to this Observable
  4360. */
  4361. remove(observer: Nullable<Observer<T>>): boolean;
  4362. /**
  4363. * Remove a callback from the Observable object
  4364. * @param callback the callback to remove
  4365. * @param scope optional scope. If used only the callbacks with this scope will be removed
  4366. * @returns false if it doesn't belong to this Observable
  4367. */
  4368. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  4369. private _deferUnregister;
  4370. private _remove;
  4371. /**
  4372. * Moves the observable to the top of the observer list making it get called first when notified
  4373. * @param observer the observer to move
  4374. */
  4375. makeObserverTopPriority(observer: Observer<T>): void;
  4376. /**
  4377. * Moves the observable to the bottom of the observer list making it get called last when notified
  4378. * @param observer the observer to move
  4379. */
  4380. makeObserverBottomPriority(observer: Observer<T>): void;
  4381. /**
  4382. * Notify all Observers by calling their respective callback with the given data
  4383. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  4384. * @param eventData defines the data to send to all observers
  4385. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  4386. * @param target defines the original target of the state
  4387. * @param currentTarget defines the current target of the state
  4388. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  4389. */
  4390. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  4391. /**
  4392. * Calling this will execute each callback, expecting it to be a promise or return a value.
  4393. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  4394. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  4395. * and it is crucial that all callbacks will be executed.
  4396. * The order of the callbacks is kept, callbacks are not executed parallel.
  4397. *
  4398. * @param eventData The data to be sent to each callback
  4399. * @param mask is used to filter observers defaults to -1
  4400. * @param target defines the callback target (see EventState)
  4401. * @param currentTarget defines he current object in the bubbling phase
  4402. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  4403. */
  4404. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  4405. /**
  4406. * Notify a specific observer
  4407. * @param observer defines the observer to notify
  4408. * @param eventData defines the data to be sent to each callback
  4409. * @param mask is used to filter observers defaults to -1
  4410. */
  4411. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  4412. /**
  4413. * Gets a boolean indicating if the observable has at least one observer
  4414. * @returns true is the Observable has at least one Observer registered
  4415. */
  4416. hasObservers(): boolean;
  4417. /**
  4418. * Clear the list of observers
  4419. */
  4420. clear(): void;
  4421. /**
  4422. * Clone the current observable
  4423. * @returns a new observable
  4424. */
  4425. clone(): Observable<T>;
  4426. /**
  4427. * Does this observable handles observer registered with a given mask
  4428. * @param mask defines the mask to be tested
  4429. * @return whether or not one observer registered with the given mask is handeled
  4430. **/
  4431. hasSpecificMask(mask?: number): boolean;
  4432. }
  4433. }
  4434. declare module "babylonjs/Misc/filesInputStore" {
  4435. /**
  4436. * Class used to help managing file picking and drag'n'drop
  4437. * File Storage
  4438. */
  4439. export class FilesInputStore {
  4440. /**
  4441. * List of files ready to be loaded
  4442. */
  4443. static FilesToLoad: {
  4444. [key: string]: File;
  4445. };
  4446. }
  4447. }
  4448. declare module "babylonjs/Engines/constants" {
  4449. /** Defines the cross module used constants to avoid circular dependncies */
  4450. export class Constants {
  4451. /** Defines that alpha blending is disabled */
  4452. static readonly ALPHA_DISABLE: number;
  4453. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  4454. static readonly ALPHA_ADD: number;
  4455. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  4456. static readonly ALPHA_COMBINE: number;
  4457. /** Defines that alpha blending to DEST - SRC * DEST */
  4458. static readonly ALPHA_SUBTRACT: number;
  4459. /** Defines that alpha blending to SRC * DEST */
  4460. static readonly ALPHA_MULTIPLY: number;
  4461. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  4462. static readonly ALPHA_MAXIMIZED: number;
  4463. /** Defines that alpha blending to SRC + DEST */
  4464. static readonly ALPHA_ONEONE: number;
  4465. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  4466. static readonly ALPHA_PREMULTIPLIED: number;
  4467. /**
  4468. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  4469. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  4470. */
  4471. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  4472. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  4473. static readonly ALPHA_INTERPOLATE: number;
  4474. /**
  4475. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  4476. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  4477. */
  4478. static readonly ALPHA_SCREENMODE: number;
  4479. /** Defines that the ressource is not delayed*/
  4480. static readonly DELAYLOADSTATE_NONE: number;
  4481. /** Defines that the ressource was successfully delay loaded */
  4482. static readonly DELAYLOADSTATE_LOADED: number;
  4483. /** Defines that the ressource is currently delay loading */
  4484. static readonly DELAYLOADSTATE_LOADING: number;
  4485. /** Defines that the ressource is delayed and has not started loading */
  4486. static readonly DELAYLOADSTATE_NOTLOADED: number;
  4487. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  4488. static readonly NEVER: number;
  4489. /** 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 */
  4490. static readonly ALWAYS: number;
  4491. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  4492. static readonly LESS: number;
  4493. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  4494. static readonly EQUAL: number;
  4495. /** 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 */
  4496. static readonly LEQUAL: number;
  4497. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  4498. static readonly GREATER: number;
  4499. /** 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 */
  4500. static readonly GEQUAL: number;
  4501. /** 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 */
  4502. static readonly NOTEQUAL: number;
  4503. /** Passed to stencilOperation to specify that stencil value must be kept */
  4504. static readonly KEEP: number;
  4505. /** Passed to stencilOperation to specify that stencil value must be replaced */
  4506. static readonly REPLACE: number;
  4507. /** Passed to stencilOperation to specify that stencil value must be incremented */
  4508. static readonly INCR: number;
  4509. /** Passed to stencilOperation to specify that stencil value must be decremented */
  4510. static readonly DECR: number;
  4511. /** Passed to stencilOperation to specify that stencil value must be inverted */
  4512. static readonly INVERT: number;
  4513. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  4514. static readonly INCR_WRAP: number;
  4515. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  4516. static readonly DECR_WRAP: number;
  4517. /** Texture is not repeating outside of 0..1 UVs */
  4518. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  4519. /** Texture is repeating outside of 0..1 UVs */
  4520. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  4521. /** Texture is repeating and mirrored */
  4522. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  4523. /** ALPHA */
  4524. static readonly TEXTUREFORMAT_ALPHA: number;
  4525. /** LUMINANCE */
  4526. static readonly TEXTUREFORMAT_LUMINANCE: number;
  4527. /** LUMINANCE_ALPHA */
  4528. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  4529. /** RGB */
  4530. static readonly TEXTUREFORMAT_RGB: number;
  4531. /** RGBA */
  4532. static readonly TEXTUREFORMAT_RGBA: number;
  4533. /** RED */
  4534. static readonly TEXTUREFORMAT_RED: number;
  4535. /** RED (2nd reference) */
  4536. static readonly TEXTUREFORMAT_R: number;
  4537. /** RG */
  4538. static readonly TEXTUREFORMAT_RG: number;
  4539. /** RED_INTEGER */
  4540. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  4541. /** RED_INTEGER (2nd reference) */
  4542. static readonly TEXTUREFORMAT_R_INTEGER: number;
  4543. /** RG_INTEGER */
  4544. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  4545. /** RGB_INTEGER */
  4546. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  4547. /** RGBA_INTEGER */
  4548. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  4549. /** UNSIGNED_BYTE */
  4550. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  4551. /** UNSIGNED_BYTE (2nd reference) */
  4552. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  4553. /** FLOAT */
  4554. static readonly TEXTURETYPE_FLOAT: number;
  4555. /** HALF_FLOAT */
  4556. static readonly TEXTURETYPE_HALF_FLOAT: number;
  4557. /** BYTE */
  4558. static readonly TEXTURETYPE_BYTE: number;
  4559. /** SHORT */
  4560. static readonly TEXTURETYPE_SHORT: number;
  4561. /** UNSIGNED_SHORT */
  4562. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  4563. /** INT */
  4564. static readonly TEXTURETYPE_INT: number;
  4565. /** UNSIGNED_INT */
  4566. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  4567. /** UNSIGNED_SHORT_4_4_4_4 */
  4568. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  4569. /** UNSIGNED_SHORT_5_5_5_1 */
  4570. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  4571. /** UNSIGNED_SHORT_5_6_5 */
  4572. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  4573. /** UNSIGNED_INT_2_10_10_10_REV */
  4574. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  4575. /** UNSIGNED_INT_24_8 */
  4576. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  4577. /** UNSIGNED_INT_10F_11F_11F_REV */
  4578. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  4579. /** UNSIGNED_INT_5_9_9_9_REV */
  4580. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  4581. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  4582. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  4583. /** nearest is mag = nearest and min = nearest and mip = linear */
  4584. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  4585. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4586. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  4587. /** Trilinear is mag = linear and min = linear and mip = linear */
  4588. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  4589. /** nearest is mag = nearest and min = nearest and mip = linear */
  4590. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  4591. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4592. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  4593. /** Trilinear is mag = linear and min = linear and mip = linear */
  4594. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  4595. /** mag = nearest and min = nearest and mip = nearest */
  4596. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  4597. /** mag = nearest and min = linear and mip = nearest */
  4598. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  4599. /** mag = nearest and min = linear and mip = linear */
  4600. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  4601. /** mag = nearest and min = linear and mip = none */
  4602. static readonly TEXTURE_NEAREST_LINEAR: number;
  4603. /** mag = nearest and min = nearest and mip = none */
  4604. static readonly TEXTURE_NEAREST_NEAREST: number;
  4605. /** mag = linear and min = nearest and mip = nearest */
  4606. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  4607. /** mag = linear and min = nearest and mip = linear */
  4608. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  4609. /** mag = linear and min = linear and mip = none */
  4610. static readonly TEXTURE_LINEAR_LINEAR: number;
  4611. /** mag = linear and min = nearest and mip = none */
  4612. static readonly TEXTURE_LINEAR_NEAREST: number;
  4613. /** Explicit coordinates mode */
  4614. static readonly TEXTURE_EXPLICIT_MODE: number;
  4615. /** Spherical coordinates mode */
  4616. static readonly TEXTURE_SPHERICAL_MODE: number;
  4617. /** Planar coordinates mode */
  4618. static readonly TEXTURE_PLANAR_MODE: number;
  4619. /** Cubic coordinates mode */
  4620. static readonly TEXTURE_CUBIC_MODE: number;
  4621. /** Projection coordinates mode */
  4622. static readonly TEXTURE_PROJECTION_MODE: number;
  4623. /** Skybox coordinates mode */
  4624. static readonly TEXTURE_SKYBOX_MODE: number;
  4625. /** Inverse Cubic coordinates mode */
  4626. static readonly TEXTURE_INVCUBIC_MODE: number;
  4627. /** Equirectangular coordinates mode */
  4628. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  4629. /** Equirectangular Fixed coordinates mode */
  4630. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  4631. /** Equirectangular Fixed Mirrored coordinates mode */
  4632. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  4633. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  4634. static readonly SCALEMODE_FLOOR: number;
  4635. /** Defines that texture rescaling will look for the nearest power of 2 size */
  4636. static readonly SCALEMODE_NEAREST: number;
  4637. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  4638. static readonly SCALEMODE_CEILING: number;
  4639. /**
  4640. * The dirty texture flag value
  4641. */
  4642. static readonly MATERIAL_TextureDirtyFlag: number;
  4643. /**
  4644. * The dirty light flag value
  4645. */
  4646. static readonly MATERIAL_LightDirtyFlag: number;
  4647. /**
  4648. * The dirty fresnel flag value
  4649. */
  4650. static readonly MATERIAL_FresnelDirtyFlag: number;
  4651. /**
  4652. * The dirty attribute flag value
  4653. */
  4654. static readonly MATERIAL_AttributesDirtyFlag: number;
  4655. /**
  4656. * The dirty misc flag value
  4657. */
  4658. static readonly MATERIAL_MiscDirtyFlag: number;
  4659. /**
  4660. * The all dirty flag value
  4661. */
  4662. static readonly MATERIAL_AllDirtyFlag: number;
  4663. /**
  4664. * Returns the triangle fill mode
  4665. */
  4666. static readonly MATERIAL_TriangleFillMode: number;
  4667. /**
  4668. * Returns the wireframe mode
  4669. */
  4670. static readonly MATERIAL_WireFrameFillMode: number;
  4671. /**
  4672. * Returns the point fill mode
  4673. */
  4674. static readonly MATERIAL_PointFillMode: number;
  4675. /**
  4676. * Returns the point list draw mode
  4677. */
  4678. static readonly MATERIAL_PointListDrawMode: number;
  4679. /**
  4680. * Returns the line list draw mode
  4681. */
  4682. static readonly MATERIAL_LineListDrawMode: number;
  4683. /**
  4684. * Returns the line loop draw mode
  4685. */
  4686. static readonly MATERIAL_LineLoopDrawMode: number;
  4687. /**
  4688. * Returns the line strip draw mode
  4689. */
  4690. static readonly MATERIAL_LineStripDrawMode: number;
  4691. /**
  4692. * Returns the triangle strip draw mode
  4693. */
  4694. static readonly MATERIAL_TriangleStripDrawMode: number;
  4695. /**
  4696. * Returns the triangle fan draw mode
  4697. */
  4698. static readonly MATERIAL_TriangleFanDrawMode: number;
  4699. /**
  4700. * Stores the clock-wise side orientation
  4701. */
  4702. static readonly MATERIAL_ClockWiseSideOrientation: number;
  4703. /**
  4704. * Stores the counter clock-wise side orientation
  4705. */
  4706. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  4707. /**
  4708. * Nothing
  4709. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4710. */
  4711. static readonly ACTION_NothingTrigger: number;
  4712. /**
  4713. * On pick
  4714. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4715. */
  4716. static readonly ACTION_OnPickTrigger: number;
  4717. /**
  4718. * On left pick
  4719. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4720. */
  4721. static readonly ACTION_OnLeftPickTrigger: number;
  4722. /**
  4723. * On right pick
  4724. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4725. */
  4726. static readonly ACTION_OnRightPickTrigger: number;
  4727. /**
  4728. * On center pick
  4729. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4730. */
  4731. static readonly ACTION_OnCenterPickTrigger: number;
  4732. /**
  4733. * On pick down
  4734. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4735. */
  4736. static readonly ACTION_OnPickDownTrigger: number;
  4737. /**
  4738. * On double pick
  4739. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4740. */
  4741. static readonly ACTION_OnDoublePickTrigger: number;
  4742. /**
  4743. * On pick up
  4744. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4745. */
  4746. static readonly ACTION_OnPickUpTrigger: number;
  4747. /**
  4748. * On pick out.
  4749. * This trigger will only be raised if you also declared a OnPickDown
  4750. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4751. */
  4752. static readonly ACTION_OnPickOutTrigger: number;
  4753. /**
  4754. * On long press
  4755. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4756. */
  4757. static readonly ACTION_OnLongPressTrigger: number;
  4758. /**
  4759. * On pointer over
  4760. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4761. */
  4762. static readonly ACTION_OnPointerOverTrigger: number;
  4763. /**
  4764. * On pointer out
  4765. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4766. */
  4767. static readonly ACTION_OnPointerOutTrigger: number;
  4768. /**
  4769. * On every frame
  4770. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4771. */
  4772. static readonly ACTION_OnEveryFrameTrigger: number;
  4773. /**
  4774. * On intersection enter
  4775. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4776. */
  4777. static readonly ACTION_OnIntersectionEnterTrigger: number;
  4778. /**
  4779. * On intersection exit
  4780. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4781. */
  4782. static readonly ACTION_OnIntersectionExitTrigger: number;
  4783. /**
  4784. * On key down
  4785. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4786. */
  4787. static readonly ACTION_OnKeyDownTrigger: number;
  4788. /**
  4789. * On key up
  4790. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4791. */
  4792. static readonly ACTION_OnKeyUpTrigger: number;
  4793. /**
  4794. * Billboard mode will only apply to Y axis
  4795. */
  4796. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  4797. /**
  4798. * Billboard mode will apply to all axes
  4799. */
  4800. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  4801. /**
  4802. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  4803. */
  4804. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  4805. /**
  4806. * Gets or sets base Assets URL
  4807. */
  4808. static readonly PARTICLES_BaseAssetsUrl: string;
  4809. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  4810. * Test order :
  4811. * Is the bounding sphere outside the frustum ?
  4812. * If not, are the bounding box vertices outside the frustum ?
  4813. * It not, then the cullable object is in the frustum.
  4814. */
  4815. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  4816. /** Culling strategy : Bounding Sphere Only.
  4817. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  4818. * It's also less accurate than the standard because some not visible objects can still be selected.
  4819. * Test : is the bounding sphere outside the frustum ?
  4820. * If not, then the cullable object is in the frustum.
  4821. */
  4822. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  4823. /** Culling strategy : Optimistic Inclusion.
  4824. * This in an inclusion test first, then the standard exclusion test.
  4825. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  4826. * 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.
  4827. * Anyway, it's as accurate as the standard strategy.
  4828. * Test :
  4829. * Is the cullable object bounding sphere center in the frustum ?
  4830. * If not, apply the default culling strategy.
  4831. */
  4832. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  4833. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  4834. * This in an inclusion test first, then the bounding sphere only exclusion test.
  4835. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  4836. * 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.
  4837. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  4838. * Test :
  4839. * Is the cullable object bounding sphere center in the frustum ?
  4840. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  4841. */
  4842. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  4843. /**
  4844. * No logging while loading
  4845. */
  4846. static readonly SCENELOADER_NO_LOGGING: number;
  4847. /**
  4848. * Minimal logging while loading
  4849. */
  4850. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  4851. /**
  4852. * Summary logging while loading
  4853. */
  4854. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  4855. /**
  4856. * Detailled logging while loading
  4857. */
  4858. static readonly SCENELOADER_DETAILED_LOGGING: number;
  4859. }
  4860. }
  4861. declare module "babylonjs/Misc/domManagement" {
  4862. /**
  4863. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  4864. * Babylon.js
  4865. */
  4866. export class DomManagement {
  4867. /**
  4868. * Checks if the window object exists
  4869. * @returns true if the window object exists
  4870. */
  4871. static IsWindowObjectExist(): boolean;
  4872. /**
  4873. * Extracts text content from a DOM element hierarchy
  4874. * @param element defines the root element
  4875. * @returns a string
  4876. */
  4877. static GetDOMTextContent(element: HTMLElement): string;
  4878. }
  4879. }
  4880. declare module "babylonjs/Misc/logger" {
  4881. /**
  4882. * Logger used througouht the application to allow configuration of
  4883. * the log level required for the messages.
  4884. */
  4885. export class Logger {
  4886. /**
  4887. * No log
  4888. */
  4889. static readonly NoneLogLevel: number;
  4890. /**
  4891. * Only message logs
  4892. */
  4893. static readonly MessageLogLevel: number;
  4894. /**
  4895. * Only warning logs
  4896. */
  4897. static readonly WarningLogLevel: number;
  4898. /**
  4899. * Only error logs
  4900. */
  4901. static readonly ErrorLogLevel: number;
  4902. /**
  4903. * All logs
  4904. */
  4905. static readonly AllLogLevel: number;
  4906. private static _LogCache;
  4907. /**
  4908. * Gets a value indicating the number of loading errors
  4909. * @ignorenaming
  4910. */
  4911. static errorsCount: number;
  4912. /**
  4913. * Callback called when a new log is added
  4914. */
  4915. static OnNewCacheEntry: (entry: string) => void;
  4916. private static _AddLogEntry;
  4917. private static _FormatMessage;
  4918. private static _LogDisabled;
  4919. private static _LogEnabled;
  4920. private static _WarnDisabled;
  4921. private static _WarnEnabled;
  4922. private static _ErrorDisabled;
  4923. private static _ErrorEnabled;
  4924. /**
  4925. * Log a message to the console
  4926. */
  4927. static Log: (message: string) => void;
  4928. /**
  4929. * Write a warning message to the console
  4930. */
  4931. static Warn: (message: string) => void;
  4932. /**
  4933. * Write an error message to the console
  4934. */
  4935. static Error: (message: string) => void;
  4936. /**
  4937. * Gets current log cache (list of logs)
  4938. */
  4939. static readonly LogCache: string;
  4940. /**
  4941. * Clears the log cache
  4942. */
  4943. static ClearLogCache(): void;
  4944. /**
  4945. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  4946. */
  4947. static LogLevels: number;
  4948. }
  4949. }
  4950. declare module "babylonjs/Misc/typeStore" {
  4951. /** @hidden */
  4952. export class _TypeStore {
  4953. /** @hidden */
  4954. static RegisteredTypes: {
  4955. [key: string]: Object;
  4956. };
  4957. /** @hidden */
  4958. static GetClass(fqdn: string): any;
  4959. }
  4960. }
  4961. declare module "babylonjs/Misc/deepCopier" {
  4962. /**
  4963. * Class containing a set of static utilities functions for deep copy.
  4964. */
  4965. export class DeepCopier {
  4966. /**
  4967. * Tries to copy an object by duplicating every property
  4968. * @param source defines the source object
  4969. * @param destination defines the target object
  4970. * @param doNotCopyList defines a list of properties to avoid
  4971. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  4972. */
  4973. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  4974. }
  4975. }
  4976. declare module "babylonjs/Misc/precisionDate" {
  4977. /**
  4978. * Class containing a set of static utilities functions for precision date
  4979. */
  4980. export class PrecisionDate {
  4981. /**
  4982. * Gets either window.performance.now() if supported or Date.now() else
  4983. */
  4984. static readonly Now: number;
  4985. }
  4986. }
  4987. declare module "babylonjs/Misc/devTools" {
  4988. /** @hidden */
  4989. export class _DevTools {
  4990. static WarnImport(name: string): string;
  4991. }
  4992. }
  4993. declare module "babylonjs/Misc/webRequest" {
  4994. /**
  4995. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  4996. */
  4997. export class WebRequest {
  4998. private _xhr;
  4999. /**
  5000. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  5001. * i.e. when loading files, where the server/service expects an Authorization header
  5002. */
  5003. static CustomRequestHeaders: {
  5004. [key: string]: string;
  5005. };
  5006. /**
  5007. * Add callback functions in this array to update all the requests before they get sent to the network
  5008. */
  5009. static CustomRequestModifiers: ((request: XMLHttpRequest) => void)[];
  5010. private _injectCustomRequestHeaders;
  5011. /**
  5012. * Gets or sets a function to be called when loading progress changes
  5013. */
  5014. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  5015. /**
  5016. * Returns client's state
  5017. */
  5018. readonly readyState: number;
  5019. /**
  5020. * Returns client's status
  5021. */
  5022. readonly status: number;
  5023. /**
  5024. * Returns client's status as a text
  5025. */
  5026. readonly statusText: string;
  5027. /**
  5028. * Returns client's response
  5029. */
  5030. readonly response: any;
  5031. /**
  5032. * Returns client's response url
  5033. */
  5034. readonly responseURL: string;
  5035. /**
  5036. * Returns client's response as text
  5037. */
  5038. readonly responseText: string;
  5039. /**
  5040. * Gets or sets the expected response type
  5041. */
  5042. responseType: XMLHttpRequestResponseType;
  5043. /** @hidden */
  5044. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  5045. /** @hidden */
  5046. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  5047. /**
  5048. * Cancels any network activity
  5049. */
  5050. abort(): void;
  5051. /**
  5052. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  5053. * @param body defines an optional request body
  5054. */
  5055. send(body?: Document | BodyInit | null): void;
  5056. /**
  5057. * Sets the request method, request URL
  5058. * @param method defines the method to use (GET, POST, etc..)
  5059. * @param url defines the url to connect with
  5060. */
  5061. open(method: string, url: string): void;
  5062. }
  5063. }
  5064. declare module "babylonjs/Misc/andOrNotEvaluator" {
  5065. /**
  5066. * Class used to evalaute queries containing `and` and `or` operators
  5067. */
  5068. export class AndOrNotEvaluator {
  5069. /**
  5070. * Evaluate a query
  5071. * @param query defines the query to evaluate
  5072. * @param evaluateCallback defines the callback used to filter result
  5073. * @returns true if the query matches
  5074. */
  5075. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  5076. private static _HandleParenthesisContent;
  5077. private static _SimplifyNegation;
  5078. }
  5079. }
  5080. declare module "babylonjs/Misc/tags" {
  5081. /**
  5082. * Class used to store custom tags
  5083. */
  5084. export class Tags {
  5085. /**
  5086. * Adds support for tags on the given object
  5087. * @param obj defines the object to use
  5088. */
  5089. static EnableFor(obj: any): void;
  5090. /**
  5091. * Removes tags support
  5092. * @param obj defines the object to use
  5093. */
  5094. static DisableFor(obj: any): void;
  5095. /**
  5096. * Gets a boolean indicating if the given object has tags
  5097. * @param obj defines the object to use
  5098. * @returns a boolean
  5099. */
  5100. static HasTags(obj: any): boolean;
  5101. /**
  5102. * Gets the tags available on a given object
  5103. * @param obj defines the object to use
  5104. * @param asString defines if the tags must be returned as a string instead of an array of strings
  5105. * @returns the tags
  5106. */
  5107. static GetTags(obj: any, asString?: boolean): any;
  5108. /**
  5109. * Adds tags to an object
  5110. * @param obj defines the object to use
  5111. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  5112. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  5113. */
  5114. static AddTagsTo(obj: any, tagsString: string): void;
  5115. /**
  5116. * @hidden
  5117. */
  5118. static _AddTagTo(obj: any, tag: string): void;
  5119. /**
  5120. * Removes specific tags from a specific object
  5121. * @param obj defines the object to use
  5122. * @param tagsString defines the tags to remove
  5123. */
  5124. static RemoveTagsFrom(obj: any, tagsString: string): void;
  5125. /**
  5126. * @hidden
  5127. */
  5128. static _RemoveTagFrom(obj: any, tag: string): void;
  5129. /**
  5130. * Defines if tags hosted on an object match a given query
  5131. * @param obj defines the object to use
  5132. * @param tagsQuery defines the tag query
  5133. * @returns a boolean
  5134. */
  5135. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  5136. }
  5137. }
  5138. declare module "babylonjs/Materials/materialDefines" {
  5139. /**
  5140. * Manages the defines for the Material
  5141. */
  5142. export class MaterialDefines {
  5143. private _keys;
  5144. private _isDirty;
  5145. /** @hidden */
  5146. _renderId: number;
  5147. /** @hidden */
  5148. _areLightsDirty: boolean;
  5149. /** @hidden */
  5150. _areAttributesDirty: boolean;
  5151. /** @hidden */
  5152. _areTexturesDirty: boolean;
  5153. /** @hidden */
  5154. _areFresnelDirty: boolean;
  5155. /** @hidden */
  5156. _areMiscDirty: boolean;
  5157. /** @hidden */
  5158. _areImageProcessingDirty: boolean;
  5159. /** @hidden */
  5160. _normals: boolean;
  5161. /** @hidden */
  5162. _uvs: boolean;
  5163. /** @hidden */
  5164. _needNormals: boolean;
  5165. /** @hidden */
  5166. _needUVs: boolean;
  5167. /**
  5168. * Specifies if the material needs to be re-calculated
  5169. */
  5170. readonly isDirty: boolean;
  5171. /**
  5172. * Marks the material to indicate that it has been re-calculated
  5173. */
  5174. markAsProcessed(): void;
  5175. /**
  5176. * Marks the material to indicate that it needs to be re-calculated
  5177. */
  5178. markAsUnprocessed(): void;
  5179. /**
  5180. * Marks the material to indicate all of its defines need to be re-calculated
  5181. */
  5182. markAllAsDirty(): void;
  5183. /**
  5184. * Marks the material to indicate that image processing needs to be re-calculated
  5185. */
  5186. markAsImageProcessingDirty(): void;
  5187. /**
  5188. * Marks the material to indicate the lights need to be re-calculated
  5189. */
  5190. markAsLightDirty(): void;
  5191. /**
  5192. * Marks the attribute state as changed
  5193. */
  5194. markAsAttributesDirty(): void;
  5195. /**
  5196. * Marks the texture state as changed
  5197. */
  5198. markAsTexturesDirty(): void;
  5199. /**
  5200. * Marks the fresnel state as changed
  5201. */
  5202. markAsFresnelDirty(): void;
  5203. /**
  5204. * Marks the misc state as changed
  5205. */
  5206. markAsMiscDirty(): void;
  5207. /**
  5208. * Rebuilds the material defines
  5209. */
  5210. rebuild(): void;
  5211. /**
  5212. * Specifies if two material defines are equal
  5213. * @param other - A material define instance to compare to
  5214. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  5215. */
  5216. isEqual(other: MaterialDefines): boolean;
  5217. /**
  5218. * Clones this instance's defines to another instance
  5219. * @param other - material defines to clone values to
  5220. */
  5221. cloneTo(other: MaterialDefines): void;
  5222. /**
  5223. * Resets the material define values
  5224. */
  5225. reset(): void;
  5226. /**
  5227. * Converts the material define values to a string
  5228. * @returns - String of material define information
  5229. */
  5230. toString(): string;
  5231. }
  5232. }
  5233. declare module "babylonjs/Misc/performanceMonitor" {
  5234. /**
  5235. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  5236. */
  5237. export class PerformanceMonitor {
  5238. private _enabled;
  5239. private _rollingFrameTime;
  5240. private _lastFrameTimeMs;
  5241. /**
  5242. * constructor
  5243. * @param frameSampleSize The number of samples required to saturate the sliding window
  5244. */
  5245. constructor(frameSampleSize?: number);
  5246. /**
  5247. * Samples current frame
  5248. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  5249. */
  5250. sampleFrame(timeMs?: number): void;
  5251. /**
  5252. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  5253. */
  5254. readonly averageFrameTime: number;
  5255. /**
  5256. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  5257. */
  5258. readonly averageFrameTimeVariance: number;
  5259. /**
  5260. * Returns the frame time of the most recent frame
  5261. */
  5262. readonly instantaneousFrameTime: number;
  5263. /**
  5264. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  5265. */
  5266. readonly averageFPS: number;
  5267. /**
  5268. * Returns the average framerate in frames per second using the most recent frame time
  5269. */
  5270. readonly instantaneousFPS: number;
  5271. /**
  5272. * Returns true if enough samples have been taken to completely fill the sliding window
  5273. */
  5274. readonly isSaturated: boolean;
  5275. /**
  5276. * Enables contributions to the sliding window sample set
  5277. */
  5278. enable(): void;
  5279. /**
  5280. * Disables contributions to the sliding window sample set
  5281. * Samples will not be interpolated over the disabled period
  5282. */
  5283. disable(): void;
  5284. /**
  5285. * Returns true if sampling is enabled
  5286. */
  5287. readonly isEnabled: boolean;
  5288. /**
  5289. * Resets performance monitor
  5290. */
  5291. reset(): void;
  5292. }
  5293. /**
  5294. * RollingAverage
  5295. *
  5296. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  5297. */
  5298. export class RollingAverage {
  5299. /**
  5300. * Current average
  5301. */
  5302. average: number;
  5303. /**
  5304. * Current variance
  5305. */
  5306. variance: number;
  5307. protected _samples: Array<number>;
  5308. protected _sampleCount: number;
  5309. protected _pos: number;
  5310. protected _m2: number;
  5311. /**
  5312. * constructor
  5313. * @param length The number of samples required to saturate the sliding window
  5314. */
  5315. constructor(length: number);
  5316. /**
  5317. * Adds a sample to the sample set
  5318. * @param v The sample value
  5319. */
  5320. add(v: number): void;
  5321. /**
  5322. * Returns previously added values or null if outside of history or outside the sliding window domain
  5323. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  5324. * @return Value previously recorded with add() or null if outside of range
  5325. */
  5326. history(i: number): number;
  5327. /**
  5328. * Returns true if enough samples have been taken to completely fill the sliding window
  5329. * @return true if sample-set saturated
  5330. */
  5331. isSaturated(): boolean;
  5332. /**
  5333. * Resets the rolling average (equivalent to 0 samples taken so far)
  5334. */
  5335. reset(): void;
  5336. /**
  5337. * Wraps a value around the sample range boundaries
  5338. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  5339. * @return Wrapped position in sample range
  5340. */
  5341. protected _wrapPosition(i: number): number;
  5342. }
  5343. }
  5344. declare module "babylonjs/Misc/stringDictionary" {
  5345. import { Nullable } from "babylonjs/types";
  5346. /**
  5347. * This class implement a typical dictionary using a string as key and the generic type T as value.
  5348. * The underlying implementation relies on an associative array to ensure the best performances.
  5349. * The value can be anything including 'null' but except 'undefined'
  5350. */
  5351. export class StringDictionary<T> {
  5352. /**
  5353. * This will clear this dictionary and copy the content from the 'source' one.
  5354. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  5355. * @param source the dictionary to take the content from and copy to this dictionary
  5356. */
  5357. copyFrom(source: StringDictionary<T>): void;
  5358. /**
  5359. * Get a value based from its key
  5360. * @param key the given key to get the matching value from
  5361. * @return the value if found, otherwise undefined is returned
  5362. */
  5363. get(key: string): T | undefined;
  5364. /**
  5365. * Get a value from its key or add it if it doesn't exist.
  5366. * This method will ensure you that a given key/data will be present in the dictionary.
  5367. * @param key the given key to get the matching value from
  5368. * @param factory the factory that will create the value if the key is not present in the dictionary.
  5369. * The factory will only be invoked if there's no data for the given key.
  5370. * @return the value corresponding to the key.
  5371. */
  5372. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  5373. /**
  5374. * Get a value from its key if present in the dictionary otherwise add it
  5375. * @param key the key to get the value from
  5376. * @param val if there's no such key/value pair in the dictionary add it with this value
  5377. * @return the value corresponding to the key
  5378. */
  5379. getOrAdd(key: string, val: T): T;
  5380. /**
  5381. * Check if there's a given key in the dictionary
  5382. * @param key the key to check for
  5383. * @return true if the key is present, false otherwise
  5384. */
  5385. contains(key: string): boolean;
  5386. /**
  5387. * Add a new key and its corresponding value
  5388. * @param key the key to add
  5389. * @param value the value corresponding to the key
  5390. * @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
  5391. */
  5392. add(key: string, value: T): boolean;
  5393. /**
  5394. * Update a specific value associated to a key
  5395. * @param key defines the key to use
  5396. * @param value defines the value to store
  5397. * @returns true if the value was updated (or false if the key was not found)
  5398. */
  5399. set(key: string, value: T): boolean;
  5400. /**
  5401. * Get the element of the given key and remove it from the dictionary
  5402. * @param key defines the key to search
  5403. * @returns the value associated with the key or null if not found
  5404. */
  5405. getAndRemove(key: string): Nullable<T>;
  5406. /**
  5407. * Remove a key/value from the dictionary.
  5408. * @param key the key to remove
  5409. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  5410. */
  5411. remove(key: string): boolean;
  5412. /**
  5413. * Clear the whole content of the dictionary
  5414. */
  5415. clear(): void;
  5416. /**
  5417. * Gets the current count
  5418. */
  5419. readonly count: number;
  5420. /**
  5421. * Execute a callback on each key/val of the dictionary.
  5422. * Note that you can remove any element in this dictionary in the callback implementation
  5423. * @param callback the callback to execute on a given key/value pair
  5424. */
  5425. forEach(callback: (key: string, val: T) => void): void;
  5426. /**
  5427. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  5428. * If the callback returns null or undefined the method will iterate to the next key/value pair
  5429. * Note that you can remove any element in this dictionary in the callback implementation
  5430. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  5431. * @returns the first item
  5432. */
  5433. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  5434. private _count;
  5435. private _data;
  5436. }
  5437. }
  5438. declare module "babylonjs/Misc/promise" {
  5439. /**
  5440. * Helper class that provides a small promise polyfill
  5441. */
  5442. export class PromisePolyfill {
  5443. /**
  5444. * Static function used to check if the polyfill is required
  5445. * If this is the case then the function will inject the polyfill to window.Promise
  5446. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  5447. */
  5448. static Apply(force?: boolean): void;
  5449. }
  5450. }
  5451. declare module "babylonjs/Meshes/buffer" {
  5452. import { Nullable, DataArray } from "babylonjs/types";
  5453. /**
  5454. * Class used to store data that will be store in GPU memory
  5455. */
  5456. export class Buffer {
  5457. private _engine;
  5458. private _buffer;
  5459. /** @hidden */
  5460. _data: Nullable<DataArray>;
  5461. private _updatable;
  5462. private _instanced;
  5463. /**
  5464. * Gets the byte stride.
  5465. */
  5466. readonly byteStride: number;
  5467. /**
  5468. * Constructor
  5469. * @param engine the engine
  5470. * @param data the data to use for this buffer
  5471. * @param updatable whether the data is updatable
  5472. * @param stride the stride (optional)
  5473. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  5474. * @param instanced whether the buffer is instanced (optional)
  5475. * @param useBytes set to true if the stride in in bytes (optional)
  5476. */
  5477. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  5478. /**
  5479. * Create a new VertexBuffer based on the current buffer
  5480. * @param kind defines the vertex buffer kind (position, normal, etc.)
  5481. * @param offset defines offset in the buffer (0 by default)
  5482. * @param size defines the size in floats of attributes (position is 3 for instance)
  5483. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  5484. * @param instanced defines if the vertex buffer contains indexed data
  5485. * @param useBytes defines if the offset and stride are in bytes
  5486. * @returns the new vertex buffer
  5487. */
  5488. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  5489. /**
  5490. * Gets a boolean indicating if the Buffer is updatable?
  5491. * @returns true if the buffer is updatable
  5492. */
  5493. isUpdatable(): boolean;
  5494. /**
  5495. * Gets current buffer's data
  5496. * @returns a DataArray or null
  5497. */
  5498. getData(): Nullable<DataArray>;
  5499. /**
  5500. * Gets underlying native buffer
  5501. * @returns underlying native buffer
  5502. */
  5503. getBuffer(): Nullable<WebGLBuffer>;
  5504. /**
  5505. * Gets the stride in float32 units (i.e. byte stride / 4).
  5506. * May not be an integer if the byte stride is not divisible by 4.
  5507. * DEPRECATED. Use byteStride instead.
  5508. * @returns the stride in float32 units
  5509. */
  5510. getStrideSize(): number;
  5511. /**
  5512. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  5513. * @param data defines the data to store
  5514. */
  5515. create(data?: Nullable<DataArray>): void;
  5516. /** @hidden */
  5517. _rebuild(): void;
  5518. /**
  5519. * Update current buffer data
  5520. * @param data defines the data to store
  5521. */
  5522. update(data: DataArray): void;
  5523. /**
  5524. * Updates the data directly.
  5525. * @param data the new data
  5526. * @param offset the new offset
  5527. * @param vertexCount the vertex count (optional)
  5528. * @param useBytes set to true if the offset is in bytes
  5529. */
  5530. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  5531. /**
  5532. * Release all resources
  5533. */
  5534. dispose(): void;
  5535. }
  5536. /**
  5537. * Specialized buffer used to store vertex data
  5538. */
  5539. export class VertexBuffer {
  5540. /** @hidden */
  5541. _buffer: Buffer;
  5542. private _kind;
  5543. private _size;
  5544. private _ownsBuffer;
  5545. private _instanced;
  5546. private _instanceDivisor;
  5547. /**
  5548. * The byte type.
  5549. */
  5550. static readonly BYTE: number;
  5551. /**
  5552. * The unsigned byte type.
  5553. */
  5554. static readonly UNSIGNED_BYTE: number;
  5555. /**
  5556. * The short type.
  5557. */
  5558. static readonly SHORT: number;
  5559. /**
  5560. * The unsigned short type.
  5561. */
  5562. static readonly UNSIGNED_SHORT: number;
  5563. /**
  5564. * The integer type.
  5565. */
  5566. static readonly INT: number;
  5567. /**
  5568. * The unsigned integer type.
  5569. */
  5570. static readonly UNSIGNED_INT: number;
  5571. /**
  5572. * The float type.
  5573. */
  5574. static readonly FLOAT: number;
  5575. /**
  5576. * Gets or sets the instance divisor when in instanced mode
  5577. */
  5578. instanceDivisor: number;
  5579. /**
  5580. * Gets the byte stride.
  5581. */
  5582. readonly byteStride: number;
  5583. /**
  5584. * Gets the byte offset.
  5585. */
  5586. readonly byteOffset: number;
  5587. /**
  5588. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  5589. */
  5590. readonly normalized: boolean;
  5591. /**
  5592. * Gets the data type of each component in the array.
  5593. */
  5594. readonly type: number;
  5595. /**
  5596. * Constructor
  5597. * @param engine the engine
  5598. * @param data the data to use for this vertex buffer
  5599. * @param kind the vertex buffer kind
  5600. * @param updatable whether the data is updatable
  5601. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  5602. * @param stride the stride (optional)
  5603. * @param instanced whether the buffer is instanced (optional)
  5604. * @param offset the offset of the data (optional)
  5605. * @param size the number of components (optional)
  5606. * @param type the type of the component (optional)
  5607. * @param normalized whether the data contains normalized data (optional)
  5608. * @param useBytes set to true if stride and offset are in bytes (optional)
  5609. */
  5610. 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);
  5611. /** @hidden */
  5612. _rebuild(): void;
  5613. /**
  5614. * Returns the kind of the VertexBuffer (string)
  5615. * @returns a string
  5616. */
  5617. getKind(): string;
  5618. /**
  5619. * Gets a boolean indicating if the VertexBuffer is updatable?
  5620. * @returns true if the buffer is updatable
  5621. */
  5622. isUpdatable(): boolean;
  5623. /**
  5624. * Gets current buffer's data
  5625. * @returns a DataArray or null
  5626. */
  5627. getData(): Nullable<DataArray>;
  5628. /**
  5629. * Gets underlying native buffer
  5630. * @returns underlying native buffer
  5631. */
  5632. getBuffer(): Nullable<WebGLBuffer>;
  5633. /**
  5634. * Gets the stride in float32 units (i.e. byte stride / 4).
  5635. * May not be an integer if the byte stride is not divisible by 4.
  5636. * DEPRECATED. Use byteStride instead.
  5637. * @returns the stride in float32 units
  5638. */
  5639. getStrideSize(): number;
  5640. /**
  5641. * Returns the offset as a multiple of the type byte length.
  5642. * DEPRECATED. Use byteOffset instead.
  5643. * @returns the offset in bytes
  5644. */
  5645. getOffset(): number;
  5646. /**
  5647. * Returns the number of components per vertex attribute (integer)
  5648. * @returns the size in float
  5649. */
  5650. getSize(): number;
  5651. /**
  5652. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  5653. * @returns true if this buffer is instanced
  5654. */
  5655. getIsInstanced(): boolean;
  5656. /**
  5657. * Returns the instancing divisor, zero for non-instanced (integer).
  5658. * @returns a number
  5659. */
  5660. getInstanceDivisor(): number;
  5661. /**
  5662. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  5663. * @param data defines the data to store
  5664. */
  5665. create(data?: DataArray): void;
  5666. /**
  5667. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  5668. * This function will create a new buffer if the current one is not updatable
  5669. * @param data defines the data to store
  5670. */
  5671. update(data: DataArray): void;
  5672. /**
  5673. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  5674. * Returns the directly updated WebGLBuffer.
  5675. * @param data the new data
  5676. * @param offset the new offset
  5677. * @param useBytes set to true if the offset is in bytes
  5678. */
  5679. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  5680. /**
  5681. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  5682. */
  5683. dispose(): void;
  5684. /**
  5685. * Enumerates each value of this vertex buffer as numbers.
  5686. * @param count the number of values to enumerate
  5687. * @param callback the callback function called for each value
  5688. */
  5689. forEach(count: number, callback: (value: number, index: number) => void): void;
  5690. /**
  5691. * Positions
  5692. */
  5693. static readonly PositionKind: string;
  5694. /**
  5695. * Normals
  5696. */
  5697. static readonly NormalKind: string;
  5698. /**
  5699. * Tangents
  5700. */
  5701. static readonly TangentKind: string;
  5702. /**
  5703. * Texture coordinates
  5704. */
  5705. static readonly UVKind: string;
  5706. /**
  5707. * Texture coordinates 2
  5708. */
  5709. static readonly UV2Kind: string;
  5710. /**
  5711. * Texture coordinates 3
  5712. */
  5713. static readonly UV3Kind: string;
  5714. /**
  5715. * Texture coordinates 4
  5716. */
  5717. static readonly UV4Kind: string;
  5718. /**
  5719. * Texture coordinates 5
  5720. */
  5721. static readonly UV5Kind: string;
  5722. /**
  5723. * Texture coordinates 6
  5724. */
  5725. static readonly UV6Kind: string;
  5726. /**
  5727. * Colors
  5728. */
  5729. static readonly ColorKind: string;
  5730. /**
  5731. * Matrix indices (for bones)
  5732. */
  5733. static readonly MatricesIndicesKind: string;
  5734. /**
  5735. * Matrix weights (for bones)
  5736. */
  5737. static readonly MatricesWeightsKind: string;
  5738. /**
  5739. * Additional matrix indices (for bones)
  5740. */
  5741. static readonly MatricesIndicesExtraKind: string;
  5742. /**
  5743. * Additional matrix weights (for bones)
  5744. */
  5745. static readonly MatricesWeightsExtraKind: string;
  5746. /**
  5747. * Deduces the stride given a kind.
  5748. * @param kind The kind string to deduce
  5749. * @returns The deduced stride
  5750. */
  5751. static DeduceStride(kind: string): number;
  5752. /**
  5753. * Gets the byte length of the given type.
  5754. * @param type the type
  5755. * @returns the number of bytes
  5756. */
  5757. static GetTypeByteLength(type: number): number;
  5758. /**
  5759. * Enumerates each value of the given parameters as numbers.
  5760. * @param data the data to enumerate
  5761. * @param byteOffset the byte offset of the data
  5762. * @param byteStride the byte stride of the data
  5763. * @param componentCount the number of components per element
  5764. * @param componentType the type of the component
  5765. * @param count the total number of components
  5766. * @param normalized whether the data is normalized
  5767. * @param callback the callback function called for each value
  5768. */
  5769. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  5770. private static _GetFloatValue;
  5771. }
  5772. }
  5773. declare module "babylonjs/Maths/sphericalPolynomial" {
  5774. import { Vector3, Color3 } from "babylonjs/Maths/math";
  5775. /**
  5776. * Class representing spherical polynomial coefficients to the 3rd degree
  5777. */
  5778. export class SphericalPolynomial {
  5779. /**
  5780. * The x coefficients of the spherical polynomial
  5781. */
  5782. x: Vector3;
  5783. /**
  5784. * The y coefficients of the spherical polynomial
  5785. */
  5786. y: Vector3;
  5787. /**
  5788. * The z coefficients of the spherical polynomial
  5789. */
  5790. z: Vector3;
  5791. /**
  5792. * The xx coefficients of the spherical polynomial
  5793. */
  5794. xx: Vector3;
  5795. /**
  5796. * The yy coefficients of the spherical polynomial
  5797. */
  5798. yy: Vector3;
  5799. /**
  5800. * The zz coefficients of the spherical polynomial
  5801. */
  5802. zz: Vector3;
  5803. /**
  5804. * The xy coefficients of the spherical polynomial
  5805. */
  5806. xy: Vector3;
  5807. /**
  5808. * The yz coefficients of the spherical polynomial
  5809. */
  5810. yz: Vector3;
  5811. /**
  5812. * The zx coefficients of the spherical polynomial
  5813. */
  5814. zx: Vector3;
  5815. /**
  5816. * Adds an ambient color to the spherical polynomial
  5817. * @param color the color to add
  5818. */
  5819. addAmbient(color: Color3): void;
  5820. /**
  5821. * Scales the spherical polynomial by the given amount
  5822. * @param scale the amount to scale
  5823. */
  5824. scale(scale: number): void;
  5825. /**
  5826. * Gets the spherical polynomial from harmonics
  5827. * @param harmonics the spherical harmonics
  5828. * @returns the spherical polynomial
  5829. */
  5830. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  5831. /**
  5832. * Constructs a spherical polynomial from an array.
  5833. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  5834. * @returns the spherical polynomial
  5835. */
  5836. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  5837. }
  5838. /**
  5839. * Class representing spherical harmonics coefficients to the 3rd degree
  5840. */
  5841. export class SphericalHarmonics {
  5842. /**
  5843. * The l0,0 coefficients of the spherical harmonics
  5844. */
  5845. l00: Vector3;
  5846. /**
  5847. * The l1,-1 coefficients of the spherical harmonics
  5848. */
  5849. l1_1: Vector3;
  5850. /**
  5851. * The l1,0 coefficients of the spherical harmonics
  5852. */
  5853. l10: Vector3;
  5854. /**
  5855. * The l1,1 coefficients of the spherical harmonics
  5856. */
  5857. l11: Vector3;
  5858. /**
  5859. * The l2,-2 coefficients of the spherical harmonics
  5860. */
  5861. l2_2: Vector3;
  5862. /**
  5863. * The l2,-1 coefficients of the spherical harmonics
  5864. */
  5865. l2_1: Vector3;
  5866. /**
  5867. * The l2,0 coefficients of the spherical harmonics
  5868. */
  5869. l20: Vector3;
  5870. /**
  5871. * The l2,1 coefficients of the spherical harmonics
  5872. */
  5873. l21: Vector3;
  5874. /**
  5875. * The l2,2 coefficients of the spherical harmonics
  5876. */
  5877. lL22: Vector3;
  5878. /**
  5879. * Adds a light to the spherical harmonics
  5880. * @param direction the direction of the light
  5881. * @param color the color of the light
  5882. * @param deltaSolidAngle the delta solid angle of the light
  5883. */
  5884. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  5885. /**
  5886. * Scales the spherical harmonics by the given amount
  5887. * @param scale the amount to scale
  5888. */
  5889. scale(scale: number): void;
  5890. /**
  5891. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  5892. *
  5893. * ```
  5894. * E_lm = A_l * L_lm
  5895. * ```
  5896. *
  5897. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  5898. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  5899. * the scaling factors are given in equation 9.
  5900. */
  5901. convertIncidentRadianceToIrradiance(): void;
  5902. /**
  5903. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  5904. *
  5905. * ```
  5906. * L = (1/pi) * E * rho
  5907. * ```
  5908. *
  5909. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  5910. */
  5911. convertIrradianceToLambertianRadiance(): void;
  5912. /**
  5913. * Gets the spherical harmonics from polynomial
  5914. * @param polynomial the spherical polynomial
  5915. * @returns the spherical harmonics
  5916. */
  5917. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  5918. /**
  5919. * Constructs a spherical harmonics from an array.
  5920. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  5921. * @returns the spherical harmonics
  5922. */
  5923. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  5924. }
  5925. }
  5926. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  5927. import { Nullable } from "babylonjs/types";
  5928. /**
  5929. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  5930. */
  5931. export interface CubeMapInfo {
  5932. /**
  5933. * The pixel array for the front face.
  5934. * This is stored in format, left to right, up to down format.
  5935. */
  5936. front: Nullable<ArrayBufferView>;
  5937. /**
  5938. * The pixel array for the back face.
  5939. * This is stored in format, left to right, up to down format.
  5940. */
  5941. back: Nullable<ArrayBufferView>;
  5942. /**
  5943. * The pixel array for the left face.
  5944. * This is stored in format, left to right, up to down format.
  5945. */
  5946. left: Nullable<ArrayBufferView>;
  5947. /**
  5948. * The pixel array for the right face.
  5949. * This is stored in format, left to right, up to down format.
  5950. */
  5951. right: Nullable<ArrayBufferView>;
  5952. /**
  5953. * The pixel array for the up face.
  5954. * This is stored in format, left to right, up to down format.
  5955. */
  5956. up: Nullable<ArrayBufferView>;
  5957. /**
  5958. * The pixel array for the down face.
  5959. * This is stored in format, left to right, up to down format.
  5960. */
  5961. down: Nullable<ArrayBufferView>;
  5962. /**
  5963. * The size of the cubemap stored.
  5964. *
  5965. * Each faces will be size * size pixels.
  5966. */
  5967. size: number;
  5968. /**
  5969. * The format of the texture.
  5970. *
  5971. * RGBA, RGB.
  5972. */
  5973. format: number;
  5974. /**
  5975. * The type of the texture data.
  5976. *
  5977. * UNSIGNED_INT, FLOAT.
  5978. */
  5979. type: number;
  5980. /**
  5981. * Specifies whether the texture is in gamma space.
  5982. */
  5983. gammaSpace: boolean;
  5984. }
  5985. /**
  5986. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  5987. */
  5988. export class PanoramaToCubeMapTools {
  5989. private static FACE_FRONT;
  5990. private static FACE_BACK;
  5991. private static FACE_RIGHT;
  5992. private static FACE_LEFT;
  5993. private static FACE_DOWN;
  5994. private static FACE_UP;
  5995. /**
  5996. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  5997. *
  5998. * @param float32Array The source data.
  5999. * @param inputWidth The width of the input panorama.
  6000. * @param inputHeight The height of the input panorama.
  6001. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  6002. * @return The cubemap data
  6003. */
  6004. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  6005. private static CreateCubemapTexture;
  6006. private static CalcProjectionSpherical;
  6007. }
  6008. }
  6009. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  6010. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  6011. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  6012. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  6013. /**
  6014. * Helper class dealing with the extraction of spherical polynomial dataArray
  6015. * from a cube map.
  6016. */
  6017. export class CubeMapToSphericalPolynomialTools {
  6018. private static FileFaces;
  6019. /**
  6020. * Converts a texture to the according Spherical Polynomial data.
  6021. * This extracts the first 3 orders only as they are the only one used in the lighting.
  6022. *
  6023. * @param texture The texture to extract the information from.
  6024. * @return The Spherical Polynomial data.
  6025. */
  6026. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): SphericalPolynomial | null;
  6027. /**
  6028. * Converts a cubemap to the according Spherical Polynomial data.
  6029. * This extracts the first 3 orders only as they are the only one used in the lighting.
  6030. *
  6031. * @param cubeInfo The Cube map to extract the information from.
  6032. * @return The Spherical Polynomial data.
  6033. */
  6034. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  6035. }
  6036. }
  6037. declare module "babylonjs/Engines/engineStore" {
  6038. import { Nullable } from "babylonjs/types";
  6039. import { Engine } from "babylonjs/Engines/engine";
  6040. import { Scene } from "babylonjs/scene";
  6041. /**
  6042. * The engine store class is responsible to hold all the instances of Engine and Scene created
  6043. * during the life time of the application.
  6044. */
  6045. export class EngineStore {
  6046. /** Gets the list of created engines */
  6047. static Instances: import("babylonjs/Engines/engine").Engine[];
  6048. /**
  6049. * Gets the latest created engine
  6050. */
  6051. static readonly LastCreatedEngine: Nullable<Engine>;
  6052. /**
  6053. * Gets the latest created scene
  6054. */
  6055. static readonly LastCreatedScene: Nullable<Scene>;
  6056. }
  6057. }
  6058. declare module "babylonjs/Materials/Textures/renderTargetCreationOptions" {
  6059. /**
  6060. * Define options used to create a render target texture
  6061. */
  6062. export class RenderTargetCreationOptions {
  6063. /**
  6064. * Specifies is mipmaps must be generated
  6065. */
  6066. generateMipMaps?: boolean;
  6067. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  6068. generateDepthBuffer?: boolean;
  6069. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  6070. generateStencilBuffer?: boolean;
  6071. /** Defines texture type (int by default) */
  6072. type?: number;
  6073. /** Defines sampling mode (trilinear by default) */
  6074. samplingMode?: number;
  6075. /** Defines format (RGBA by default) */
  6076. format?: number;
  6077. }
  6078. }
  6079. declare module "babylonjs/States/alphaCullingState" {
  6080. /**
  6081. * @hidden
  6082. **/
  6083. export class _AlphaState {
  6084. private _isAlphaBlendDirty;
  6085. private _isBlendFunctionParametersDirty;
  6086. private _isBlendEquationParametersDirty;
  6087. private _isBlendConstantsDirty;
  6088. private _alphaBlend;
  6089. private _blendFunctionParameters;
  6090. private _blendEquationParameters;
  6091. private _blendConstants;
  6092. /**
  6093. * Initializes the state.
  6094. */
  6095. constructor();
  6096. readonly isDirty: boolean;
  6097. alphaBlend: boolean;
  6098. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  6099. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  6100. setAlphaEquationParameters(rgb: number, alpha: number): void;
  6101. reset(): void;
  6102. apply(gl: WebGLRenderingContext): void;
  6103. }
  6104. }
  6105. declare module "babylonjs/States/depthCullingState" {
  6106. import { Nullable } from "babylonjs/types";
  6107. /**
  6108. * @hidden
  6109. **/
  6110. export class _DepthCullingState {
  6111. private _isDepthTestDirty;
  6112. private _isDepthMaskDirty;
  6113. private _isDepthFuncDirty;
  6114. private _isCullFaceDirty;
  6115. private _isCullDirty;
  6116. private _isZOffsetDirty;
  6117. private _isFrontFaceDirty;
  6118. private _depthTest;
  6119. private _depthMask;
  6120. private _depthFunc;
  6121. private _cull;
  6122. private _cullFace;
  6123. private _zOffset;
  6124. private _frontFace;
  6125. /**
  6126. * Initializes the state.
  6127. */
  6128. constructor();
  6129. readonly isDirty: boolean;
  6130. zOffset: number;
  6131. cullFace: Nullable<number>;
  6132. cull: Nullable<boolean>;
  6133. depthFunc: Nullable<number>;
  6134. depthMask: boolean;
  6135. depthTest: boolean;
  6136. frontFace: Nullable<number>;
  6137. reset(): void;
  6138. apply(gl: WebGLRenderingContext): void;
  6139. }
  6140. }
  6141. declare module "babylonjs/States/stencilState" {
  6142. /**
  6143. * @hidden
  6144. **/
  6145. export class _StencilState {
  6146. /** 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 */
  6147. static readonly ALWAYS: number;
  6148. /** Passed to stencilOperation to specify that stencil value must be kept */
  6149. static readonly KEEP: number;
  6150. /** Passed to stencilOperation to specify that stencil value must be replaced */
  6151. static readonly REPLACE: number;
  6152. private _isStencilTestDirty;
  6153. private _isStencilMaskDirty;
  6154. private _isStencilFuncDirty;
  6155. private _isStencilOpDirty;
  6156. private _stencilTest;
  6157. private _stencilMask;
  6158. private _stencilFunc;
  6159. private _stencilFuncRef;
  6160. private _stencilFuncMask;
  6161. private _stencilOpStencilFail;
  6162. private _stencilOpDepthFail;
  6163. private _stencilOpStencilDepthPass;
  6164. readonly isDirty: boolean;
  6165. stencilFunc: number;
  6166. stencilFuncRef: number;
  6167. stencilFuncMask: number;
  6168. stencilOpStencilFail: number;
  6169. stencilOpDepthFail: number;
  6170. stencilOpStencilDepthPass: number;
  6171. stencilMask: number;
  6172. stencilTest: boolean;
  6173. constructor();
  6174. reset(): void;
  6175. apply(gl: WebGLRenderingContext): void;
  6176. }
  6177. }
  6178. declare module "babylonjs/States/index" {
  6179. export * from "babylonjs/States/alphaCullingState";
  6180. export * from "babylonjs/States/depthCullingState";
  6181. export * from "babylonjs/States/stencilState";
  6182. }
  6183. declare module "babylonjs/Instrumentation/timeToken" {
  6184. import { Nullable } from "babylonjs/types";
  6185. /**
  6186. * @hidden
  6187. **/
  6188. export class _TimeToken {
  6189. _startTimeQuery: Nullable<WebGLQuery>;
  6190. _endTimeQuery: Nullable<WebGLQuery>;
  6191. _timeElapsedQuery: Nullable<WebGLQuery>;
  6192. _timeElapsedQueryEnded: boolean;
  6193. }
  6194. }
  6195. declare module "babylonjs/Materials/Textures/internalTexture" {
  6196. import { Observable } from "babylonjs/Misc/observable";
  6197. import { Nullable, int } from "babylonjs/types";
  6198. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  6199. import { Engine } from "babylonjs/Engines/engine";
  6200. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  6201. /**
  6202. * Class used to store data associated with WebGL texture data for the engine
  6203. * This class should not be used directly
  6204. */
  6205. export class InternalTexture {
  6206. /** hidden */
  6207. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: SphericalPolynomial | null, lodScale: number, lodOffset: number) => Promise<void>;
  6208. /**
  6209. * The source of the texture data is unknown
  6210. */
  6211. static DATASOURCE_UNKNOWN: number;
  6212. /**
  6213. * Texture data comes from an URL
  6214. */
  6215. static DATASOURCE_URL: number;
  6216. /**
  6217. * Texture data is only used for temporary storage
  6218. */
  6219. static DATASOURCE_TEMP: number;
  6220. /**
  6221. * Texture data comes from raw data (ArrayBuffer)
  6222. */
  6223. static DATASOURCE_RAW: number;
  6224. /**
  6225. * Texture content is dynamic (video or dynamic texture)
  6226. */
  6227. static DATASOURCE_DYNAMIC: number;
  6228. /**
  6229. * Texture content is generated by rendering to it
  6230. */
  6231. static DATASOURCE_RENDERTARGET: number;
  6232. /**
  6233. * Texture content is part of a multi render target process
  6234. */
  6235. static DATASOURCE_MULTIRENDERTARGET: number;
  6236. /**
  6237. * Texture data comes from a cube data file
  6238. */
  6239. static DATASOURCE_CUBE: number;
  6240. /**
  6241. * Texture data comes from a raw cube data
  6242. */
  6243. static DATASOURCE_CUBERAW: number;
  6244. /**
  6245. * Texture data come from a prefiltered cube data file
  6246. */
  6247. static DATASOURCE_CUBEPREFILTERED: number;
  6248. /**
  6249. * Texture content is raw 3D data
  6250. */
  6251. static DATASOURCE_RAW3D: number;
  6252. /**
  6253. * Texture content is a depth texture
  6254. */
  6255. static DATASOURCE_DEPTHTEXTURE: number;
  6256. /**
  6257. * Texture data comes from a raw cube data encoded with RGBD
  6258. */
  6259. static DATASOURCE_CUBERAW_RGBD: number;
  6260. /**
  6261. * Defines if the texture is ready
  6262. */
  6263. isReady: boolean;
  6264. /**
  6265. * Defines if the texture is a cube texture
  6266. */
  6267. isCube: boolean;
  6268. /**
  6269. * Defines if the texture contains 3D data
  6270. */
  6271. is3D: boolean;
  6272. /**
  6273. * Defines if the texture contains multiview data
  6274. */
  6275. isMultiview: boolean;
  6276. /**
  6277. * Gets the URL used to load this texture
  6278. */
  6279. url: string;
  6280. /**
  6281. * Gets the sampling mode of the texture
  6282. */
  6283. samplingMode: number;
  6284. /**
  6285. * Gets a boolean indicating if the texture needs mipmaps generation
  6286. */
  6287. generateMipMaps: boolean;
  6288. /**
  6289. * Gets the number of samples used by the texture (WebGL2+ only)
  6290. */
  6291. samples: number;
  6292. /**
  6293. * Gets the type of the texture (int, float...)
  6294. */
  6295. type: number;
  6296. /**
  6297. * Gets the format of the texture (RGB, RGBA...)
  6298. */
  6299. format: number;
  6300. /**
  6301. * Observable called when the texture is loaded
  6302. */
  6303. onLoadedObservable: Observable<InternalTexture>;
  6304. /**
  6305. * Gets the width of the texture
  6306. */
  6307. width: number;
  6308. /**
  6309. * Gets the height of the texture
  6310. */
  6311. height: number;
  6312. /**
  6313. * Gets the depth of the texture
  6314. */
  6315. depth: number;
  6316. /**
  6317. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  6318. */
  6319. baseWidth: number;
  6320. /**
  6321. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  6322. */
  6323. baseHeight: number;
  6324. /**
  6325. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  6326. */
  6327. baseDepth: number;
  6328. /**
  6329. * Gets a boolean indicating if the texture is inverted on Y axis
  6330. */
  6331. invertY: boolean;
  6332. /** @hidden */
  6333. _invertVScale: boolean;
  6334. /** @hidden */
  6335. _associatedChannel: number;
  6336. /** @hidden */
  6337. _dataSource: number;
  6338. /** @hidden */
  6339. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  6340. /** @hidden */
  6341. _bufferView: Nullable<ArrayBufferView>;
  6342. /** @hidden */
  6343. _bufferViewArray: Nullable<ArrayBufferView[]>;
  6344. /** @hidden */
  6345. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  6346. /** @hidden */
  6347. _size: number;
  6348. /** @hidden */
  6349. _extension: string;
  6350. /** @hidden */
  6351. _files: Nullable<string[]>;
  6352. /** @hidden */
  6353. _workingCanvas: HTMLCanvasElement;
  6354. /** @hidden */
  6355. _workingContext: CanvasRenderingContext2D;
  6356. /** @hidden */
  6357. _framebuffer: Nullable<WebGLFramebuffer>;
  6358. /** @hidden */
  6359. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  6360. /** @hidden */
  6361. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  6362. /** @hidden */
  6363. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  6364. /** @hidden */
  6365. _attachments: Nullable<number[]>;
  6366. /** @hidden */
  6367. _cachedCoordinatesMode: Nullable<number>;
  6368. /** @hidden */
  6369. _cachedWrapU: Nullable<number>;
  6370. /** @hidden */
  6371. _cachedWrapV: Nullable<number>;
  6372. /** @hidden */
  6373. _cachedWrapR: Nullable<number>;
  6374. /** @hidden */
  6375. _cachedAnisotropicFilteringLevel: Nullable<number>;
  6376. /** @hidden */
  6377. _isDisabled: boolean;
  6378. /** @hidden */
  6379. _compression: Nullable<string>;
  6380. /** @hidden */
  6381. _generateStencilBuffer: boolean;
  6382. /** @hidden */
  6383. _generateDepthBuffer: boolean;
  6384. /** @hidden */
  6385. _comparisonFunction: number;
  6386. /** @hidden */
  6387. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  6388. /** @hidden */
  6389. _lodGenerationScale: number;
  6390. /** @hidden */
  6391. _lodGenerationOffset: number;
  6392. /** @hidden */
  6393. _colorTextureArray: Nullable<WebGLTexture>;
  6394. /** @hidden */
  6395. _depthStencilTextureArray: Nullable<WebGLTexture>;
  6396. /** @hidden */
  6397. _lodTextureHigh: BaseTexture;
  6398. /** @hidden */
  6399. _lodTextureMid: BaseTexture;
  6400. /** @hidden */
  6401. _lodTextureLow: BaseTexture;
  6402. /** @hidden */
  6403. _isRGBD: boolean;
  6404. /** @hidden */
  6405. _webGLTexture: Nullable<WebGLTexture>;
  6406. /** @hidden */
  6407. _references: number;
  6408. private _engine;
  6409. /**
  6410. * Gets the Engine the texture belongs to.
  6411. * @returns The babylon engine
  6412. */
  6413. getEngine(): Engine;
  6414. /**
  6415. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  6416. */
  6417. readonly dataSource: number;
  6418. /**
  6419. * Creates a new InternalTexture
  6420. * @param engine defines the engine to use
  6421. * @param dataSource defines the type of data that will be used
  6422. * @param delayAllocation if the texture allocation should be delayed (default: false)
  6423. */
  6424. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  6425. /**
  6426. * Increments the number of references (ie. the number of Texture that point to it)
  6427. */
  6428. incrementReferences(): void;
  6429. /**
  6430. * Change the size of the texture (not the size of the content)
  6431. * @param width defines the new width
  6432. * @param height defines the new height
  6433. * @param depth defines the new depth (1 by default)
  6434. */
  6435. updateSize(width: int, height: int, depth?: int): void;
  6436. /** @hidden */
  6437. _rebuild(): void;
  6438. /** @hidden */
  6439. _swapAndDie(target: InternalTexture): void;
  6440. /**
  6441. * Dispose the current allocated resources
  6442. */
  6443. dispose(): void;
  6444. }
  6445. }
  6446. declare module "babylonjs/Animations/easing" {
  6447. /**
  6448. * This represents the main contract an easing function should follow.
  6449. * Easing functions are used throughout the animation system.
  6450. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6451. */
  6452. export interface IEasingFunction {
  6453. /**
  6454. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6455. * of the easing function.
  6456. * The link below provides some of the most common examples of easing functions.
  6457. * @see https://easings.net/
  6458. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6459. * @returns the corresponding value on the curve defined by the easing function
  6460. */
  6461. ease(gradient: number): number;
  6462. }
  6463. /**
  6464. * Base class used for every default easing function.
  6465. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6466. */
  6467. export class EasingFunction implements IEasingFunction {
  6468. /**
  6469. * Interpolation follows the mathematical formula associated with the easing function.
  6470. */
  6471. static readonly EASINGMODE_EASEIN: number;
  6472. /**
  6473. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  6474. */
  6475. static readonly EASINGMODE_EASEOUT: number;
  6476. /**
  6477. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  6478. */
  6479. static readonly EASINGMODE_EASEINOUT: number;
  6480. private _easingMode;
  6481. /**
  6482. * Sets the easing mode of the current function.
  6483. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  6484. */
  6485. setEasingMode(easingMode: number): void;
  6486. /**
  6487. * Gets the current easing mode.
  6488. * @returns the easing mode
  6489. */
  6490. getEasingMode(): number;
  6491. /**
  6492. * @hidden
  6493. */
  6494. easeInCore(gradient: number): number;
  6495. /**
  6496. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6497. * of the easing function.
  6498. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6499. * @returns the corresponding value on the curve defined by the easing function
  6500. */
  6501. ease(gradient: number): number;
  6502. }
  6503. /**
  6504. * Easing function with a circle shape (see link below).
  6505. * @see https://easings.net/#easeInCirc
  6506. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6507. */
  6508. export class CircleEase extends EasingFunction implements IEasingFunction {
  6509. /** @hidden */
  6510. easeInCore(gradient: number): number;
  6511. }
  6512. /**
  6513. * Easing function with a ease back shape (see link below).
  6514. * @see https://easings.net/#easeInBack
  6515. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6516. */
  6517. export class BackEase extends EasingFunction implements IEasingFunction {
  6518. /** Defines the amplitude of the function */
  6519. amplitude: number;
  6520. /**
  6521. * Instantiates a back ease easing
  6522. * @see https://easings.net/#easeInBack
  6523. * @param amplitude Defines the amplitude of the function
  6524. */
  6525. constructor(
  6526. /** Defines the amplitude of the function */
  6527. amplitude?: number);
  6528. /** @hidden */
  6529. easeInCore(gradient: number): number;
  6530. }
  6531. /**
  6532. * Easing function with a bouncing shape (see link below).
  6533. * @see https://easings.net/#easeInBounce
  6534. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6535. */
  6536. export class BounceEase extends EasingFunction implements IEasingFunction {
  6537. /** Defines the number of bounces */
  6538. bounces: number;
  6539. /** Defines the amplitude of the bounce */
  6540. bounciness: number;
  6541. /**
  6542. * Instantiates a bounce easing
  6543. * @see https://easings.net/#easeInBounce
  6544. * @param bounces Defines the number of bounces
  6545. * @param bounciness Defines the amplitude of the bounce
  6546. */
  6547. constructor(
  6548. /** Defines the number of bounces */
  6549. bounces?: number,
  6550. /** Defines the amplitude of the bounce */
  6551. bounciness?: number);
  6552. /** @hidden */
  6553. easeInCore(gradient: number): number;
  6554. }
  6555. /**
  6556. * Easing function with a power of 3 shape (see link below).
  6557. * @see https://easings.net/#easeInCubic
  6558. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6559. */
  6560. export class CubicEase extends EasingFunction implements IEasingFunction {
  6561. /** @hidden */
  6562. easeInCore(gradient: number): number;
  6563. }
  6564. /**
  6565. * Easing function with an elastic shape (see link below).
  6566. * @see https://easings.net/#easeInElastic
  6567. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6568. */
  6569. export class ElasticEase extends EasingFunction implements IEasingFunction {
  6570. /** Defines the number of oscillations*/
  6571. oscillations: number;
  6572. /** Defines the amplitude of the oscillations*/
  6573. springiness: number;
  6574. /**
  6575. * Instantiates an elastic easing function
  6576. * @see https://easings.net/#easeInElastic
  6577. * @param oscillations Defines the number of oscillations
  6578. * @param springiness Defines the amplitude of the oscillations
  6579. */
  6580. constructor(
  6581. /** Defines the number of oscillations*/
  6582. oscillations?: number,
  6583. /** Defines the amplitude of the oscillations*/
  6584. springiness?: number);
  6585. /** @hidden */
  6586. easeInCore(gradient: number): number;
  6587. }
  6588. /**
  6589. * Easing function with an exponential shape (see link below).
  6590. * @see https://easings.net/#easeInExpo
  6591. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6592. */
  6593. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  6594. /** Defines the exponent of the function */
  6595. exponent: number;
  6596. /**
  6597. * Instantiates an exponential easing function
  6598. * @see https://easings.net/#easeInExpo
  6599. * @param exponent Defines the exponent of the function
  6600. */
  6601. constructor(
  6602. /** Defines the exponent of the function */
  6603. exponent?: number);
  6604. /** @hidden */
  6605. easeInCore(gradient: number): number;
  6606. }
  6607. /**
  6608. * Easing function with a power shape (see link below).
  6609. * @see https://easings.net/#easeInQuad
  6610. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6611. */
  6612. export class PowerEase extends EasingFunction implements IEasingFunction {
  6613. /** Defines the power of the function */
  6614. power: number;
  6615. /**
  6616. * Instantiates an power base easing function
  6617. * @see https://easings.net/#easeInQuad
  6618. * @param power Defines the power of the function
  6619. */
  6620. constructor(
  6621. /** Defines the power of the function */
  6622. power?: number);
  6623. /** @hidden */
  6624. easeInCore(gradient: number): number;
  6625. }
  6626. /**
  6627. * Easing function with a power of 2 shape (see link below).
  6628. * @see https://easings.net/#easeInQuad
  6629. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6630. */
  6631. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  6632. /** @hidden */
  6633. easeInCore(gradient: number): number;
  6634. }
  6635. /**
  6636. * Easing function with a power of 4 shape (see link below).
  6637. * @see https://easings.net/#easeInQuart
  6638. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6639. */
  6640. export class QuarticEase extends EasingFunction implements IEasingFunction {
  6641. /** @hidden */
  6642. easeInCore(gradient: number): number;
  6643. }
  6644. /**
  6645. * Easing function with a power of 5 shape (see link below).
  6646. * @see https://easings.net/#easeInQuint
  6647. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6648. */
  6649. export class QuinticEase extends EasingFunction implements IEasingFunction {
  6650. /** @hidden */
  6651. easeInCore(gradient: number): number;
  6652. }
  6653. /**
  6654. * Easing function with a sin shape (see link below).
  6655. * @see https://easings.net/#easeInSine
  6656. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6657. */
  6658. export class SineEase extends EasingFunction implements IEasingFunction {
  6659. /** @hidden */
  6660. easeInCore(gradient: number): number;
  6661. }
  6662. /**
  6663. * Easing function with a bezier shape (see link below).
  6664. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6665. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6666. */
  6667. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  6668. /** Defines the x component of the start tangent in the bezier curve */
  6669. x1: number;
  6670. /** Defines the y component of the start tangent in the bezier curve */
  6671. y1: number;
  6672. /** Defines the x component of the end tangent in the bezier curve */
  6673. x2: number;
  6674. /** Defines the y component of the end tangent in the bezier curve */
  6675. y2: number;
  6676. /**
  6677. * Instantiates a bezier function
  6678. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6679. * @param x1 Defines the x component of the start tangent in the bezier curve
  6680. * @param y1 Defines the y component of the start tangent in the bezier curve
  6681. * @param x2 Defines the x component of the end tangent in the bezier curve
  6682. * @param y2 Defines the y component of the end tangent in the bezier curve
  6683. */
  6684. constructor(
  6685. /** Defines the x component of the start tangent in the bezier curve */
  6686. x1?: number,
  6687. /** Defines the y component of the start tangent in the bezier curve */
  6688. y1?: number,
  6689. /** Defines the x component of the end tangent in the bezier curve */
  6690. x2?: number,
  6691. /** Defines the y component of the end tangent in the bezier curve */
  6692. y2?: number);
  6693. /** @hidden */
  6694. easeInCore(gradient: number): number;
  6695. }
  6696. }
  6697. declare module "babylonjs/Animations/animationKey" {
  6698. /**
  6699. * Defines an interface which represents an animation key frame
  6700. */
  6701. export interface IAnimationKey {
  6702. /**
  6703. * Frame of the key frame
  6704. */
  6705. frame: number;
  6706. /**
  6707. * Value at the specifies key frame
  6708. */
  6709. value: any;
  6710. /**
  6711. * The input tangent for the cubic hermite spline
  6712. */
  6713. inTangent?: any;
  6714. /**
  6715. * The output tangent for the cubic hermite spline
  6716. */
  6717. outTangent?: any;
  6718. /**
  6719. * The animation interpolation type
  6720. */
  6721. interpolation?: AnimationKeyInterpolation;
  6722. }
  6723. /**
  6724. * Enum for the animation key frame interpolation type
  6725. */
  6726. export enum AnimationKeyInterpolation {
  6727. /**
  6728. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6729. */
  6730. STEP = 1
  6731. }
  6732. }
  6733. declare module "babylonjs/Animations/animationRange" {
  6734. /**
  6735. * Represents the range of an animation
  6736. */
  6737. export class AnimationRange {
  6738. /**The name of the animation range**/
  6739. name: string;
  6740. /**The starting frame of the animation */
  6741. from: number;
  6742. /**The ending frame of the animation*/
  6743. to: number;
  6744. /**
  6745. * Initializes the range of an animation
  6746. * @param name The name of the animation range
  6747. * @param from The starting frame of the animation
  6748. * @param to The ending frame of the animation
  6749. */
  6750. constructor(
  6751. /**The name of the animation range**/
  6752. name: string,
  6753. /**The starting frame of the animation */
  6754. from: number,
  6755. /**The ending frame of the animation*/
  6756. to: number);
  6757. /**
  6758. * Makes a copy of the animation range
  6759. * @returns A copy of the animation range
  6760. */
  6761. clone(): AnimationRange;
  6762. }
  6763. }
  6764. declare module "babylonjs/Animations/animationEvent" {
  6765. /**
  6766. * Composed of a frame, and an action function
  6767. */
  6768. export class AnimationEvent {
  6769. /** The frame for which the event is triggered **/
  6770. frame: number;
  6771. /** The event to perform when triggered **/
  6772. action: (currentFrame: number) => void;
  6773. /** Specifies if the event should be triggered only once**/
  6774. onlyOnce?: boolean | undefined;
  6775. /**
  6776. * Specifies if the animation event is done
  6777. */
  6778. isDone: boolean;
  6779. /**
  6780. * Initializes the animation event
  6781. * @param frame The frame for which the event is triggered
  6782. * @param action The event to perform when triggered
  6783. * @param onlyOnce Specifies if the event should be triggered only once
  6784. */
  6785. constructor(
  6786. /** The frame for which the event is triggered **/
  6787. frame: number,
  6788. /** The event to perform when triggered **/
  6789. action: (currentFrame: number) => void,
  6790. /** Specifies if the event should be triggered only once**/
  6791. onlyOnce?: boolean | undefined);
  6792. /** @hidden */
  6793. _clone(): AnimationEvent;
  6794. }
  6795. }
  6796. declare module "babylonjs/Behaviors/behavior" {
  6797. import { Nullable } from "babylonjs/types";
  6798. /**
  6799. * Interface used to define a behavior
  6800. */
  6801. export interface Behavior<T> {
  6802. /** gets or sets behavior's name */
  6803. name: string;
  6804. /**
  6805. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6806. */
  6807. init(): void;
  6808. /**
  6809. * Called when the behavior is attached to a target
  6810. * @param target defines the target where the behavior is attached to
  6811. */
  6812. attach(target: T): void;
  6813. /**
  6814. * Called when the behavior is detached from its target
  6815. */
  6816. detach(): void;
  6817. }
  6818. /**
  6819. * Interface implemented by classes supporting behaviors
  6820. */
  6821. export interface IBehaviorAware<T> {
  6822. /**
  6823. * Attach a behavior
  6824. * @param behavior defines the behavior to attach
  6825. * @returns the current host
  6826. */
  6827. addBehavior(behavior: Behavior<T>): T;
  6828. /**
  6829. * Remove a behavior from the current object
  6830. * @param behavior defines the behavior to detach
  6831. * @returns the current host
  6832. */
  6833. removeBehavior(behavior: Behavior<T>): T;
  6834. /**
  6835. * Gets a behavior using its name to search
  6836. * @param name defines the name to search
  6837. * @returns the behavior or null if not found
  6838. */
  6839. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6840. }
  6841. }
  6842. declare module "babylonjs/Collisions/intersectionInfo" {
  6843. import { Nullable } from "babylonjs/types";
  6844. /**
  6845. * @hidden
  6846. */
  6847. export class IntersectionInfo {
  6848. bu: Nullable<number>;
  6849. bv: Nullable<number>;
  6850. distance: number;
  6851. faceId: number;
  6852. subMeshId: number;
  6853. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6854. }
  6855. }
  6856. declare module "babylonjs/Culling/boundingSphere" {
  6857. import { DeepImmutable } from "babylonjs/types";
  6858. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  6859. /**
  6860. * Class used to store bounding sphere information
  6861. */
  6862. export class BoundingSphere {
  6863. /**
  6864. * Gets the center of the bounding sphere in local space
  6865. */
  6866. readonly center: Vector3;
  6867. /**
  6868. * Radius of the bounding sphere in local space
  6869. */
  6870. radius: number;
  6871. /**
  6872. * Gets the center of the bounding sphere in world space
  6873. */
  6874. readonly centerWorld: Vector3;
  6875. /**
  6876. * Radius of the bounding sphere in world space
  6877. */
  6878. radiusWorld: number;
  6879. /**
  6880. * Gets the minimum vector in local space
  6881. */
  6882. readonly minimum: Vector3;
  6883. /**
  6884. * Gets the maximum vector in local space
  6885. */
  6886. readonly maximum: Vector3;
  6887. private _worldMatrix;
  6888. private static readonly TmpVector3;
  6889. /**
  6890. * Creates a new bounding sphere
  6891. * @param min defines the minimum vector (in local space)
  6892. * @param max defines the maximum vector (in local space)
  6893. * @param worldMatrix defines the new world matrix
  6894. */
  6895. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6896. /**
  6897. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6898. * @param min defines the new minimum vector (in local space)
  6899. * @param max defines the new maximum vector (in local space)
  6900. * @param worldMatrix defines the new world matrix
  6901. */
  6902. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6903. /**
  6904. * Scale the current bounding sphere by applying a scale factor
  6905. * @param factor defines the scale factor to apply
  6906. * @returns the current bounding box
  6907. */
  6908. scale(factor: number): BoundingSphere;
  6909. /**
  6910. * Gets the world matrix of the bounding box
  6911. * @returns a matrix
  6912. */
  6913. getWorldMatrix(): DeepImmutable<Matrix>;
  6914. /** @hidden */
  6915. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6916. /**
  6917. * Tests if the bounding sphere is intersecting the frustum planes
  6918. * @param frustumPlanes defines the frustum planes to test
  6919. * @returns true if there is an intersection
  6920. */
  6921. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6922. /**
  6923. * Tests if the bounding sphere center is in between the frustum planes.
  6924. * Used for optimistic fast inclusion.
  6925. * @param frustumPlanes defines the frustum planes to test
  6926. * @returns true if the sphere center is in between the frustum planes
  6927. */
  6928. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6929. /**
  6930. * Tests if a point is inside the bounding sphere
  6931. * @param point defines the point to test
  6932. * @returns true if the point is inside the bounding sphere
  6933. */
  6934. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6935. /**
  6936. * Checks if two sphere intersct
  6937. * @param sphere0 sphere 0
  6938. * @param sphere1 sphere 1
  6939. * @returns true if the speres intersect
  6940. */
  6941. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6942. }
  6943. }
  6944. declare module "babylonjs/Culling/boundingBox" {
  6945. import { DeepImmutable } from "babylonjs/types";
  6946. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  6947. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  6948. import { ICullable } from "babylonjs/Culling/boundingInfo";
  6949. /**
  6950. * Class used to store bounding box information
  6951. */
  6952. export class BoundingBox implements ICullable {
  6953. /**
  6954. * Gets the 8 vectors representing the bounding box in local space
  6955. */
  6956. readonly vectors: Vector3[];
  6957. /**
  6958. * Gets the center of the bounding box in local space
  6959. */
  6960. readonly center: Vector3;
  6961. /**
  6962. * Gets the center of the bounding box in world space
  6963. */
  6964. readonly centerWorld: Vector3;
  6965. /**
  6966. * Gets the extend size in local space
  6967. */
  6968. readonly extendSize: Vector3;
  6969. /**
  6970. * Gets the extend size in world space
  6971. */
  6972. readonly extendSizeWorld: Vector3;
  6973. /**
  6974. * Gets the OBB (object bounding box) directions
  6975. */
  6976. readonly directions: Vector3[];
  6977. /**
  6978. * Gets the 8 vectors representing the bounding box in world space
  6979. */
  6980. readonly vectorsWorld: Vector3[];
  6981. /**
  6982. * Gets the minimum vector in world space
  6983. */
  6984. readonly minimumWorld: Vector3;
  6985. /**
  6986. * Gets the maximum vector in world space
  6987. */
  6988. readonly maximumWorld: Vector3;
  6989. /**
  6990. * Gets the minimum vector in local space
  6991. */
  6992. readonly minimum: Vector3;
  6993. /**
  6994. * Gets the maximum vector in local space
  6995. */
  6996. readonly maximum: Vector3;
  6997. private _worldMatrix;
  6998. private static readonly TmpVector3;
  6999. /**
  7000. * @hidden
  7001. */
  7002. _tag: number;
  7003. /**
  7004. * Creates a new bounding box
  7005. * @param min defines the minimum vector (in local space)
  7006. * @param max defines the maximum vector (in local space)
  7007. * @param worldMatrix defines the new world matrix
  7008. */
  7009. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7010. /**
  7011. * Recreates the entire bounding box from scratch as if we call the constructor in place
  7012. * @param min defines the new minimum vector (in local space)
  7013. * @param max defines the new maximum vector (in local space)
  7014. * @param worldMatrix defines the new world matrix
  7015. */
  7016. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7017. /**
  7018. * Scale the current bounding box by applying a scale factor
  7019. * @param factor defines the scale factor to apply
  7020. * @returns the current bounding box
  7021. */
  7022. scale(factor: number): BoundingBox;
  7023. /**
  7024. * Gets the world matrix of the bounding box
  7025. * @returns a matrix
  7026. */
  7027. getWorldMatrix(): DeepImmutable<Matrix>;
  7028. /** @hidden */
  7029. _update(world: DeepImmutable<Matrix>): void;
  7030. /**
  7031. * Tests if the bounding box is intersecting the frustum planes
  7032. * @param frustumPlanes defines the frustum planes to test
  7033. * @returns true if there is an intersection
  7034. */
  7035. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7036. /**
  7037. * Tests if the bounding box is entirely inside the frustum planes
  7038. * @param frustumPlanes defines the frustum planes to test
  7039. * @returns true if there is an inclusion
  7040. */
  7041. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7042. /**
  7043. * Tests if a point is inside the bounding box
  7044. * @param point defines the point to test
  7045. * @returns true if the point is inside the bounding box
  7046. */
  7047. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7048. /**
  7049. * Tests if the bounding box intersects with a bounding sphere
  7050. * @param sphere defines the sphere to test
  7051. * @returns true if there is an intersection
  7052. */
  7053. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  7054. /**
  7055. * Tests if the bounding box intersects with a box defined by a min and max vectors
  7056. * @param min defines the min vector to use
  7057. * @param max defines the max vector to use
  7058. * @returns true if there is an intersection
  7059. */
  7060. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  7061. /**
  7062. * Tests if two bounding boxes are intersections
  7063. * @param box0 defines the first box to test
  7064. * @param box1 defines the second box to test
  7065. * @returns true if there is an intersection
  7066. */
  7067. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7068. /**
  7069. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7070. * @param minPoint defines the minimum vector of the bounding box
  7071. * @param maxPoint defines the maximum vector of the bounding box
  7072. * @param sphereCenter defines the sphere center
  7073. * @param sphereRadius defines the sphere radius
  7074. * @returns true if there is an intersection
  7075. */
  7076. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7077. /**
  7078. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7079. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7080. * @param frustumPlanes defines the frustum planes to test
  7081. * @return true if there is an inclusion
  7082. */
  7083. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7084. /**
  7085. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7086. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7087. * @param frustumPlanes defines the frustum planes to test
  7088. * @return true if there is an intersection
  7089. */
  7090. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7091. }
  7092. }
  7093. declare module "babylonjs/Collisions/collider" {
  7094. import { Nullable, IndicesArray } from "babylonjs/types";
  7095. import { Vector3, Plane } from "babylonjs/Maths/math";
  7096. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7097. /** @hidden */
  7098. export class Collider {
  7099. /** Define if a collision was found */
  7100. collisionFound: boolean;
  7101. /**
  7102. * Define last intersection point in local space
  7103. */
  7104. intersectionPoint: Vector3;
  7105. /**
  7106. * Define last collided mesh
  7107. */
  7108. collidedMesh: Nullable<AbstractMesh>;
  7109. private _collisionPoint;
  7110. private _planeIntersectionPoint;
  7111. private _tempVector;
  7112. private _tempVector2;
  7113. private _tempVector3;
  7114. private _tempVector4;
  7115. private _edge;
  7116. private _baseToVertex;
  7117. private _destinationPoint;
  7118. private _slidePlaneNormal;
  7119. private _displacementVector;
  7120. /** @hidden */
  7121. _radius: Vector3;
  7122. /** @hidden */
  7123. _retry: number;
  7124. private _velocity;
  7125. private _basePoint;
  7126. private _epsilon;
  7127. /** @hidden */
  7128. _velocityWorldLength: number;
  7129. /** @hidden */
  7130. _basePointWorld: Vector3;
  7131. private _velocityWorld;
  7132. private _normalizedVelocity;
  7133. /** @hidden */
  7134. _initialVelocity: Vector3;
  7135. /** @hidden */
  7136. _initialPosition: Vector3;
  7137. private _nearestDistance;
  7138. private _collisionMask;
  7139. collisionMask: number;
  7140. /**
  7141. * Gets the plane normal used to compute the sliding response (in local space)
  7142. */
  7143. readonly slidePlaneNormal: Vector3;
  7144. /** @hidden */
  7145. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7146. /** @hidden */
  7147. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7148. /** @hidden */
  7149. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7150. /** @hidden */
  7151. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  7152. /** @hidden */
  7153. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  7154. /** @hidden */
  7155. _getResponse(pos: Vector3, vel: Vector3): void;
  7156. }
  7157. }
  7158. declare module "babylonjs/Culling/boundingInfo" {
  7159. import { DeepImmutable } from "babylonjs/types";
  7160. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  7161. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  7162. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7163. import { Collider } from "babylonjs/Collisions/collider";
  7164. /**
  7165. * Interface for cullable objects
  7166. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7167. */
  7168. export interface ICullable {
  7169. /**
  7170. * Checks if the object or part of the object is in the frustum
  7171. * @param frustumPlanes Camera near/planes
  7172. * @returns true if the object is in frustum otherwise false
  7173. */
  7174. isInFrustum(frustumPlanes: Plane[]): boolean;
  7175. /**
  7176. * Checks if a cullable object (mesh...) is in the camera frustum
  7177. * Unlike isInFrustum this cheks the full bounding box
  7178. * @param frustumPlanes Camera near/planes
  7179. * @returns true if the object is in frustum otherwise false
  7180. */
  7181. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7182. }
  7183. /**
  7184. * Info for a bounding data of a mesh
  7185. */
  7186. export class BoundingInfo implements ICullable {
  7187. /**
  7188. * Bounding box for the mesh
  7189. */
  7190. readonly boundingBox: BoundingBox;
  7191. /**
  7192. * Bounding sphere for the mesh
  7193. */
  7194. readonly boundingSphere: BoundingSphere;
  7195. private _isLocked;
  7196. private static readonly TmpVector3;
  7197. /**
  7198. * Constructs bounding info
  7199. * @param minimum min vector of the bounding box/sphere
  7200. * @param maximum max vector of the bounding box/sphere
  7201. * @param worldMatrix defines the new world matrix
  7202. */
  7203. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7204. /**
  7205. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7206. * @param min defines the new minimum vector (in local space)
  7207. * @param max defines the new maximum vector (in local space)
  7208. * @param worldMatrix defines the new world matrix
  7209. */
  7210. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7211. /**
  7212. * min vector of the bounding box/sphere
  7213. */
  7214. readonly minimum: Vector3;
  7215. /**
  7216. * max vector of the bounding box/sphere
  7217. */
  7218. readonly maximum: Vector3;
  7219. /**
  7220. * If the info is locked and won't be updated to avoid perf overhead
  7221. */
  7222. isLocked: boolean;
  7223. /**
  7224. * Updates the bounding sphere and box
  7225. * @param world world matrix to be used to update
  7226. */
  7227. update(world: DeepImmutable<Matrix>): void;
  7228. /**
  7229. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7230. * @param center New center of the bounding info
  7231. * @param extend New extend of the bounding info
  7232. * @returns the current bounding info
  7233. */
  7234. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7235. /**
  7236. * Scale the current bounding info by applying a scale factor
  7237. * @param factor defines the scale factor to apply
  7238. * @returns the current bounding info
  7239. */
  7240. scale(factor: number): BoundingInfo;
  7241. /**
  7242. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7243. * @param frustumPlanes defines the frustum to test
  7244. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7245. * @returns true if the bounding info is in the frustum planes
  7246. */
  7247. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7248. /**
  7249. * Gets the world distance between the min and max points of the bounding box
  7250. */
  7251. readonly diagonalLength: number;
  7252. /**
  7253. * Checks if a cullable object (mesh...) is in the camera frustum
  7254. * Unlike isInFrustum this cheks the full bounding box
  7255. * @param frustumPlanes Camera near/planes
  7256. * @returns true if the object is in frustum otherwise false
  7257. */
  7258. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7259. /** @hidden */
  7260. _checkCollision(collider: Collider): boolean;
  7261. /**
  7262. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7263. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7264. * @param point the point to check intersection with
  7265. * @returns if the point intersects
  7266. */
  7267. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7268. /**
  7269. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7270. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7271. * @param boundingInfo the bounding info to check intersection with
  7272. * @param precise if the intersection should be done using OBB
  7273. * @returns if the bounding info intersects
  7274. */
  7275. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7276. }
  7277. }
  7278. declare module "babylonjs/Misc/smartArray" {
  7279. /**
  7280. * Defines an array and its length.
  7281. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  7282. */
  7283. export interface ISmartArrayLike<T> {
  7284. /**
  7285. * The data of the array.
  7286. */
  7287. data: Array<T>;
  7288. /**
  7289. * The active length of the array.
  7290. */
  7291. length: number;
  7292. }
  7293. /**
  7294. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  7295. */
  7296. export class SmartArray<T> implements ISmartArrayLike<T> {
  7297. /**
  7298. * The full set of data from the array.
  7299. */
  7300. data: Array<T>;
  7301. /**
  7302. * The active length of the array.
  7303. */
  7304. length: number;
  7305. protected _id: number;
  7306. /**
  7307. * Instantiates a Smart Array.
  7308. * @param capacity defines the default capacity of the array.
  7309. */
  7310. constructor(capacity: number);
  7311. /**
  7312. * Pushes a value at the end of the active data.
  7313. * @param value defines the object to push in the array.
  7314. */
  7315. push(value: T): void;
  7316. /**
  7317. * Iterates over the active data and apply the lambda to them.
  7318. * @param func defines the action to apply on each value.
  7319. */
  7320. forEach(func: (content: T) => void): void;
  7321. /**
  7322. * Sorts the full sets of data.
  7323. * @param compareFn defines the comparison function to apply.
  7324. */
  7325. sort(compareFn: (a: T, b: T) => number): void;
  7326. /**
  7327. * Resets the active data to an empty array.
  7328. */
  7329. reset(): void;
  7330. /**
  7331. * Releases all the data from the array as well as the array.
  7332. */
  7333. dispose(): void;
  7334. /**
  7335. * Concats the active data with a given array.
  7336. * @param array defines the data to concatenate with.
  7337. */
  7338. concat(array: any): void;
  7339. /**
  7340. * Returns the position of a value in the active data.
  7341. * @param value defines the value to find the index for
  7342. * @returns the index if found in the active data otherwise -1
  7343. */
  7344. indexOf(value: T): number;
  7345. /**
  7346. * Returns whether an element is part of the active data.
  7347. * @param value defines the value to look for
  7348. * @returns true if found in the active data otherwise false
  7349. */
  7350. contains(value: T): boolean;
  7351. private static _GlobalId;
  7352. }
  7353. /**
  7354. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  7355. * The data in this array can only be present once
  7356. */
  7357. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  7358. private _duplicateId;
  7359. /**
  7360. * Pushes a value at the end of the active data.
  7361. * THIS DOES NOT PREVENT DUPPLICATE DATA
  7362. * @param value defines the object to push in the array.
  7363. */
  7364. push(value: T): void;
  7365. /**
  7366. * Pushes a value at the end of the active data.
  7367. * If the data is already present, it won t be added again
  7368. * @param value defines the object to push in the array.
  7369. * @returns true if added false if it was already present
  7370. */
  7371. pushNoDuplicate(value: T): boolean;
  7372. /**
  7373. * Resets the active data to an empty array.
  7374. */
  7375. reset(): void;
  7376. /**
  7377. * Concats the active data with a given array.
  7378. * This ensures no dupplicate will be present in the result.
  7379. * @param array defines the data to concatenate with.
  7380. */
  7381. concatWithNoDuplicate(array: any): void;
  7382. }
  7383. }
  7384. declare module "babylonjs/Materials/multiMaterial" {
  7385. import { Nullable } from "babylonjs/types";
  7386. import { Scene } from "babylonjs/scene";
  7387. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7388. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  7389. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7390. import { Material } from "babylonjs/Materials/material";
  7391. /**
  7392. * A multi-material is used to apply different materials to different parts of the same object without the need of
  7393. * separate meshes. This can be use to improve performances.
  7394. * @see http://doc.babylonjs.com/how_to/multi_materials
  7395. */
  7396. export class MultiMaterial extends Material {
  7397. private _subMaterials;
  7398. /**
  7399. * Gets or Sets the list of Materials used within the multi material.
  7400. * They need to be ordered according to the submeshes order in the associated mesh
  7401. */
  7402. subMaterials: Nullable<Material>[];
  7403. /**
  7404. * Function used to align with Node.getChildren()
  7405. * @returns the list of Materials used within the multi material
  7406. */
  7407. getChildren(): Nullable<Material>[];
  7408. /**
  7409. * Instantiates a new Multi Material
  7410. * A multi-material is used to apply different materials to different parts of the same object without the need of
  7411. * separate meshes. This can be use to improve performances.
  7412. * @see http://doc.babylonjs.com/how_to/multi_materials
  7413. * @param name Define the name in the scene
  7414. * @param scene Define the scene the material belongs to
  7415. */
  7416. constructor(name: string, scene: Scene);
  7417. private _hookArray;
  7418. /**
  7419. * Get one of the submaterial by its index in the submaterials array
  7420. * @param index The index to look the sub material at
  7421. * @returns The Material if the index has been defined
  7422. */
  7423. getSubMaterial(index: number): Nullable<Material>;
  7424. /**
  7425. * Get the list of active textures for the whole sub materials list.
  7426. * @returns All the textures that will be used during the rendering
  7427. */
  7428. getActiveTextures(): BaseTexture[];
  7429. /**
  7430. * Gets the current class name of the material e.g. "MultiMaterial"
  7431. * Mainly use in serialization.
  7432. * @returns the class name
  7433. */
  7434. getClassName(): string;
  7435. /**
  7436. * Checks if the material is ready to render the requested sub mesh
  7437. * @param mesh Define the mesh the submesh belongs to
  7438. * @param subMesh Define the sub mesh to look readyness for
  7439. * @param useInstances Define whether or not the material is used with instances
  7440. * @returns true if ready, otherwise false
  7441. */
  7442. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  7443. /**
  7444. * Clones the current material and its related sub materials
  7445. * @param name Define the name of the newly cloned material
  7446. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  7447. * @returns the cloned material
  7448. */
  7449. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  7450. /**
  7451. * Serializes the materials into a JSON representation.
  7452. * @returns the JSON representation
  7453. */
  7454. serialize(): any;
  7455. /**
  7456. * Dispose the material and release its associated resources
  7457. * @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)
  7458. * @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)
  7459. * @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)
  7460. */
  7461. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  7462. /**
  7463. * Creates a MultiMaterial from parsed MultiMaterial data.
  7464. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  7465. * @param scene defines the hosting scene
  7466. * @returns a new MultiMaterial
  7467. */
  7468. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  7469. }
  7470. }
  7471. declare module "babylonjs/Loading/sceneLoaderFlags" {
  7472. /**
  7473. * Class used to represent data loading progression
  7474. */
  7475. export class SceneLoaderFlags {
  7476. private static _ForceFullSceneLoadingForIncremental;
  7477. private static _ShowLoadingScreen;
  7478. private static _CleanBoneMatrixWeights;
  7479. private static _loggingLevel;
  7480. /**
  7481. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  7482. */
  7483. static ForceFullSceneLoadingForIncremental: boolean;
  7484. /**
  7485. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  7486. */
  7487. static ShowLoadingScreen: boolean;
  7488. /**
  7489. * Defines the current logging level (while loading the scene)
  7490. * @ignorenaming
  7491. */
  7492. static loggingLevel: number;
  7493. /**
  7494. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  7495. */
  7496. static CleanBoneMatrixWeights: boolean;
  7497. }
  7498. }
  7499. declare module "babylonjs/Meshes/transformNode" {
  7500. import { DeepImmutable } from "babylonjs/types";
  7501. import { Observable } from "babylonjs/Misc/observable";
  7502. import { Nullable } from "babylonjs/types";
  7503. import { Camera } from "babylonjs/Cameras/camera";
  7504. import { Scene } from "babylonjs/scene";
  7505. import { Quaternion, Matrix, Vector3, Space } from "babylonjs/Maths/math";
  7506. import { Node } from "babylonjs/node";
  7507. import { Bone } from "babylonjs/Bones/bone";
  7508. /**
  7509. * 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.
  7510. * @see https://doc.babylonjs.com/how_to/transformnode
  7511. */
  7512. export class TransformNode extends Node {
  7513. /**
  7514. * Object will not rotate to face the camera
  7515. */
  7516. static BILLBOARDMODE_NONE: number;
  7517. /**
  7518. * Object will rotate to face the camera but only on the x axis
  7519. */
  7520. static BILLBOARDMODE_X: number;
  7521. /**
  7522. * Object will rotate to face the camera but only on the y axis
  7523. */
  7524. static BILLBOARDMODE_Y: number;
  7525. /**
  7526. * Object will rotate to face the camera but only on the z axis
  7527. */
  7528. static BILLBOARDMODE_Z: number;
  7529. /**
  7530. * Object will rotate to face the camera
  7531. */
  7532. static BILLBOARDMODE_ALL: number;
  7533. private _forward;
  7534. private _forwardInverted;
  7535. private _up;
  7536. private _right;
  7537. private _rightInverted;
  7538. private _usePivotMatrix;
  7539. private _position;
  7540. private _rotation;
  7541. private _rotationQuaternion;
  7542. protected _scaling: Vector3;
  7543. protected _isDirty: boolean;
  7544. private _transformToBoneReferal;
  7545. /**
  7546. * Set the billboard mode. Default is 0.
  7547. *
  7548. * | Value | Type | Description |
  7549. * | --- | --- | --- |
  7550. * | 0 | BILLBOARDMODE_NONE | |
  7551. * | 1 | BILLBOARDMODE_X | |
  7552. * | 2 | BILLBOARDMODE_Y | |
  7553. * | 4 | BILLBOARDMODE_Z | |
  7554. * | 7 | BILLBOARDMODE_ALL | |
  7555. *
  7556. */
  7557. billboardMode: number;
  7558. /**
  7559. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  7560. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  7561. */
  7562. preserveParentRotationForBillboard: boolean;
  7563. /**
  7564. * 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
  7565. */
  7566. scalingDeterminant: number;
  7567. /**
  7568. * Sets the distance of the object to max, often used by skybox
  7569. */
  7570. infiniteDistance: boolean;
  7571. /**
  7572. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  7573. * By default the system will update normals to compensate
  7574. */
  7575. ignoreNonUniformScaling: boolean;
  7576. /** @hidden */
  7577. _poseMatrix: Matrix;
  7578. /** @hidden */
  7579. _localMatrix: Matrix;
  7580. private _absolutePosition;
  7581. private _pivotMatrix;
  7582. private _pivotMatrixInverse;
  7583. protected _postMultiplyPivotMatrix: boolean;
  7584. protected _isWorldMatrixFrozen: boolean;
  7585. /** @hidden */
  7586. _indexInSceneTransformNodesArray: number;
  7587. /**
  7588. * An event triggered after the world matrix is updated
  7589. */
  7590. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  7591. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  7592. /**
  7593. * Gets a string identifying the name of the class
  7594. * @returns "TransformNode" string
  7595. */
  7596. getClassName(): string;
  7597. /**
  7598. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  7599. */
  7600. position: Vector3;
  7601. /**
  7602. * 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)).
  7603. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  7604. */
  7605. rotation: Vector3;
  7606. /**
  7607. * 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)).
  7608. */
  7609. scaling: Vector3;
  7610. /**
  7611. * 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).
  7612. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  7613. */
  7614. rotationQuaternion: Nullable<Quaternion>;
  7615. /**
  7616. * The forward direction of that transform in world space.
  7617. */
  7618. readonly forward: Vector3;
  7619. /**
  7620. * The up direction of that transform in world space.
  7621. */
  7622. readonly up: Vector3;
  7623. /**
  7624. * The right direction of that transform in world space.
  7625. */
  7626. readonly right: Vector3;
  7627. /**
  7628. * Copies the parameter passed Matrix into the mesh Pose matrix.
  7629. * @param matrix the matrix to copy the pose from
  7630. * @returns this TransformNode.
  7631. */
  7632. updatePoseMatrix(matrix: Matrix): TransformNode;
  7633. /**
  7634. * Returns the mesh Pose matrix.
  7635. * @returns the pose matrix
  7636. */
  7637. getPoseMatrix(): Matrix;
  7638. /** @hidden */
  7639. _isSynchronized(): boolean;
  7640. /** @hidden */
  7641. _initCache(): void;
  7642. /**
  7643. * Flag the transform node as dirty (Forcing it to update everything)
  7644. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  7645. * @returns this transform node
  7646. */
  7647. markAsDirty(property: string): TransformNode;
  7648. /**
  7649. * Returns the current mesh absolute position.
  7650. * Returns a Vector3.
  7651. */
  7652. readonly absolutePosition: Vector3;
  7653. /**
  7654. * Sets a new matrix to apply before all other transformation
  7655. * @param matrix defines the transform matrix
  7656. * @returns the current TransformNode
  7657. */
  7658. setPreTransformMatrix(matrix: Matrix): TransformNode;
  7659. /**
  7660. * Sets a new pivot matrix to the current node
  7661. * @param matrix defines the new pivot matrix to use
  7662. * @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
  7663. * @returns the current TransformNode
  7664. */
  7665. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  7666. /**
  7667. * Returns the mesh pivot matrix.
  7668. * Default : Identity.
  7669. * @returns the matrix
  7670. */
  7671. getPivotMatrix(): Matrix;
  7672. /**
  7673. * Prevents the World matrix to be computed any longer.
  7674. * @returns the TransformNode.
  7675. */
  7676. freezeWorldMatrix(): TransformNode;
  7677. /**
  7678. * Allows back the World matrix computation.
  7679. * @returns the TransformNode.
  7680. */
  7681. unfreezeWorldMatrix(): this;
  7682. /**
  7683. * True if the World matrix has been frozen.
  7684. */
  7685. readonly isWorldMatrixFrozen: boolean;
  7686. /**
  7687. * Retuns the mesh absolute position in the World.
  7688. * @returns a Vector3.
  7689. */
  7690. getAbsolutePosition(): Vector3;
  7691. /**
  7692. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  7693. * @param absolutePosition the absolute position to set
  7694. * @returns the TransformNode.
  7695. */
  7696. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  7697. /**
  7698. * Sets the mesh position in its local space.
  7699. * @param vector3 the position to set in localspace
  7700. * @returns the TransformNode.
  7701. */
  7702. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  7703. /**
  7704. * Returns the mesh position in the local space from the current World matrix values.
  7705. * @returns a new Vector3.
  7706. */
  7707. getPositionExpressedInLocalSpace(): Vector3;
  7708. /**
  7709. * Translates the mesh along the passed Vector3 in its local space.
  7710. * @param vector3 the distance to translate in localspace
  7711. * @returns the TransformNode.
  7712. */
  7713. locallyTranslate(vector3: Vector3): TransformNode;
  7714. private static _lookAtVectorCache;
  7715. /**
  7716. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  7717. * @param targetPoint the position (must be in same space as current mesh) to look at
  7718. * @param yawCor optional yaw (y-axis) correction in radians
  7719. * @param pitchCor optional pitch (x-axis) correction in radians
  7720. * @param rollCor optional roll (z-axis) correction in radians
  7721. * @param space the choosen space of the target
  7722. * @returns the TransformNode.
  7723. */
  7724. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  7725. /**
  7726. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  7727. * This Vector3 is expressed in the World space.
  7728. * @param localAxis axis to rotate
  7729. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  7730. */
  7731. getDirection(localAxis: Vector3): Vector3;
  7732. /**
  7733. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  7734. * localAxis is expressed in the mesh local space.
  7735. * result is computed in the Wordl space from the mesh World matrix.
  7736. * @param localAxis axis to rotate
  7737. * @param result the resulting transformnode
  7738. * @returns this TransformNode.
  7739. */
  7740. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  7741. /**
  7742. * Sets this transform node rotation to the given local axis.
  7743. * @param localAxis the axis in local space
  7744. * @param yawCor optional yaw (y-axis) correction in radians
  7745. * @param pitchCor optional pitch (x-axis) correction in radians
  7746. * @param rollCor optional roll (z-axis) correction in radians
  7747. * @returns this TransformNode
  7748. */
  7749. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  7750. /**
  7751. * Sets a new pivot point to the current node
  7752. * @param point defines the new pivot point to use
  7753. * @param space defines if the point is in world or local space (local by default)
  7754. * @returns the current TransformNode
  7755. */
  7756. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  7757. /**
  7758. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  7759. * @returns the pivot point
  7760. */
  7761. getPivotPoint(): Vector3;
  7762. /**
  7763. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  7764. * @param result the vector3 to store the result
  7765. * @returns this TransformNode.
  7766. */
  7767. getPivotPointToRef(result: Vector3): TransformNode;
  7768. /**
  7769. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  7770. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  7771. */
  7772. getAbsolutePivotPoint(): Vector3;
  7773. /**
  7774. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  7775. * @param result vector3 to store the result
  7776. * @returns this TransformNode.
  7777. */
  7778. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  7779. /**
  7780. * Defines the passed node as the parent of the current node.
  7781. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  7782. * @see https://doc.babylonjs.com/how_to/parenting
  7783. * @param node the node ot set as the parent
  7784. * @returns this TransformNode.
  7785. */
  7786. setParent(node: Nullable<Node>): TransformNode;
  7787. private _nonUniformScaling;
  7788. /**
  7789. * True if the scaling property of this object is non uniform eg. (1,2,1)
  7790. */
  7791. readonly nonUniformScaling: boolean;
  7792. /** @hidden */
  7793. _updateNonUniformScalingState(value: boolean): boolean;
  7794. /**
  7795. * Attach the current TransformNode to another TransformNode associated with a bone
  7796. * @param bone Bone affecting the TransformNode
  7797. * @param affectedTransformNode TransformNode associated with the bone
  7798. * @returns this object
  7799. */
  7800. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  7801. /**
  7802. * Detach the transform node if its associated with a bone
  7803. * @returns this object
  7804. */
  7805. detachFromBone(): TransformNode;
  7806. private static _rotationAxisCache;
  7807. /**
  7808. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  7809. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  7810. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  7811. * The passed axis is also normalized.
  7812. * @param axis the axis to rotate around
  7813. * @param amount the amount to rotate in radians
  7814. * @param space Space to rotate in (Default: local)
  7815. * @returns the TransformNode.
  7816. */
  7817. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  7818. /**
  7819. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  7820. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  7821. * The passed axis is also normalized. .
  7822. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  7823. * @param point the point to rotate around
  7824. * @param axis the axis to rotate around
  7825. * @param amount the amount to rotate in radians
  7826. * @returns the TransformNode
  7827. */
  7828. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  7829. /**
  7830. * Translates the mesh along the axis vector for the passed distance in the given space.
  7831. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  7832. * @param axis the axis to translate in
  7833. * @param distance the distance to translate
  7834. * @param space Space to rotate in (Default: local)
  7835. * @returns the TransformNode.
  7836. */
  7837. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  7838. /**
  7839. * Adds a rotation step to the mesh current rotation.
  7840. * x, y, z are Euler angles expressed in radians.
  7841. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  7842. * This means this rotation is made in the mesh local space only.
  7843. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  7844. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  7845. * ```javascript
  7846. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  7847. * ```
  7848. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  7849. * 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.
  7850. * @param x Rotation to add
  7851. * @param y Rotation to add
  7852. * @param z Rotation to add
  7853. * @returns the TransformNode.
  7854. */
  7855. addRotation(x: number, y: number, z: number): TransformNode;
  7856. /**
  7857. * @hidden
  7858. */
  7859. protected _getEffectiveParent(): Nullable<Node>;
  7860. /**
  7861. * Computes the world matrix of the node
  7862. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  7863. * @returns the world matrix
  7864. */
  7865. computeWorldMatrix(force?: boolean): Matrix;
  7866. protected _afterComputeWorldMatrix(): void;
  7867. /**
  7868. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  7869. * @param func callback function to add
  7870. *
  7871. * @returns the TransformNode.
  7872. */
  7873. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  7874. /**
  7875. * Removes a registered callback function.
  7876. * @param func callback function to remove
  7877. * @returns the TransformNode.
  7878. */
  7879. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  7880. /**
  7881. * Gets the position of the current mesh in camera space
  7882. * @param camera defines the camera to use
  7883. * @returns a position
  7884. */
  7885. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  7886. /**
  7887. * Returns the distance from the mesh to the active camera
  7888. * @param camera defines the camera to use
  7889. * @returns the distance
  7890. */
  7891. getDistanceToCamera(camera?: Nullable<Camera>): number;
  7892. /**
  7893. * Clone the current transform node
  7894. * @param name Name of the new clone
  7895. * @param newParent New parent for the clone
  7896. * @param doNotCloneChildren Do not clone children hierarchy
  7897. * @returns the new transform node
  7898. */
  7899. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  7900. /**
  7901. * Serializes the objects information.
  7902. * @param currentSerializationObject defines the object to serialize in
  7903. * @returns the serialized object
  7904. */
  7905. serialize(currentSerializationObject?: any): any;
  7906. /**
  7907. * Returns a new TransformNode object parsed from the source provided.
  7908. * @param parsedTransformNode is the source.
  7909. * @param scene the scne the object belongs to
  7910. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  7911. * @returns a new TransformNode object parsed from the source provided.
  7912. */
  7913. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  7914. /**
  7915. * Get all child-transformNodes of this node
  7916. * @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
  7917. * @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
  7918. * @returns an array of TransformNode
  7919. */
  7920. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  7921. /**
  7922. * Releases resources associated with this transform node.
  7923. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  7924. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  7925. */
  7926. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  7927. }
  7928. }
  7929. declare module "babylonjs/Animations/animationPropertiesOverride" {
  7930. /**
  7931. * Class used to override all child animations of a given target
  7932. */
  7933. export class AnimationPropertiesOverride {
  7934. /**
  7935. * Gets or sets a value indicating if animation blending must be used
  7936. */
  7937. enableBlending: boolean;
  7938. /**
  7939. * Gets or sets the blending speed to use when enableBlending is true
  7940. */
  7941. blendingSpeed: number;
  7942. /**
  7943. * Gets or sets the default loop mode to use
  7944. */
  7945. loopMode: number;
  7946. }
  7947. }
  7948. declare module "babylonjs/Bones/bone" {
  7949. import { Skeleton } from "babylonjs/Bones/skeleton";
  7950. import { Vector3, Quaternion, Matrix, Space } from "babylonjs/Maths/math";
  7951. import { Nullable } from "babylonjs/types";
  7952. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7953. import { TransformNode } from "babylonjs/Meshes/transformNode";
  7954. import { Node } from "babylonjs/node";
  7955. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  7956. /**
  7957. * Class used to store bone information
  7958. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  7959. */
  7960. export class Bone extends Node {
  7961. /**
  7962. * defines the bone name
  7963. */
  7964. name: string;
  7965. private static _tmpVecs;
  7966. private static _tmpQuat;
  7967. private static _tmpMats;
  7968. /**
  7969. * Gets the list of child bones
  7970. */
  7971. children: Bone[];
  7972. /** Gets the animations associated with this bone */
  7973. animations: import("babylonjs/Animations/animation").Animation[];
  7974. /**
  7975. * Gets or sets bone length
  7976. */
  7977. length: number;
  7978. /**
  7979. * @hidden Internal only
  7980. * Set this value to map this bone to a different index in the transform matrices
  7981. * Set this value to -1 to exclude the bone from the transform matrices
  7982. */
  7983. _index: Nullable<number>;
  7984. private _skeleton;
  7985. private _localMatrix;
  7986. private _restPose;
  7987. private _baseMatrix;
  7988. private _absoluteTransform;
  7989. private _invertedAbsoluteTransform;
  7990. private _parent;
  7991. private _scalingDeterminant;
  7992. private _worldTransform;
  7993. private _localScaling;
  7994. private _localRotation;
  7995. private _localPosition;
  7996. private _needToDecompose;
  7997. private _needToCompose;
  7998. /** @hidden */
  7999. _linkedTransformNode: Nullable<TransformNode>;
  8000. /** @hidden */
  8001. /** @hidden */
  8002. _matrix: Matrix;
  8003. /**
  8004. * Create a new bone
  8005. * @param name defines the bone name
  8006. * @param skeleton defines the parent skeleton
  8007. * @param parentBone defines the parent (can be null if the bone is the root)
  8008. * @param localMatrix defines the local matrix
  8009. * @param restPose defines the rest pose matrix
  8010. * @param baseMatrix defines the base matrix
  8011. * @param index defines index of the bone in the hiearchy
  8012. */
  8013. constructor(
  8014. /**
  8015. * defines the bone name
  8016. */
  8017. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  8018. /**
  8019. * Gets the current object class name.
  8020. * @return the class name
  8021. */
  8022. getClassName(): string;
  8023. /**
  8024. * Gets the parent skeleton
  8025. * @returns a skeleton
  8026. */
  8027. getSkeleton(): Skeleton;
  8028. /**
  8029. * Gets parent bone
  8030. * @returns a bone or null if the bone is the root of the bone hierarchy
  8031. */
  8032. getParent(): Nullable<Bone>;
  8033. /**
  8034. * Returns an array containing the root bones
  8035. * @returns an array containing the root bones
  8036. */
  8037. getChildren(): Array<Bone>;
  8038. /**
  8039. * Sets the parent bone
  8040. * @param parent defines the parent (can be null if the bone is the root)
  8041. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  8042. */
  8043. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  8044. /**
  8045. * Gets the local matrix
  8046. * @returns a matrix
  8047. */
  8048. getLocalMatrix(): Matrix;
  8049. /**
  8050. * Gets the base matrix (initial matrix which remains unchanged)
  8051. * @returns a matrix
  8052. */
  8053. getBaseMatrix(): Matrix;
  8054. /**
  8055. * Gets the rest pose matrix
  8056. * @returns a matrix
  8057. */
  8058. getRestPose(): Matrix;
  8059. /**
  8060. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  8061. */
  8062. getWorldMatrix(): Matrix;
  8063. /**
  8064. * Sets the local matrix to rest pose matrix
  8065. */
  8066. returnToRest(): void;
  8067. /**
  8068. * Gets the inverse of the absolute transform matrix.
  8069. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  8070. * @returns a matrix
  8071. */
  8072. getInvertedAbsoluteTransform(): Matrix;
  8073. /**
  8074. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  8075. * @returns a matrix
  8076. */
  8077. getAbsoluteTransform(): Matrix;
  8078. /**
  8079. * Links with the given transform node.
  8080. * The local matrix of this bone is copied from the transform node every frame.
  8081. * @param transformNode defines the transform node to link to
  8082. */
  8083. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  8084. /** Gets or sets current position (in local space) */
  8085. position: Vector3;
  8086. /** Gets or sets current rotation (in local space) */
  8087. rotation: Vector3;
  8088. /** Gets or sets current rotation quaternion (in local space) */
  8089. rotationQuaternion: Quaternion;
  8090. /** Gets or sets current scaling (in local space) */
  8091. scaling: Vector3;
  8092. /**
  8093. * Gets the animation properties override
  8094. */
  8095. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  8096. private _decompose;
  8097. private _compose;
  8098. /**
  8099. * Update the base and local matrices
  8100. * @param matrix defines the new base or local matrix
  8101. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  8102. * @param updateLocalMatrix defines if the local matrix should be updated
  8103. */
  8104. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  8105. /** @hidden */
  8106. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  8107. /**
  8108. * Flag the bone as dirty (Forcing it to update everything)
  8109. */
  8110. markAsDirty(): void;
  8111. private _markAsDirtyAndCompose;
  8112. private _markAsDirtyAndDecompose;
  8113. /**
  8114. * Translate the bone in local or world space
  8115. * @param vec The amount to translate the bone
  8116. * @param space The space that the translation is in
  8117. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8118. */
  8119. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  8120. /**
  8121. * Set the postion of the bone in local or world space
  8122. * @param position The position to set the bone
  8123. * @param space The space that the position is in
  8124. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8125. */
  8126. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  8127. /**
  8128. * Set the absolute position of the bone (world space)
  8129. * @param position The position to set the bone
  8130. * @param mesh The mesh that this bone is attached to
  8131. */
  8132. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  8133. /**
  8134. * Scale the bone on the x, y and z axes (in local space)
  8135. * @param x The amount to scale the bone on the x axis
  8136. * @param y The amount to scale the bone on the y axis
  8137. * @param z The amount to scale the bone on the z axis
  8138. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  8139. */
  8140. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  8141. /**
  8142. * Set the bone scaling in local space
  8143. * @param scale defines the scaling vector
  8144. */
  8145. setScale(scale: Vector3): void;
  8146. /**
  8147. * Gets the current scaling in local space
  8148. * @returns the current scaling vector
  8149. */
  8150. getScale(): Vector3;
  8151. /**
  8152. * Gets the current scaling in local space and stores it in a target vector
  8153. * @param result defines the target vector
  8154. */
  8155. getScaleToRef(result: Vector3): void;
  8156. /**
  8157. * Set the yaw, pitch, and roll of the bone in local or world space
  8158. * @param yaw The rotation of the bone on the y axis
  8159. * @param pitch The rotation of the bone on the x axis
  8160. * @param roll The rotation of the bone on the z axis
  8161. * @param space The space that the axes of rotation are in
  8162. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8163. */
  8164. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  8165. /**
  8166. * Add a rotation to the bone on an axis in local or world space
  8167. * @param axis The axis to rotate the bone on
  8168. * @param amount The amount to rotate the bone
  8169. * @param space The space that the axis is in
  8170. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8171. */
  8172. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  8173. /**
  8174. * Set the rotation of the bone to a particular axis angle in local or world space
  8175. * @param axis The axis to rotate the bone on
  8176. * @param angle The angle that the bone should be rotated to
  8177. * @param space The space that the axis is in
  8178. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8179. */
  8180. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  8181. /**
  8182. * Set the euler rotation of the bone in local of world space
  8183. * @param rotation The euler rotation that the bone should be set to
  8184. * @param space The space that the rotation is in
  8185. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8186. */
  8187. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  8188. /**
  8189. * Set the quaternion rotation of the bone in local of world space
  8190. * @param quat The quaternion rotation that the bone should be set to
  8191. * @param space The space that the rotation is in
  8192. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8193. */
  8194. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  8195. /**
  8196. * Set the rotation matrix of the bone in local of world space
  8197. * @param rotMat The rotation matrix that the bone should be set to
  8198. * @param space The space that the rotation is in
  8199. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8200. */
  8201. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  8202. private _rotateWithMatrix;
  8203. private _getNegativeRotationToRef;
  8204. /**
  8205. * Get the position of the bone in local or world space
  8206. * @param space The space that the returned position is in
  8207. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8208. * @returns The position of the bone
  8209. */
  8210. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  8211. /**
  8212. * Copy the position of the bone to a vector3 in local or world space
  8213. * @param space The space that the returned position is in
  8214. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8215. * @param result The vector3 to copy the position to
  8216. */
  8217. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  8218. /**
  8219. * Get the absolute position of the bone (world space)
  8220. * @param mesh The mesh that this bone is attached to
  8221. * @returns The absolute position of the bone
  8222. */
  8223. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  8224. /**
  8225. * Copy the absolute position of the bone (world space) to the result param
  8226. * @param mesh The mesh that this bone is attached to
  8227. * @param result The vector3 to copy the absolute position to
  8228. */
  8229. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  8230. /**
  8231. * Compute the absolute transforms of this bone and its children
  8232. */
  8233. computeAbsoluteTransforms(): void;
  8234. /**
  8235. * Get the world direction from an axis that is in the local space of the bone
  8236. * @param localAxis The local direction that is used to compute the world direction
  8237. * @param mesh The mesh that this bone is attached to
  8238. * @returns The world direction
  8239. */
  8240. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  8241. /**
  8242. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  8243. * @param localAxis The local direction that is used to compute the world direction
  8244. * @param mesh The mesh that this bone is attached to
  8245. * @param result The vector3 that the world direction will be copied to
  8246. */
  8247. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8248. /**
  8249. * Get the euler rotation of the bone in local or world space
  8250. * @param space The space that the rotation should be in
  8251. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8252. * @returns The euler rotation
  8253. */
  8254. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  8255. /**
  8256. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  8257. * @param space The space that the rotation should be in
  8258. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8259. * @param result The vector3 that the rotation should be copied to
  8260. */
  8261. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8262. /**
  8263. * Get the quaternion rotation of the bone in either local or world space
  8264. * @param space The space that the rotation should be in
  8265. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8266. * @returns The quaternion rotation
  8267. */
  8268. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  8269. /**
  8270. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  8271. * @param space The space that the rotation should be in
  8272. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8273. * @param result The quaternion that the rotation should be copied to
  8274. */
  8275. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  8276. /**
  8277. * Get the rotation matrix of the bone in local or world space
  8278. * @param space The space that the rotation should be in
  8279. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8280. * @returns The rotation matrix
  8281. */
  8282. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  8283. /**
  8284. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  8285. * @param space The space that the rotation should be in
  8286. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8287. * @param result The quaternion that the rotation should be copied to
  8288. */
  8289. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  8290. /**
  8291. * Get the world position of a point that is in the local space of the bone
  8292. * @param position The local position
  8293. * @param mesh The mesh that this bone is attached to
  8294. * @returns The world position
  8295. */
  8296. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  8297. /**
  8298. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  8299. * @param position The local position
  8300. * @param mesh The mesh that this bone is attached to
  8301. * @param result The vector3 that the world position should be copied to
  8302. */
  8303. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8304. /**
  8305. * Get the local position of a point that is in world space
  8306. * @param position The world position
  8307. * @param mesh The mesh that this bone is attached to
  8308. * @returns The local position
  8309. */
  8310. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  8311. /**
  8312. * Get the local position of a point that is in world space and copy it to the result param
  8313. * @param position The world position
  8314. * @param mesh The mesh that this bone is attached to
  8315. * @param result The vector3 that the local position should be copied to
  8316. */
  8317. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8318. }
  8319. }
  8320. declare module "babylonjs/Misc/iInspectable" {
  8321. /**
  8322. * Enum that determines the text-wrapping mode to use.
  8323. */
  8324. export enum InspectableType {
  8325. /**
  8326. * Checkbox for booleans
  8327. */
  8328. Checkbox = 0,
  8329. /**
  8330. * Sliders for numbers
  8331. */
  8332. Slider = 1,
  8333. /**
  8334. * Vector3
  8335. */
  8336. Vector3 = 2,
  8337. /**
  8338. * Quaternions
  8339. */
  8340. Quaternion = 3,
  8341. /**
  8342. * Color3
  8343. */
  8344. Color3 = 4
  8345. }
  8346. /**
  8347. * Interface used to define custom inspectable properties.
  8348. * This interface is used by the inspector to display custom property grids
  8349. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  8350. */
  8351. export interface IInspectable {
  8352. /**
  8353. * Gets the label to display
  8354. */
  8355. label: string;
  8356. /**
  8357. * Gets the name of the property to edit
  8358. */
  8359. propertyName: string;
  8360. /**
  8361. * Gets the type of the editor to use
  8362. */
  8363. type: InspectableType;
  8364. /**
  8365. * Gets the minimum value of the property when using in "slider" mode
  8366. */
  8367. min?: number;
  8368. /**
  8369. * Gets the maximum value of the property when using in "slider" mode
  8370. */
  8371. max?: number;
  8372. /**
  8373. * Gets the setp to use when using in "slider" mode
  8374. */
  8375. step?: number;
  8376. }
  8377. }
  8378. declare module "babylonjs/Materials/Textures/cubeTexture" {
  8379. import { Nullable } from "babylonjs/types";
  8380. import { Scene } from "babylonjs/scene";
  8381. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  8382. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8383. /**
  8384. * Class for creating a cube texture
  8385. */
  8386. export class CubeTexture extends BaseTexture {
  8387. private _delayedOnLoad;
  8388. /**
  8389. * The url of the texture
  8390. */
  8391. url: string;
  8392. /**
  8393. * Gets or sets the center of the bounding box associated with the cube texture.
  8394. * It must define where the camera used to render the texture was set
  8395. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  8396. */
  8397. boundingBoxPosition: Vector3;
  8398. private _boundingBoxSize;
  8399. /**
  8400. * Gets or sets the size of the bounding box associated with the cube texture
  8401. * When defined, the cubemap will switch to local mode
  8402. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  8403. * @example https://www.babylonjs-playground.com/#RNASML
  8404. */
  8405. /**
  8406. * Returns the bounding box size
  8407. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  8408. */
  8409. boundingBoxSize: Vector3;
  8410. protected _rotationY: number;
  8411. /**
  8412. * Sets texture matrix rotation angle around Y axis in radians.
  8413. */
  8414. /**
  8415. * Gets texture matrix rotation angle around Y axis radians.
  8416. */
  8417. rotationY: number;
  8418. /**
  8419. * Are mip maps generated for this texture or not.
  8420. */
  8421. readonly noMipmap: boolean;
  8422. private _noMipmap;
  8423. private _files;
  8424. private _extensions;
  8425. private _textureMatrix;
  8426. private _format;
  8427. private _createPolynomials;
  8428. /** @hidden */
  8429. _prefiltered: boolean;
  8430. /**
  8431. * Creates a cube texture from an array of image urls
  8432. * @param files defines an array of image urls
  8433. * @param scene defines the hosting scene
  8434. * @param noMipmap specifies if mip maps are not used
  8435. * @returns a cube texture
  8436. */
  8437. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  8438. /**
  8439. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  8440. * @param url defines the url of the prefiltered texture
  8441. * @param scene defines the scene the texture is attached to
  8442. * @param forcedExtension defines the extension of the file if different from the url
  8443. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  8444. * @return the prefiltered texture
  8445. */
  8446. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  8447. /**
  8448. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  8449. * as prefiltered data.
  8450. * @param rootUrl defines the url of the texture or the root name of the six images
  8451. * @param scene defines the scene the texture is attached to
  8452. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  8453. * @param noMipmap defines if mipmaps should be created or not
  8454. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  8455. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  8456. * @param onError defines a callback triggered in case of error during load
  8457. * @param format defines the internal format to use for the texture once loaded
  8458. * @param prefiltered defines whether or not the texture is created from prefiltered data
  8459. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  8460. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  8461. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  8462. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  8463. * @return the cube texture
  8464. */
  8465. 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);
  8466. /**
  8467. * Get the current class name of the texture useful for serialization or dynamic coding.
  8468. * @returns "CubeTexture"
  8469. */
  8470. getClassName(): string;
  8471. /**
  8472. * Update the url (and optional buffer) of this texture if url was null during construction.
  8473. * @param url the url of the texture
  8474. * @param forcedExtension defines the extension to use
  8475. * @param onLoad callback called when the texture is loaded (defaults to null)
  8476. */
  8477. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  8478. /**
  8479. * Delays loading of the cube texture
  8480. * @param forcedExtension defines the extension to use
  8481. */
  8482. delayLoad(forcedExtension?: string): void;
  8483. /**
  8484. * Returns the reflection texture matrix
  8485. * @returns the reflection texture matrix
  8486. */
  8487. getReflectionTextureMatrix(): Matrix;
  8488. /**
  8489. * Sets the reflection texture matrix
  8490. * @param value Reflection texture matrix
  8491. */
  8492. setReflectionTextureMatrix(value: Matrix): void;
  8493. /**
  8494. * Parses text to create a cube texture
  8495. * @param parsedTexture define the serialized text to read from
  8496. * @param scene defines the hosting scene
  8497. * @param rootUrl defines the root url of the cube texture
  8498. * @returns a cube texture
  8499. */
  8500. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  8501. /**
  8502. * Makes a clone, or deep copy, of the cube texture
  8503. * @returns a new cube texture
  8504. */
  8505. clone(): CubeTexture;
  8506. }
  8507. }
  8508. declare module "babylonjs/Shaders/postprocess.vertex" {
  8509. /** @hidden */
  8510. export var postprocessVertexShader: {
  8511. name: string;
  8512. shader: string;
  8513. };
  8514. }
  8515. declare module "babylonjs/Cameras/targetCamera" {
  8516. import { Nullable } from "babylonjs/types";
  8517. import { Camera } from "babylonjs/Cameras/camera";
  8518. import { Scene } from "babylonjs/scene";
  8519. import { Quaternion, Matrix, Vector3, Vector2 } from "babylonjs/Maths/math";
  8520. /**
  8521. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8522. * This is the base of the follow, arc rotate cameras and Free camera
  8523. * @see http://doc.babylonjs.com/features/cameras
  8524. */
  8525. export class TargetCamera extends Camera {
  8526. private static _RigCamTransformMatrix;
  8527. private static _TargetTransformMatrix;
  8528. private static _TargetFocalPoint;
  8529. /**
  8530. * Define the current direction the camera is moving to
  8531. */
  8532. cameraDirection: Vector3;
  8533. /**
  8534. * Define the current rotation the camera is rotating to
  8535. */
  8536. cameraRotation: Vector2;
  8537. /**
  8538. * When set, the up vector of the camera will be updated by the rotation of the camera
  8539. */
  8540. updateUpVectorFromRotation: boolean;
  8541. private _tmpQuaternion;
  8542. /**
  8543. * Define the current rotation of the camera
  8544. */
  8545. rotation: Vector3;
  8546. /**
  8547. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8548. */
  8549. rotationQuaternion: Quaternion;
  8550. /**
  8551. * Define the current speed of the camera
  8552. */
  8553. speed: number;
  8554. /**
  8555. * Add cconstraint to the camera to prevent it to move freely in all directions and
  8556. * around all axis.
  8557. */
  8558. noRotationConstraint: boolean;
  8559. /**
  8560. * Define the current target of the camera as an object or a position.
  8561. */
  8562. lockedTarget: any;
  8563. /** @hidden */
  8564. _currentTarget: Vector3;
  8565. /** @hidden */
  8566. _initialFocalDistance: number;
  8567. /** @hidden */
  8568. _viewMatrix: Matrix;
  8569. /** @hidden */
  8570. _camMatrix: Matrix;
  8571. /** @hidden */
  8572. _cameraTransformMatrix: Matrix;
  8573. /** @hidden */
  8574. _cameraRotationMatrix: Matrix;
  8575. /** @hidden */
  8576. _referencePoint: Vector3;
  8577. /** @hidden */
  8578. _transformedReferencePoint: Vector3;
  8579. protected _globalCurrentTarget: Vector3;
  8580. protected _globalCurrentUpVector: Vector3;
  8581. /** @hidden */
  8582. _reset: () => void;
  8583. private _defaultUp;
  8584. /**
  8585. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  8586. * This is the base of the follow, arc rotate cameras and Free camera
  8587. * @see http://doc.babylonjs.com/features/cameras
  8588. * @param name Defines the name of the camera in the scene
  8589. * @param position Defines the start position of the camera in the scene
  8590. * @param scene Defines the scene the camera belongs to
  8591. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8592. */
  8593. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8594. /**
  8595. * Gets the position in front of the camera at a given distance.
  8596. * @param distance The distance from the camera we want the position to be
  8597. * @returns the position
  8598. */
  8599. getFrontPosition(distance: number): Vector3;
  8600. /** @hidden */
  8601. _getLockedTargetPosition(): Nullable<Vector3>;
  8602. private _storedPosition;
  8603. private _storedRotation;
  8604. private _storedRotationQuaternion;
  8605. /**
  8606. * Store current camera state of the camera (fov, position, rotation, etc..)
  8607. * @returns the camera
  8608. */
  8609. storeState(): Camera;
  8610. /**
  8611. * Restored camera state. You must call storeState() first
  8612. * @returns whether it was successful or not
  8613. * @hidden
  8614. */
  8615. _restoreStateValues(): boolean;
  8616. /** @hidden */
  8617. _initCache(): void;
  8618. /** @hidden */
  8619. _updateCache(ignoreParentClass?: boolean): void;
  8620. /** @hidden */
  8621. _isSynchronizedViewMatrix(): boolean;
  8622. /** @hidden */
  8623. _computeLocalCameraSpeed(): number;
  8624. /**
  8625. * Defines the target the camera should look at.
  8626. * This will automatically adapt alpha beta and radius to fit within the new target.
  8627. * @param target Defines the new target as a Vector or a mesh
  8628. */
  8629. setTarget(target: Vector3): void;
  8630. /**
  8631. * Return the current target position of the camera. This value is expressed in local space.
  8632. * @returns the target position
  8633. */
  8634. getTarget(): Vector3;
  8635. /** @hidden */
  8636. _decideIfNeedsToMove(): boolean;
  8637. /** @hidden */
  8638. _updatePosition(): void;
  8639. /** @hidden */
  8640. _checkInputs(): void;
  8641. protected _updateCameraRotationMatrix(): void;
  8642. /**
  8643. * 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)
  8644. * @returns the current camera
  8645. */
  8646. private _rotateUpVectorWithCameraRotationMatrix;
  8647. private _cachedRotationZ;
  8648. private _cachedQuaternionRotationZ;
  8649. /** @hidden */
  8650. _getViewMatrix(): Matrix;
  8651. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8652. /**
  8653. * @hidden
  8654. */
  8655. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8656. /**
  8657. * @hidden
  8658. */
  8659. _updateRigCameras(): void;
  8660. private _getRigCamPositionAndTarget;
  8661. /**
  8662. * Gets the current object class name.
  8663. * @return the class name
  8664. */
  8665. getClassName(): string;
  8666. }
  8667. }
  8668. declare module "babylonjs/Cameras/cameraInputsManager" {
  8669. import { Nullable } from "babylonjs/types";
  8670. import { Camera } from "babylonjs/Cameras/camera";
  8671. /**
  8672. * @ignore
  8673. * This is a list of all the different input types that are available in the application.
  8674. * Fo instance: ArcRotateCameraGamepadInput...
  8675. */
  8676. export var CameraInputTypes: {};
  8677. /**
  8678. * This is the contract to implement in order to create a new input class.
  8679. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  8680. */
  8681. export interface ICameraInput<TCamera extends Camera> {
  8682. /**
  8683. * Defines the camera the input is attached to.
  8684. */
  8685. camera: Nullable<TCamera>;
  8686. /**
  8687. * Gets the class name of the current intput.
  8688. * @returns the class name
  8689. */
  8690. getClassName(): string;
  8691. /**
  8692. * Get the friendly name associated with the input class.
  8693. * @returns the input friendly name
  8694. */
  8695. getSimpleName(): string;
  8696. /**
  8697. * Attach the input controls to a specific dom element to get the input from.
  8698. * @param element Defines the element the controls should be listened from
  8699. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8700. */
  8701. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8702. /**
  8703. * Detach the current controls from the specified dom element.
  8704. * @param element Defines the element to stop listening the inputs from
  8705. */
  8706. detachControl(element: Nullable<HTMLElement>): void;
  8707. /**
  8708. * Update the current camera state depending on the inputs that have been used this frame.
  8709. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8710. */
  8711. checkInputs?: () => void;
  8712. }
  8713. /**
  8714. * Represents a map of input types to input instance or input index to input instance.
  8715. */
  8716. export interface CameraInputsMap<TCamera extends Camera> {
  8717. /**
  8718. * Accessor to the input by input type.
  8719. */
  8720. [name: string]: ICameraInput<TCamera>;
  8721. /**
  8722. * Accessor to the input by input index.
  8723. */
  8724. [idx: number]: ICameraInput<TCamera>;
  8725. }
  8726. /**
  8727. * This represents the input manager used within a camera.
  8728. * It helps dealing with all the different kind of input attached to a camera.
  8729. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8730. */
  8731. export class CameraInputsManager<TCamera extends Camera> {
  8732. /**
  8733. * Defines the list of inputs attahed to the camera.
  8734. */
  8735. attached: CameraInputsMap<TCamera>;
  8736. /**
  8737. * Defines the dom element the camera is collecting inputs from.
  8738. * This is null if the controls have not been attached.
  8739. */
  8740. attachedElement: Nullable<HTMLElement>;
  8741. /**
  8742. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8743. */
  8744. noPreventDefault: boolean;
  8745. /**
  8746. * Defined the camera the input manager belongs to.
  8747. */
  8748. camera: TCamera;
  8749. /**
  8750. * Update the current camera state depending on the inputs that have been used this frame.
  8751. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8752. */
  8753. checkInputs: () => void;
  8754. /**
  8755. * Instantiate a new Camera Input Manager.
  8756. * @param camera Defines the camera the input manager blongs to
  8757. */
  8758. constructor(camera: TCamera);
  8759. /**
  8760. * Add an input method to a camera
  8761. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8762. * @param input camera input method
  8763. */
  8764. add(input: ICameraInput<TCamera>): void;
  8765. /**
  8766. * Remove a specific input method from a camera
  8767. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  8768. * @param inputToRemove camera input method
  8769. */
  8770. remove(inputToRemove: ICameraInput<TCamera>): void;
  8771. /**
  8772. * Remove a specific input type from a camera
  8773. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  8774. * @param inputType the type of the input to remove
  8775. */
  8776. removeByType(inputType: string): void;
  8777. private _addCheckInputs;
  8778. /**
  8779. * Attach the input controls to the currently attached dom element to listen the events from.
  8780. * @param input Defines the input to attach
  8781. */
  8782. attachInput(input: ICameraInput<TCamera>): void;
  8783. /**
  8784. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  8785. * @param element Defines the dom element to collect the events from
  8786. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8787. */
  8788. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  8789. /**
  8790. * Detach the current manager inputs controls from a specific dom element.
  8791. * @param element Defines the dom element to collect the events from
  8792. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  8793. */
  8794. detachElement(element: HTMLElement, disconnect?: boolean): void;
  8795. /**
  8796. * Rebuild the dynamic inputCheck function from the current list of
  8797. * defined inputs in the manager.
  8798. */
  8799. rebuildInputCheck(): void;
  8800. /**
  8801. * Remove all attached input methods from a camera
  8802. */
  8803. clear(): void;
  8804. /**
  8805. * Serialize the current input manager attached to a camera.
  8806. * This ensures than once parsed,
  8807. * the input associated to the camera will be identical to the current ones
  8808. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  8809. */
  8810. serialize(serializedCamera: any): void;
  8811. /**
  8812. * Parses an input manager serialized JSON to restore the previous list of inputs
  8813. * and states associated to a camera.
  8814. * @param parsedCamera Defines the JSON to parse
  8815. */
  8816. parse(parsedCamera: any): void;
  8817. }
  8818. }
  8819. declare module "babylonjs/Events/keyboardEvents" {
  8820. /**
  8821. * Gather the list of keyboard event types as constants.
  8822. */
  8823. export class KeyboardEventTypes {
  8824. /**
  8825. * The keydown event is fired when a key becomes active (pressed).
  8826. */
  8827. static readonly KEYDOWN: number;
  8828. /**
  8829. * The keyup event is fired when a key has been released.
  8830. */
  8831. static readonly KEYUP: number;
  8832. }
  8833. /**
  8834. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8835. */
  8836. export class KeyboardInfo {
  8837. /**
  8838. * Defines the type of event (KeyboardEventTypes)
  8839. */
  8840. type: number;
  8841. /**
  8842. * Defines the related dom event
  8843. */
  8844. event: KeyboardEvent;
  8845. /**
  8846. * Instantiates a new keyboard info.
  8847. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8848. * @param type Defines the type of event (KeyboardEventTypes)
  8849. * @param event Defines the related dom event
  8850. */
  8851. constructor(
  8852. /**
  8853. * Defines the type of event (KeyboardEventTypes)
  8854. */
  8855. type: number,
  8856. /**
  8857. * Defines the related dom event
  8858. */
  8859. event: KeyboardEvent);
  8860. }
  8861. /**
  8862. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8863. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8864. */
  8865. export class KeyboardInfoPre extends KeyboardInfo {
  8866. /**
  8867. * Defines the type of event (KeyboardEventTypes)
  8868. */
  8869. type: number;
  8870. /**
  8871. * Defines the related dom event
  8872. */
  8873. event: KeyboardEvent;
  8874. /**
  8875. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8876. */
  8877. skipOnPointerObservable: boolean;
  8878. /**
  8879. * Instantiates a new keyboard pre info.
  8880. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8881. * @param type Defines the type of event (KeyboardEventTypes)
  8882. * @param event Defines the related dom event
  8883. */
  8884. constructor(
  8885. /**
  8886. * Defines the type of event (KeyboardEventTypes)
  8887. */
  8888. type: number,
  8889. /**
  8890. * Defines the related dom event
  8891. */
  8892. event: KeyboardEvent);
  8893. }
  8894. }
  8895. declare module "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput" {
  8896. import { Nullable } from "babylonjs/types";
  8897. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  8898. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  8899. /**
  8900. * Manage the keyboard inputs to control the movement of a free camera.
  8901. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8902. */
  8903. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8904. /**
  8905. * Defines the camera the input is attached to.
  8906. */
  8907. camera: FreeCamera;
  8908. /**
  8909. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8910. */
  8911. keysUp: number[];
  8912. /**
  8913. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8914. */
  8915. keysDown: number[];
  8916. /**
  8917. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8918. */
  8919. keysLeft: number[];
  8920. /**
  8921. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8922. */
  8923. keysRight: number[];
  8924. private _keys;
  8925. private _onCanvasBlurObserver;
  8926. private _onKeyboardObserver;
  8927. private _engine;
  8928. private _scene;
  8929. /**
  8930. * Attach the input controls to a specific dom element to get the input from.
  8931. * @param element Defines the element the controls should be listened from
  8932. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8933. */
  8934. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8935. /**
  8936. * Detach the current controls from the specified dom element.
  8937. * @param element Defines the element to stop listening the inputs from
  8938. */
  8939. detachControl(element: Nullable<HTMLElement>): void;
  8940. /**
  8941. * Update the current camera state depending on the inputs that have been used this frame.
  8942. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8943. */
  8944. checkInputs(): void;
  8945. /**
  8946. * Gets the class name of the current intput.
  8947. * @returns the class name
  8948. */
  8949. getClassName(): string;
  8950. /** @hidden */
  8951. _onLostFocus(): void;
  8952. /**
  8953. * Get the friendly name associated with the input class.
  8954. * @returns the input friendly name
  8955. */
  8956. getSimpleName(): string;
  8957. }
  8958. }
  8959. declare module "babylonjs/Lights/shadowLight" {
  8960. import { Camera } from "babylonjs/Cameras/camera";
  8961. import { Scene } from "babylonjs/scene";
  8962. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  8963. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8964. import { Light } from "babylonjs/Lights/light";
  8965. /**
  8966. * Interface describing all the common properties and methods a shadow light needs to implement.
  8967. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8968. * as well as binding the different shadow properties to the effects.
  8969. */
  8970. export interface IShadowLight extends Light {
  8971. /**
  8972. * The light id in the scene (used in scene.findLighById for instance)
  8973. */
  8974. id: string;
  8975. /**
  8976. * The position the shdow will be casted from.
  8977. */
  8978. position: Vector3;
  8979. /**
  8980. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8981. */
  8982. direction: Vector3;
  8983. /**
  8984. * The transformed position. Position of the light in world space taking parenting in account.
  8985. */
  8986. transformedPosition: Vector3;
  8987. /**
  8988. * The transformed direction. Direction of the light in world space taking parenting in account.
  8989. */
  8990. transformedDirection: Vector3;
  8991. /**
  8992. * The friendly name of the light in the scene.
  8993. */
  8994. name: string;
  8995. /**
  8996. * Defines the shadow projection clipping minimum z value.
  8997. */
  8998. shadowMinZ: number;
  8999. /**
  9000. * Defines the shadow projection clipping maximum z value.
  9001. */
  9002. shadowMaxZ: number;
  9003. /**
  9004. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9005. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9006. */
  9007. computeTransformedInformation(): boolean;
  9008. /**
  9009. * Gets the scene the light belongs to.
  9010. * @returns The scene
  9011. */
  9012. getScene(): Scene;
  9013. /**
  9014. * Callback defining a custom Projection Matrix Builder.
  9015. * This can be used to override the default projection matrix computation.
  9016. */
  9017. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9018. /**
  9019. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9020. * @param matrix The materix to updated with the projection information
  9021. * @param viewMatrix The transform matrix of the light
  9022. * @param renderList The list of mesh to render in the map
  9023. * @returns The current light
  9024. */
  9025. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9026. /**
  9027. * Gets the current depth scale used in ESM.
  9028. * @returns The scale
  9029. */
  9030. getDepthScale(): number;
  9031. /**
  9032. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9033. * @returns true if a cube texture needs to be use
  9034. */
  9035. needCube(): boolean;
  9036. /**
  9037. * Detects if the projection matrix requires to be recomputed this frame.
  9038. * @returns true if it requires to be recomputed otherwise, false.
  9039. */
  9040. needProjectionMatrixCompute(): boolean;
  9041. /**
  9042. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9043. */
  9044. forceProjectionMatrixCompute(): void;
  9045. /**
  9046. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9047. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9048. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9049. */
  9050. getShadowDirection(faceIndex?: number): Vector3;
  9051. /**
  9052. * Gets the minZ used for shadow according to both the scene and the light.
  9053. * @param activeCamera The camera we are returning the min for
  9054. * @returns the depth min z
  9055. */
  9056. getDepthMinZ(activeCamera: Camera): number;
  9057. /**
  9058. * Gets the maxZ used for shadow according to both the scene and the light.
  9059. * @param activeCamera The camera we are returning the max for
  9060. * @returns the depth max z
  9061. */
  9062. getDepthMaxZ(activeCamera: Camera): number;
  9063. }
  9064. /**
  9065. * Base implementation IShadowLight
  9066. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  9067. */
  9068. export abstract class ShadowLight extends Light implements IShadowLight {
  9069. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  9070. protected _position: Vector3;
  9071. protected _setPosition(value: Vector3): void;
  9072. /**
  9073. * Sets the position the shadow will be casted from. Also use as the light position for both
  9074. * point and spot lights.
  9075. */
  9076. /**
  9077. * Sets the position the shadow will be casted from. Also use as the light position for both
  9078. * point and spot lights.
  9079. */
  9080. position: Vector3;
  9081. protected _direction: Vector3;
  9082. protected _setDirection(value: Vector3): void;
  9083. /**
  9084. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  9085. * Also use as the light direction on spot and directional lights.
  9086. */
  9087. /**
  9088. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  9089. * Also use as the light direction on spot and directional lights.
  9090. */
  9091. direction: Vector3;
  9092. private _shadowMinZ;
  9093. /**
  9094. * Gets the shadow projection clipping minimum z value.
  9095. */
  9096. /**
  9097. * Sets the shadow projection clipping minimum z value.
  9098. */
  9099. shadowMinZ: number;
  9100. private _shadowMaxZ;
  9101. /**
  9102. * Sets the shadow projection clipping maximum z value.
  9103. */
  9104. /**
  9105. * Gets the shadow projection clipping maximum z value.
  9106. */
  9107. shadowMaxZ: number;
  9108. /**
  9109. * Callback defining a custom Projection Matrix Builder.
  9110. * This can be used to override the default projection matrix computation.
  9111. */
  9112. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9113. /**
  9114. * The transformed position. Position of the light in world space taking parenting in account.
  9115. */
  9116. transformedPosition: Vector3;
  9117. /**
  9118. * The transformed direction. Direction of the light in world space taking parenting in account.
  9119. */
  9120. transformedDirection: Vector3;
  9121. private _needProjectionMatrixCompute;
  9122. /**
  9123. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9124. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9125. */
  9126. computeTransformedInformation(): boolean;
  9127. /**
  9128. * Return the depth scale used for the shadow map.
  9129. * @returns the depth scale.
  9130. */
  9131. getDepthScale(): number;
  9132. /**
  9133. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9134. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9135. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9136. */
  9137. getShadowDirection(faceIndex?: number): Vector3;
  9138. /**
  9139. * Returns the ShadowLight absolute position in the World.
  9140. * @returns the position vector in world space
  9141. */
  9142. getAbsolutePosition(): Vector3;
  9143. /**
  9144. * Sets the ShadowLight direction toward the passed target.
  9145. * @param target The point to target in local space
  9146. * @returns the updated ShadowLight direction
  9147. */
  9148. setDirectionToTarget(target: Vector3): Vector3;
  9149. /**
  9150. * Returns the light rotation in euler definition.
  9151. * @returns the x y z rotation in local space.
  9152. */
  9153. getRotation(): Vector3;
  9154. /**
  9155. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9156. * @returns true if a cube texture needs to be use
  9157. */
  9158. needCube(): boolean;
  9159. /**
  9160. * Detects if the projection matrix requires to be recomputed this frame.
  9161. * @returns true if it requires to be recomputed otherwise, false.
  9162. */
  9163. needProjectionMatrixCompute(): boolean;
  9164. /**
  9165. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9166. */
  9167. forceProjectionMatrixCompute(): void;
  9168. /** @hidden */
  9169. _initCache(): void;
  9170. /** @hidden */
  9171. _isSynchronized(): boolean;
  9172. /**
  9173. * Computes the world matrix of the node
  9174. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9175. * @returns the world matrix
  9176. */
  9177. computeWorldMatrix(force?: boolean): Matrix;
  9178. /**
  9179. * Gets the minZ used for shadow according to both the scene and the light.
  9180. * @param activeCamera The camera we are returning the min for
  9181. * @returns the depth min z
  9182. */
  9183. getDepthMinZ(activeCamera: Camera): number;
  9184. /**
  9185. * Gets the maxZ used for shadow according to both the scene and the light.
  9186. * @param activeCamera The camera we are returning the max for
  9187. * @returns the depth max z
  9188. */
  9189. getDepthMaxZ(activeCamera: Camera): number;
  9190. /**
  9191. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9192. * @param matrix The materix to updated with the projection information
  9193. * @param viewMatrix The transform matrix of the light
  9194. * @param renderList The list of mesh to render in the map
  9195. * @returns The current light
  9196. */
  9197. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9198. }
  9199. }
  9200. declare module "babylonjs/Materials/materialHelper" {
  9201. import { Nullable } from "babylonjs/types";
  9202. import { Scene } from "babylonjs/scene";
  9203. import { Engine } from "babylonjs/Engines/engine";
  9204. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9205. import { Light } from "babylonjs/Lights/light";
  9206. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  9207. import { Effect, EffectFallbacks, EffectCreationOptions } from "babylonjs/Materials/effect";
  9208. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  9209. /**
  9210. * "Static Class" containing the most commonly used helper while dealing with material for
  9211. * rendering purpose.
  9212. *
  9213. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  9214. *
  9215. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  9216. */
  9217. export class MaterialHelper {
  9218. /**
  9219. * Bind the current view position to an effect.
  9220. * @param effect The effect to be bound
  9221. * @param scene The scene the eyes position is used from
  9222. */
  9223. static BindEyePosition(effect: Effect, scene: Scene): void;
  9224. /**
  9225. * Helps preparing the defines values about the UVs in used in the effect.
  9226. * UVs are shared as much as we can accross channels in the shaders.
  9227. * @param texture The texture we are preparing the UVs for
  9228. * @param defines The defines to update
  9229. * @param key The channel key "diffuse", "specular"... used in the shader
  9230. */
  9231. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  9232. /**
  9233. * Binds a texture matrix value to its corrsponding uniform
  9234. * @param texture The texture to bind the matrix for
  9235. * @param uniformBuffer The uniform buffer receivin the data
  9236. * @param key The channel key "diffuse", "specular"... used in the shader
  9237. */
  9238. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  9239. /**
  9240. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  9241. * @param mesh defines the current mesh
  9242. * @param scene defines the current scene
  9243. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  9244. * @param pointsCloud defines if point cloud rendering has to be turned on
  9245. * @param fogEnabled defines if fog has to be turned on
  9246. * @param alphaTest defines if alpha testing has to be turned on
  9247. * @param defines defines the current list of defines
  9248. */
  9249. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  9250. /**
  9251. * Helper used to prepare the list of defines associated with frame values for shader compilation
  9252. * @param scene defines the current scene
  9253. * @param engine defines the current engine
  9254. * @param defines specifies the list of active defines
  9255. * @param useInstances defines if instances have to be turned on
  9256. * @param useClipPlane defines if clip plane have to be turned on
  9257. */
  9258. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  9259. /**
  9260. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  9261. * @param mesh The mesh containing the geometry data we will draw
  9262. * @param defines The defines to update
  9263. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  9264. * @param useBones Precise whether bones should be used or not (override mesh info)
  9265. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  9266. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  9267. * @returns false if defines are considered not dirty and have not been checked
  9268. */
  9269. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  9270. /**
  9271. * Prepares the defines related to multiview
  9272. * @param scene The scene we are intending to draw
  9273. * @param defines The defines to update
  9274. */
  9275. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  9276. /**
  9277. * Prepares the defines related to the light information passed in parameter
  9278. * @param scene The scene we are intending to draw
  9279. * @param mesh The mesh the effect is compiling for
  9280. * @param defines The defines to update
  9281. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9282. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  9283. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  9284. * @returns true if normals will be required for the rest of the effect
  9285. */
  9286. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  9287. /**
  9288. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  9289. * that won t be acctive due to defines being turned off.
  9290. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  9291. * @param samplersList The samplers list
  9292. * @param defines The defines helping in the list generation
  9293. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  9294. */
  9295. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9296. /**
  9297. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9298. * @param defines The defines to update while falling back
  9299. * @param fallbacks The authorized effect fallbacks
  9300. * @param maxSimultaneousLights The maximum number of lights allowed
  9301. * @param rank the current rank of the Effect
  9302. * @returns The newly affected rank
  9303. */
  9304. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9305. /**
  9306. * Prepares the list of attributes required for morph targets according to the effect defines.
  9307. * @param attribs The current list of supported attribs
  9308. * @param mesh The mesh to prepare the morph targets attributes for
  9309. * @param defines The current Defines of the effect
  9310. */
  9311. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9312. /**
  9313. * Prepares the list of attributes required for bones according to the effect defines.
  9314. * @param attribs The current list of supported attribs
  9315. * @param mesh The mesh to prepare the bones attributes for
  9316. * @param defines The current Defines of the effect
  9317. * @param fallbacks The current efffect fallback strategy
  9318. */
  9319. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9320. /**
  9321. * Prepares the list of attributes required for instances according to the effect defines.
  9322. * @param attribs The current list of supported attribs
  9323. * @param defines The current Defines of the effect
  9324. */
  9325. static PrepareAttributesForInstances(attribs: string[], defines: any): void;
  9326. /**
  9327. * Binds the light shadow information to the effect for the given mesh.
  9328. * @param light The light containing the generator
  9329. * @param scene The scene the lights belongs to
  9330. * @param mesh The mesh we are binding the information to render
  9331. * @param lightIndex The light index in the effect used to render the mesh
  9332. * @param effect The effect we are binding the data to
  9333. */
  9334. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  9335. /**
  9336. * Binds the light information to the effect.
  9337. * @param light The light containing the generator
  9338. * @param effect The effect we are binding the data to
  9339. * @param lightIndex The light index in the effect used to render
  9340. */
  9341. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9342. /**
  9343. * Binds the lights information from the scene to the effect for the given mesh.
  9344. * @param scene The scene the lights belongs to
  9345. * @param mesh The mesh we are binding the information to render
  9346. * @param effect The effect we are binding the data to
  9347. * @param defines The generated defines for the effect
  9348. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9349. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9350. */
  9351. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  9352. private static _tempFogColor;
  9353. /**
  9354. * Binds the fog information from the scene to the effect for the given mesh.
  9355. * @param scene The scene the lights belongs to
  9356. * @param mesh The mesh we are binding the information to render
  9357. * @param effect The effect we are binding the data to
  9358. * @param linearSpace Defines if the fog effect is applied in linear space
  9359. */
  9360. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9361. /**
  9362. * Binds the bones information from the mesh to the effect.
  9363. * @param mesh The mesh we are binding the information to render
  9364. * @param effect The effect we are binding the data to
  9365. */
  9366. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9367. /**
  9368. * Binds the morph targets information from the mesh to the effect.
  9369. * @param abstractMesh The mesh we are binding the information to render
  9370. * @param effect The effect we are binding the data to
  9371. */
  9372. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9373. /**
  9374. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9375. * @param defines The generated defines used in the effect
  9376. * @param effect The effect we are binding the data to
  9377. * @param scene The scene we are willing to render with logarithmic scale for
  9378. */
  9379. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9380. /**
  9381. * Binds the clip plane information from the scene to the effect.
  9382. * @param scene The scene the clip plane information are extracted from
  9383. * @param effect The effect we are binding the data to
  9384. */
  9385. static BindClipPlane(effect: Effect, scene: Scene): void;
  9386. }
  9387. }
  9388. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  9389. /** @hidden */
  9390. export var kernelBlurVaryingDeclaration: {
  9391. name: string;
  9392. shader: string;
  9393. };
  9394. }
  9395. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  9396. /** @hidden */
  9397. export var kernelBlurFragment: {
  9398. name: string;
  9399. shader: string;
  9400. };
  9401. }
  9402. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  9403. /** @hidden */
  9404. export var kernelBlurFragment2: {
  9405. name: string;
  9406. shader: string;
  9407. };
  9408. }
  9409. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  9410. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  9411. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  9412. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  9413. /** @hidden */
  9414. export var kernelBlurPixelShader: {
  9415. name: string;
  9416. shader: string;
  9417. };
  9418. }
  9419. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  9420. /** @hidden */
  9421. export var kernelBlurVertex: {
  9422. name: string;
  9423. shader: string;
  9424. };
  9425. }
  9426. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  9427. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  9428. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  9429. /** @hidden */
  9430. export var kernelBlurVertexShader: {
  9431. name: string;
  9432. shader: string;
  9433. };
  9434. }
  9435. declare module "babylonjs/PostProcesses/blurPostProcess" {
  9436. import { Vector2 } from "babylonjs/Maths/math";
  9437. import { Nullable } from "babylonjs/types";
  9438. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  9439. import { Camera } from "babylonjs/Cameras/camera";
  9440. import { Effect } from "babylonjs/Materials/effect";
  9441. import { Engine } from "babylonjs/Engines/engine";
  9442. import "babylonjs/Shaders/kernelBlur.fragment";
  9443. import "babylonjs/Shaders/kernelBlur.vertex";
  9444. /**
  9445. * The Blur Post Process which blurs an image based on a kernel and direction.
  9446. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  9447. */
  9448. export class BlurPostProcess extends PostProcess {
  9449. /** The direction in which to blur the image. */
  9450. direction: Vector2;
  9451. private blockCompilation;
  9452. protected _kernel: number;
  9453. protected _idealKernel: number;
  9454. protected _packedFloat: boolean;
  9455. private _staticDefines;
  9456. /**
  9457. * Sets the length in pixels of the blur sample region
  9458. */
  9459. /**
  9460. * Gets the length in pixels of the blur sample region
  9461. */
  9462. kernel: number;
  9463. /**
  9464. * Sets wether or not the blur needs to unpack/repack floats
  9465. */
  9466. /**
  9467. * Gets wether or not the blur is unpacking/repacking floats
  9468. */
  9469. packedFloat: boolean;
  9470. /**
  9471. * Creates a new instance BlurPostProcess
  9472. * @param name The name of the effect.
  9473. * @param direction The direction in which to blur the image.
  9474. * @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.
  9475. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  9476. * @param camera The camera to apply the render pass to.
  9477. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  9478. * @param engine The engine which the post process will be applied. (default: current engine)
  9479. * @param reusable If the post process can be reused on the same frame. (default: false)
  9480. * @param textureType Type of textures used when performing the post process. (default: 0)
  9481. * @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)
  9482. */
  9483. constructor(name: string,
  9484. /** The direction in which to blur the image. */
  9485. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  9486. /**
  9487. * Updates the effect with the current post process compile time values and recompiles the shader.
  9488. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  9489. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  9490. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  9491. * @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
  9492. * @param onCompiled Called when the shader has been compiled.
  9493. * @param onError Called if there is an error when compiling a shader.
  9494. */
  9495. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  9496. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  9497. /**
  9498. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  9499. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  9500. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  9501. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  9502. * The gaps between physical kernels are compensated for in the weighting of the samples
  9503. * @param idealKernel Ideal blur kernel.
  9504. * @return Nearest best kernel.
  9505. */
  9506. protected _nearestBestKernel(idealKernel: number): number;
  9507. /**
  9508. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  9509. * @param x The point on the Gaussian distribution to sample.
  9510. * @return the value of the Gaussian function at x.
  9511. */
  9512. protected _gaussianWeight(x: number): number;
  9513. /**
  9514. * Generates a string that can be used as a floating point number in GLSL.
  9515. * @param x Value to print.
  9516. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  9517. * @return GLSL float string.
  9518. */
  9519. protected _glslFloat(x: number, decimalFigures?: number): string;
  9520. }
  9521. }
  9522. declare module "babylonjs/Shaders/shadowMap.fragment" {
  9523. /** @hidden */
  9524. export var shadowMapPixelShader: {
  9525. name: string;
  9526. shader: string;
  9527. };
  9528. }
  9529. declare module "babylonjs/Shaders/ShadersInclude/bonesDeclaration" {
  9530. /** @hidden */
  9531. export var bonesDeclaration: {
  9532. name: string;
  9533. shader: string;
  9534. };
  9535. }
  9536. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration" {
  9537. /** @hidden */
  9538. export var morphTargetsVertexGlobalDeclaration: {
  9539. name: string;
  9540. shader: string;
  9541. };
  9542. }
  9543. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration" {
  9544. /** @hidden */
  9545. export var morphTargetsVertexDeclaration: {
  9546. name: string;
  9547. shader: string;
  9548. };
  9549. }
  9550. declare module "babylonjs/Shaders/ShadersInclude/instancesDeclaration" {
  9551. /** @hidden */
  9552. export var instancesDeclaration: {
  9553. name: string;
  9554. shader: string;
  9555. };
  9556. }
  9557. declare module "babylonjs/Shaders/ShadersInclude/helperFunctions" {
  9558. /** @hidden */
  9559. export var helperFunctions: {
  9560. name: string;
  9561. shader: string;
  9562. };
  9563. }
  9564. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertex" {
  9565. /** @hidden */
  9566. export var morphTargetsVertex: {
  9567. name: string;
  9568. shader: string;
  9569. };
  9570. }
  9571. declare module "babylonjs/Shaders/ShadersInclude/instancesVertex" {
  9572. /** @hidden */
  9573. export var instancesVertex: {
  9574. name: string;
  9575. shader: string;
  9576. };
  9577. }
  9578. declare module "babylonjs/Shaders/ShadersInclude/bonesVertex" {
  9579. /** @hidden */
  9580. export var bonesVertex: {
  9581. name: string;
  9582. shader: string;
  9583. };
  9584. }
  9585. declare module "babylonjs/Shaders/shadowMap.vertex" {
  9586. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  9587. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  9588. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  9589. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  9590. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  9591. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  9592. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  9593. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  9594. /** @hidden */
  9595. export var shadowMapVertexShader: {
  9596. name: string;
  9597. shader: string;
  9598. };
  9599. }
  9600. declare module "babylonjs/Shaders/depthBoxBlur.fragment" {
  9601. /** @hidden */
  9602. export var depthBoxBlurPixelShader: {
  9603. name: string;
  9604. shader: string;
  9605. };
  9606. }
  9607. declare module "babylonjs/Lights/Shadows/shadowGenerator" {
  9608. import { Nullable } from "babylonjs/types";
  9609. import { Scene } from "babylonjs/scene";
  9610. import { Matrix } from "babylonjs/Maths/math";
  9611. import { SubMesh } from "babylonjs/Meshes/subMesh";
  9612. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9613. import { Mesh } from "babylonjs/Meshes/mesh";
  9614. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  9615. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  9616. import { Effect } from "babylonjs/Materials/effect";
  9617. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  9618. import "babylonjs/Shaders/shadowMap.fragment";
  9619. import "babylonjs/Shaders/shadowMap.vertex";
  9620. import "babylonjs/Shaders/depthBoxBlur.fragment";
  9621. import { Observable } from "babylonjs/Misc/observable";
  9622. /**
  9623. * Defines the options associated with the creation of a custom shader for a shadow generator.
  9624. */
  9625. export interface ICustomShaderOptions {
  9626. /**
  9627. * Gets or sets the custom shader name to use
  9628. */
  9629. shaderName: string;
  9630. /**
  9631. * The list of attribute names used in the shader
  9632. */
  9633. attributes?: string[];
  9634. /**
  9635. * The list of unifrom names used in the shader
  9636. */
  9637. uniforms?: string[];
  9638. /**
  9639. * The list of sampler names used in the shader
  9640. */
  9641. samplers?: string[];
  9642. /**
  9643. * The list of defines used in the shader
  9644. */
  9645. defines?: string[];
  9646. }
  9647. /**
  9648. * Interface to implement to create a shadow generator compatible with BJS.
  9649. */
  9650. export interface IShadowGenerator {
  9651. /**
  9652. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9653. * @returns The render target texture if present otherwise, null
  9654. */
  9655. getShadowMap(): Nullable<RenderTargetTexture>;
  9656. /**
  9657. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9658. * @returns The render target texture if the shadow map is present otherwise, null
  9659. */
  9660. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9661. /**
  9662. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9663. * @param subMesh The submesh we want to render in the shadow map
  9664. * @param useInstances Defines wether will draw in the map using instances
  9665. * @returns true if ready otherwise, false
  9666. */
  9667. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9668. /**
  9669. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9670. * @param defines Defines of the material we want to update
  9671. * @param lightIndex Index of the light in the enabled light list of the material
  9672. */
  9673. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  9674. /**
  9675. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9676. * defined in the generator but impacting the effect).
  9677. * It implies the unifroms available on the materials are the standard BJS ones.
  9678. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9679. * @param effect The effect we are binfing the information for
  9680. */
  9681. bindShadowLight(lightIndex: string, effect: Effect): void;
  9682. /**
  9683. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9684. * (eq to shadow prjection matrix * light transform matrix)
  9685. * @returns The transform matrix used to create the shadow map
  9686. */
  9687. getTransformMatrix(): Matrix;
  9688. /**
  9689. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9690. * Cube and 2D textures for instance.
  9691. */
  9692. recreateShadowMap(): void;
  9693. /**
  9694. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9695. * @param onCompiled Callback triggered at the and of the effects compilation
  9696. * @param options Sets of optional options forcing the compilation with different modes
  9697. */
  9698. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9699. useInstances: boolean;
  9700. }>): void;
  9701. /**
  9702. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9703. * @param options Sets of optional options forcing the compilation with different modes
  9704. * @returns A promise that resolves when the compilation completes
  9705. */
  9706. forceCompilationAsync(options?: Partial<{
  9707. useInstances: boolean;
  9708. }>): Promise<void>;
  9709. /**
  9710. * Serializes the shadow generator setup to a json object.
  9711. * @returns The serialized JSON object
  9712. */
  9713. serialize(): any;
  9714. /**
  9715. * Disposes the Shadow map and related Textures and effects.
  9716. */
  9717. dispose(): void;
  9718. }
  9719. /**
  9720. * Default implementation IShadowGenerator.
  9721. * This is the main object responsible of generating shadows in the framework.
  9722. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  9723. */
  9724. export class ShadowGenerator implements IShadowGenerator {
  9725. /**
  9726. * Shadow generator mode None: no filtering applied.
  9727. */
  9728. static readonly FILTER_NONE: number;
  9729. /**
  9730. * Shadow generator mode ESM: Exponential Shadow Mapping.
  9731. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9732. */
  9733. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  9734. /**
  9735. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  9736. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  9737. */
  9738. static readonly FILTER_POISSONSAMPLING: number;
  9739. /**
  9740. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  9741. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9742. */
  9743. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  9744. /**
  9745. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  9746. * edge artifacts on steep falloff.
  9747. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9748. */
  9749. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  9750. /**
  9751. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  9752. * edge artifacts on steep falloff.
  9753. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9754. */
  9755. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  9756. /**
  9757. * Shadow generator mode PCF: Percentage Closer Filtering
  9758. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9759. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  9760. */
  9761. static readonly FILTER_PCF: number;
  9762. /**
  9763. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  9764. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9765. * Contact Hardening
  9766. */
  9767. static readonly FILTER_PCSS: number;
  9768. /**
  9769. * Reserved for PCF and PCSS
  9770. * Highest Quality.
  9771. *
  9772. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  9773. *
  9774. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  9775. */
  9776. static readonly QUALITY_HIGH: number;
  9777. /**
  9778. * Reserved for PCF and PCSS
  9779. * Good tradeoff for quality/perf cross devices
  9780. *
  9781. * Execute PCF on a 3*3 kernel.
  9782. *
  9783. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  9784. */
  9785. static readonly QUALITY_MEDIUM: number;
  9786. /**
  9787. * Reserved for PCF and PCSS
  9788. * The lowest quality but the fastest.
  9789. *
  9790. * Execute PCF on a 1*1 kernel.
  9791. *
  9792. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  9793. */
  9794. static readonly QUALITY_LOW: number;
  9795. /** Gets or sets the custom shader name to use */
  9796. customShaderOptions: ICustomShaderOptions;
  9797. /**
  9798. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  9799. */
  9800. onBeforeShadowMapRenderObservable: Observable<Effect>;
  9801. /**
  9802. * Observable triggered before a mesh is rendered in the shadow map.
  9803. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  9804. */
  9805. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  9806. private _bias;
  9807. /**
  9808. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  9809. */
  9810. /**
  9811. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  9812. */
  9813. bias: number;
  9814. private _normalBias;
  9815. /**
  9816. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9817. */
  9818. /**
  9819. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9820. */
  9821. normalBias: number;
  9822. private _blurBoxOffset;
  9823. /**
  9824. * Gets the blur box offset: offset applied during the blur pass.
  9825. * Only useful if useKernelBlur = false
  9826. */
  9827. /**
  9828. * Sets the blur box offset: offset applied during the blur pass.
  9829. * Only useful if useKernelBlur = false
  9830. */
  9831. blurBoxOffset: number;
  9832. private _blurScale;
  9833. /**
  9834. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  9835. * 2 means half of the size.
  9836. */
  9837. /**
  9838. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  9839. * 2 means half of the size.
  9840. */
  9841. blurScale: number;
  9842. private _blurKernel;
  9843. /**
  9844. * Gets the blur kernel: kernel size of the blur pass.
  9845. * Only useful if useKernelBlur = true
  9846. */
  9847. /**
  9848. * Sets the blur kernel: kernel size of the blur pass.
  9849. * Only useful if useKernelBlur = true
  9850. */
  9851. blurKernel: number;
  9852. private _useKernelBlur;
  9853. /**
  9854. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  9855. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9856. */
  9857. /**
  9858. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  9859. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9860. */
  9861. useKernelBlur: boolean;
  9862. private _depthScale;
  9863. /**
  9864. * Gets the depth scale used in ESM mode.
  9865. */
  9866. /**
  9867. * Sets the depth scale used in ESM mode.
  9868. * This can override the scale stored on the light.
  9869. */
  9870. depthScale: number;
  9871. private _filter;
  9872. /**
  9873. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  9874. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9875. */
  9876. /**
  9877. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  9878. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9879. */
  9880. filter: number;
  9881. /**
  9882. * Gets if the current filter is set to Poisson Sampling.
  9883. */
  9884. /**
  9885. * Sets the current filter to Poisson Sampling.
  9886. */
  9887. usePoissonSampling: boolean;
  9888. /**
  9889. * Gets if the current filter is set to ESM.
  9890. */
  9891. /**
  9892. * Sets the current filter is to ESM.
  9893. */
  9894. useExponentialShadowMap: boolean;
  9895. /**
  9896. * Gets if the current filter is set to filtered ESM.
  9897. */
  9898. /**
  9899. * Gets if the current filter is set to filtered ESM.
  9900. */
  9901. useBlurExponentialShadowMap: boolean;
  9902. /**
  9903. * Gets if the current filter is set to "close ESM" (using the inverse of the
  9904. * exponential to prevent steep falloff artifacts).
  9905. */
  9906. /**
  9907. * Sets the current filter to "close ESM" (using the inverse of the
  9908. * exponential to prevent steep falloff artifacts).
  9909. */
  9910. useCloseExponentialShadowMap: boolean;
  9911. /**
  9912. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  9913. * exponential to prevent steep falloff artifacts).
  9914. */
  9915. /**
  9916. * Sets the current filter to filtered "close ESM" (using the inverse of the
  9917. * exponential to prevent steep falloff artifacts).
  9918. */
  9919. useBlurCloseExponentialShadowMap: boolean;
  9920. /**
  9921. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  9922. */
  9923. /**
  9924. * Sets the current filter to "PCF" (percentage closer filtering).
  9925. */
  9926. usePercentageCloserFiltering: boolean;
  9927. private _filteringQuality;
  9928. /**
  9929. * Gets the PCF or PCSS Quality.
  9930. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9931. */
  9932. /**
  9933. * Sets the PCF or PCSS Quality.
  9934. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9935. */
  9936. filteringQuality: number;
  9937. /**
  9938. * Gets if the current filter is set to "PCSS" (contact hardening).
  9939. */
  9940. /**
  9941. * Sets the current filter to "PCSS" (contact hardening).
  9942. */
  9943. useContactHardeningShadow: boolean;
  9944. private _contactHardeningLightSizeUVRatio;
  9945. /**
  9946. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9947. * Using a ratio helps keeping shape stability independently of the map size.
  9948. *
  9949. * It does not account for the light projection as it was having too much
  9950. * instability during the light setup or during light position changes.
  9951. *
  9952. * Only valid if useContactHardeningShadow is true.
  9953. */
  9954. /**
  9955. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9956. * Using a ratio helps keeping shape stability independently of the map size.
  9957. *
  9958. * It does not account for the light projection as it was having too much
  9959. * instability during the light setup or during light position changes.
  9960. *
  9961. * Only valid if useContactHardeningShadow is true.
  9962. */
  9963. contactHardeningLightSizeUVRatio: number;
  9964. private _darkness;
  9965. /**
  9966. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  9967. * 0 means strongest and 1 would means no shadow.
  9968. * @returns the darkness.
  9969. */
  9970. getDarkness(): number;
  9971. /**
  9972. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  9973. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  9974. * @returns the shadow generator allowing fluent coding.
  9975. */
  9976. setDarkness(darkness: number): ShadowGenerator;
  9977. private _transparencyShadow;
  9978. /**
  9979. * Sets the ability to have transparent shadow (boolean).
  9980. * @param transparent True if transparent else False
  9981. * @returns the shadow generator allowing fluent coding
  9982. */
  9983. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  9984. private _shadowMap;
  9985. private _shadowMap2;
  9986. /**
  9987. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9988. * @returns The render target texture if present otherwise, null
  9989. */
  9990. getShadowMap(): Nullable<RenderTargetTexture>;
  9991. /**
  9992. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9993. * @returns The render target texture if the shadow map is present otherwise, null
  9994. */
  9995. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9996. /**
  9997. * Helper function to add a mesh and its descendants to the list of shadow casters.
  9998. * @param mesh Mesh to add
  9999. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  10000. * @returns the Shadow Generator itself
  10001. */
  10002. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  10003. /**
  10004. * Helper function to remove a mesh and its descendants from the list of shadow casters
  10005. * @param mesh Mesh to remove
  10006. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  10007. * @returns the Shadow Generator itself
  10008. */
  10009. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  10010. /**
  10011. * Controls the extent to which the shadows fade out at the edge of the frustum
  10012. * Used only by directionals and spots
  10013. */
  10014. frustumEdgeFalloff: number;
  10015. private _light;
  10016. /**
  10017. * Returns the associated light object.
  10018. * @returns the light generating the shadow
  10019. */
  10020. getLight(): IShadowLight;
  10021. /**
  10022. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  10023. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  10024. * It might on the other hand introduce peter panning.
  10025. */
  10026. forceBackFacesOnly: boolean;
  10027. private _scene;
  10028. private _lightDirection;
  10029. private _effect;
  10030. private _viewMatrix;
  10031. private _projectionMatrix;
  10032. private _transformMatrix;
  10033. private _cachedPosition;
  10034. private _cachedDirection;
  10035. private _cachedDefines;
  10036. private _currentRenderID;
  10037. private _boxBlurPostprocess;
  10038. private _kernelBlurXPostprocess;
  10039. private _kernelBlurYPostprocess;
  10040. private _blurPostProcesses;
  10041. private _mapSize;
  10042. private _currentFaceIndex;
  10043. private _currentFaceIndexCache;
  10044. private _textureType;
  10045. private _defaultTextureMatrix;
  10046. /** @hidden */
  10047. static _SceneComponentInitialization: (scene: Scene) => void;
  10048. /**
  10049. * Creates a ShadowGenerator object.
  10050. * A ShadowGenerator is the required tool to use the shadows.
  10051. * Each light casting shadows needs to use its own ShadowGenerator.
  10052. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  10053. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  10054. * @param light The light object generating the shadows.
  10055. * @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.
  10056. */
  10057. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  10058. private _initializeGenerator;
  10059. private _initializeShadowMap;
  10060. private _initializeBlurRTTAndPostProcesses;
  10061. private _renderForShadowMap;
  10062. private _renderSubMeshForShadowMap;
  10063. private _applyFilterValues;
  10064. /**
  10065. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  10066. * @param onCompiled Callback triggered at the and of the effects compilation
  10067. * @param options Sets of optional options forcing the compilation with different modes
  10068. */
  10069. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  10070. useInstances: boolean;
  10071. }>): void;
  10072. /**
  10073. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  10074. * @param options Sets of optional options forcing the compilation with different modes
  10075. * @returns A promise that resolves when the compilation completes
  10076. */
  10077. forceCompilationAsync(options?: Partial<{
  10078. useInstances: boolean;
  10079. }>): Promise<void>;
  10080. /**
  10081. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  10082. * @param subMesh The submesh we want to render in the shadow map
  10083. * @param useInstances Defines wether will draw in the map using instances
  10084. * @returns true if ready otherwise, false
  10085. */
  10086. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  10087. /**
  10088. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  10089. * @param defines Defines of the material we want to update
  10090. * @param lightIndex Index of the light in the enabled light list of the material
  10091. */
  10092. prepareDefines(defines: any, lightIndex: number): void;
  10093. /**
  10094. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  10095. * defined in the generator but impacting the effect).
  10096. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  10097. * @param effect The effect we are binfing the information for
  10098. */
  10099. bindShadowLight(lightIndex: string, effect: Effect): void;
  10100. /**
  10101. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  10102. * (eq to shadow prjection matrix * light transform matrix)
  10103. * @returns The transform matrix used to create the shadow map
  10104. */
  10105. getTransformMatrix(): Matrix;
  10106. /**
  10107. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  10108. * Cube and 2D textures for instance.
  10109. */
  10110. recreateShadowMap(): void;
  10111. private _disposeBlurPostProcesses;
  10112. private _disposeRTTandPostProcesses;
  10113. /**
  10114. * Disposes the ShadowGenerator.
  10115. * Returns nothing.
  10116. */
  10117. dispose(): void;
  10118. /**
  10119. * Serializes the shadow generator setup to a json object.
  10120. * @returns The serialized JSON object
  10121. */
  10122. serialize(): any;
  10123. /**
  10124. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  10125. * @param parsedShadowGenerator The JSON object to parse
  10126. * @param scene The scene to create the shadow map for
  10127. * @returns The parsed shadow generator
  10128. */
  10129. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  10130. }
  10131. }
  10132. declare module "babylonjs/Lights/light" {
  10133. import { Nullable } from "babylonjs/types";
  10134. import { Scene } from "babylonjs/scene";
  10135. import { Vector3, Color3 } from "babylonjs/Maths/math";
  10136. import { Node } from "babylonjs/node";
  10137. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10138. import { Effect } from "babylonjs/Materials/effect";
  10139. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  10140. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  10141. /**
  10142. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  10143. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  10144. * 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.
  10145. */
  10146. export abstract class Light extends Node {
  10147. /**
  10148. * Falloff Default: light is falling off following the material specification:
  10149. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  10150. */
  10151. static readonly FALLOFF_DEFAULT: number;
  10152. /**
  10153. * Falloff Physical: light is falling off following the inverse squared distance law.
  10154. */
  10155. static readonly FALLOFF_PHYSICAL: number;
  10156. /**
  10157. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  10158. * to enhance interoperability with other engines.
  10159. */
  10160. static readonly FALLOFF_GLTF: number;
  10161. /**
  10162. * Falloff Standard: light is falling off like in the standard material
  10163. * to enhance interoperability with other materials.
  10164. */
  10165. static readonly FALLOFF_STANDARD: number;
  10166. /**
  10167. * If every light affecting the material is in this lightmapMode,
  10168. * material.lightmapTexture adds or multiplies
  10169. * (depends on material.useLightmapAsShadowmap)
  10170. * after every other light calculations.
  10171. */
  10172. static readonly LIGHTMAP_DEFAULT: number;
  10173. /**
  10174. * material.lightmapTexture as only diffuse lighting from this light
  10175. * adds only specular lighting from this light
  10176. * adds dynamic shadows
  10177. */
  10178. static readonly LIGHTMAP_SPECULAR: number;
  10179. /**
  10180. * material.lightmapTexture as only lighting
  10181. * no light calculation from this light
  10182. * only adds dynamic shadows from this light
  10183. */
  10184. static readonly LIGHTMAP_SHADOWSONLY: number;
  10185. /**
  10186. * Each light type uses the default quantity according to its type:
  10187. * point/spot lights use luminous intensity
  10188. * directional lights use illuminance
  10189. */
  10190. static readonly INTENSITYMODE_AUTOMATIC: number;
  10191. /**
  10192. * lumen (lm)
  10193. */
  10194. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  10195. /**
  10196. * candela (lm/sr)
  10197. */
  10198. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  10199. /**
  10200. * lux (lm/m^2)
  10201. */
  10202. static readonly INTENSITYMODE_ILLUMINANCE: number;
  10203. /**
  10204. * nit (cd/m^2)
  10205. */
  10206. static readonly INTENSITYMODE_LUMINANCE: number;
  10207. /**
  10208. * Light type const id of the point light.
  10209. */
  10210. static readonly LIGHTTYPEID_POINTLIGHT: number;
  10211. /**
  10212. * Light type const id of the directional light.
  10213. */
  10214. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  10215. /**
  10216. * Light type const id of the spot light.
  10217. */
  10218. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  10219. /**
  10220. * Light type const id of the hemispheric light.
  10221. */
  10222. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  10223. /**
  10224. * Diffuse gives the basic color to an object.
  10225. */
  10226. diffuse: Color3;
  10227. /**
  10228. * Specular produces a highlight color on an object.
  10229. * Note: This is note affecting PBR materials.
  10230. */
  10231. specular: Color3;
  10232. /**
  10233. * Defines the falloff type for this light. This lets overrriding how punctual light are
  10234. * falling off base on range or angle.
  10235. * This can be set to any values in Light.FALLOFF_x.
  10236. *
  10237. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  10238. * other types of materials.
  10239. */
  10240. falloffType: number;
  10241. /**
  10242. * Strength of the light.
  10243. * Note: By default it is define in the framework own unit.
  10244. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  10245. */
  10246. intensity: number;
  10247. private _range;
  10248. protected _inverseSquaredRange: number;
  10249. /**
  10250. * Defines how far from the source the light is impacting in scene units.
  10251. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10252. */
  10253. /**
  10254. * Defines how far from the source the light is impacting in scene units.
  10255. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10256. */
  10257. range: number;
  10258. /**
  10259. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  10260. * of light.
  10261. */
  10262. private _photometricScale;
  10263. private _intensityMode;
  10264. /**
  10265. * Gets the photometric scale used to interpret the intensity.
  10266. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10267. */
  10268. /**
  10269. * Sets the photometric scale used to interpret the intensity.
  10270. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10271. */
  10272. intensityMode: number;
  10273. private _radius;
  10274. /**
  10275. * Gets the light radius used by PBR Materials to simulate soft area lights.
  10276. */
  10277. /**
  10278. * sets the light radius used by PBR Materials to simulate soft area lights.
  10279. */
  10280. radius: number;
  10281. private _renderPriority;
  10282. /**
  10283. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  10284. * exceeding the number allowed of the materials.
  10285. */
  10286. renderPriority: number;
  10287. private _shadowEnabled;
  10288. /**
  10289. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10290. * the current shadow generator.
  10291. */
  10292. /**
  10293. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10294. * the current shadow generator.
  10295. */
  10296. shadowEnabled: boolean;
  10297. private _includedOnlyMeshes;
  10298. /**
  10299. * Gets the only meshes impacted by this light.
  10300. */
  10301. /**
  10302. * Sets the only meshes impacted by this light.
  10303. */
  10304. includedOnlyMeshes: AbstractMesh[];
  10305. private _excludedMeshes;
  10306. /**
  10307. * Gets the meshes not impacted by this light.
  10308. */
  10309. /**
  10310. * Sets the meshes not impacted by this light.
  10311. */
  10312. excludedMeshes: AbstractMesh[];
  10313. private _excludeWithLayerMask;
  10314. /**
  10315. * Gets the layer id use to find what meshes are not impacted by the light.
  10316. * Inactive if 0
  10317. */
  10318. /**
  10319. * Sets the layer id use to find what meshes are not impacted by the light.
  10320. * Inactive if 0
  10321. */
  10322. excludeWithLayerMask: number;
  10323. private _includeOnlyWithLayerMask;
  10324. /**
  10325. * Gets the layer id use to find what meshes are impacted by the light.
  10326. * Inactive if 0
  10327. */
  10328. /**
  10329. * Sets the layer id use to find what meshes are impacted by the light.
  10330. * Inactive if 0
  10331. */
  10332. includeOnlyWithLayerMask: number;
  10333. private _lightmapMode;
  10334. /**
  10335. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10336. */
  10337. /**
  10338. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10339. */
  10340. lightmapMode: number;
  10341. /**
  10342. * Shadow generator associted to the light.
  10343. * @hidden Internal use only.
  10344. */
  10345. _shadowGenerator: Nullable<IShadowGenerator>;
  10346. /**
  10347. * @hidden Internal use only.
  10348. */
  10349. _excludedMeshesIds: string[];
  10350. /**
  10351. * @hidden Internal use only.
  10352. */
  10353. _includedOnlyMeshesIds: string[];
  10354. /**
  10355. * The current light unifom buffer.
  10356. * @hidden Internal use only.
  10357. */
  10358. _uniformBuffer: UniformBuffer;
  10359. /**
  10360. * Creates a Light object in the scene.
  10361. * Documentation : https://doc.babylonjs.com/babylon101/lights
  10362. * @param name The firendly name of the light
  10363. * @param scene The scene the light belongs too
  10364. */
  10365. constructor(name: string, scene: Scene);
  10366. protected abstract _buildUniformLayout(): void;
  10367. /**
  10368. * Sets the passed Effect "effect" with the Light information.
  10369. * @param effect The effect to update
  10370. * @param lightIndex The index of the light in the effect to update
  10371. * @returns The light
  10372. */
  10373. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  10374. /**
  10375. * Returns the string "Light".
  10376. * @returns the class name
  10377. */
  10378. getClassName(): string;
  10379. /** @hidden */
  10380. readonly _isLight: boolean;
  10381. /**
  10382. * Converts the light information to a readable string for debug purpose.
  10383. * @param fullDetails Supports for multiple levels of logging within scene loading
  10384. * @returns the human readable light info
  10385. */
  10386. toString(fullDetails?: boolean): string;
  10387. /** @hidden */
  10388. protected _syncParentEnabledState(): void;
  10389. /**
  10390. * Set the enabled state of this node.
  10391. * @param value - the new enabled state
  10392. */
  10393. setEnabled(value: boolean): void;
  10394. /**
  10395. * Returns the Light associated shadow generator if any.
  10396. * @return the associated shadow generator.
  10397. */
  10398. getShadowGenerator(): Nullable<IShadowGenerator>;
  10399. /**
  10400. * Returns a Vector3, the absolute light position in the World.
  10401. * @returns the world space position of the light
  10402. */
  10403. getAbsolutePosition(): Vector3;
  10404. /**
  10405. * Specifies if the light will affect the passed mesh.
  10406. * @param mesh The mesh to test against the light
  10407. * @return true the mesh is affected otherwise, false.
  10408. */
  10409. canAffectMesh(mesh: AbstractMesh): boolean;
  10410. /**
  10411. * Sort function to order lights for rendering.
  10412. * @param a First Light object to compare to second.
  10413. * @param b Second Light object to compare first.
  10414. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  10415. */
  10416. static CompareLightsPriority(a: Light, b: Light): number;
  10417. /**
  10418. * Releases resources associated with this node.
  10419. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10420. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10421. */
  10422. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10423. /**
  10424. * Returns the light type ID (integer).
  10425. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  10426. */
  10427. getTypeID(): number;
  10428. /**
  10429. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  10430. * @returns the scaled intensity in intensity mode unit
  10431. */
  10432. getScaledIntensity(): number;
  10433. /**
  10434. * Returns a new Light object, named "name", from the current one.
  10435. * @param name The name of the cloned light
  10436. * @returns the new created light
  10437. */
  10438. clone(name: string): Nullable<Light>;
  10439. /**
  10440. * Serializes the current light into a Serialization object.
  10441. * @returns the serialized object.
  10442. */
  10443. serialize(): any;
  10444. /**
  10445. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  10446. * This new light is named "name" and added to the passed scene.
  10447. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  10448. * @param name The friendly name of the light
  10449. * @param scene The scene the new light will belong to
  10450. * @returns the constructor function
  10451. */
  10452. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  10453. /**
  10454. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  10455. * @param parsedLight The JSON representation of the light
  10456. * @param scene The scene to create the parsed light in
  10457. * @returns the created light after parsing
  10458. */
  10459. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  10460. private _hookArrayForExcluded;
  10461. private _hookArrayForIncludedOnly;
  10462. private _resyncMeshes;
  10463. /**
  10464. * Forces the meshes to update their light related information in their rendering used effects
  10465. * @hidden Internal Use Only
  10466. */
  10467. _markMeshesAsLightDirty(): void;
  10468. /**
  10469. * Recomputes the cached photometric scale if needed.
  10470. */
  10471. private _computePhotometricScale;
  10472. /**
  10473. * Returns the Photometric Scale according to the light type and intensity mode.
  10474. */
  10475. private _getPhotometricScale;
  10476. /**
  10477. * Reorder the light in the scene according to their defined priority.
  10478. * @hidden Internal Use Only
  10479. */
  10480. _reorderLightsInScene(): void;
  10481. /**
  10482. * Prepares the list of defines specific to the light type.
  10483. * @param defines the list of defines
  10484. * @param lightIndex defines the index of the light for the effect
  10485. */
  10486. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  10487. }
  10488. }
  10489. declare module "babylonjs/Actions/action" {
  10490. import { Observable } from "babylonjs/Misc/observable";
  10491. import { Condition } from "babylonjs/Actions/condition";
  10492. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  10493. import { ActionManager } from "babylonjs/Actions/actionManager";
  10494. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10495. /**
  10496. * Interface used to define Action
  10497. */
  10498. export interface IAction {
  10499. /**
  10500. * Trigger for the action
  10501. */
  10502. trigger: number;
  10503. /** Options of the trigger */
  10504. triggerOptions: any;
  10505. /**
  10506. * Gets the trigger parameters
  10507. * @returns the trigger parameters
  10508. */
  10509. getTriggerParameter(): any;
  10510. /**
  10511. * Internal only - executes current action event
  10512. * @hidden
  10513. */
  10514. _executeCurrent(evt?: ActionEvent): void;
  10515. /**
  10516. * Serialize placeholder for child classes
  10517. * @param parent of child
  10518. * @returns the serialized object
  10519. */
  10520. serialize(parent: any): any;
  10521. /**
  10522. * Internal only
  10523. * @hidden
  10524. */
  10525. _prepare(): void;
  10526. /**
  10527. * Internal only - manager for action
  10528. * @hidden
  10529. */
  10530. _actionManager: AbstractActionManager;
  10531. }
  10532. /**
  10533. * The action to be carried out following a trigger
  10534. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  10535. */
  10536. export class Action implements IAction {
  10537. /** the trigger, with or without parameters, for the action */
  10538. triggerOptions: any;
  10539. /**
  10540. * Trigger for the action
  10541. */
  10542. trigger: number;
  10543. /**
  10544. * Internal only - manager for action
  10545. * @hidden
  10546. */
  10547. _actionManager: ActionManager;
  10548. private _nextActiveAction;
  10549. private _child;
  10550. private _condition?;
  10551. private _triggerParameter;
  10552. /**
  10553. * An event triggered prior to action being executed.
  10554. */
  10555. onBeforeExecuteObservable: Observable<Action>;
  10556. /**
  10557. * Creates a new Action
  10558. * @param triggerOptions the trigger, with or without parameters, for the action
  10559. * @param condition an optional determinant of action
  10560. */
  10561. constructor(
  10562. /** the trigger, with or without parameters, for the action */
  10563. triggerOptions: any, condition?: Condition);
  10564. /**
  10565. * Internal only
  10566. * @hidden
  10567. */
  10568. _prepare(): void;
  10569. /**
  10570. * Gets the trigger parameters
  10571. * @returns the trigger parameters
  10572. */
  10573. getTriggerParameter(): any;
  10574. /**
  10575. * Internal only - executes current action event
  10576. * @hidden
  10577. */
  10578. _executeCurrent(evt?: ActionEvent): void;
  10579. /**
  10580. * Execute placeholder for child classes
  10581. * @param evt optional action event
  10582. */
  10583. execute(evt?: ActionEvent): void;
  10584. /**
  10585. * Skips to next active action
  10586. */
  10587. skipToNextActiveAction(): void;
  10588. /**
  10589. * Adds action to chain of actions, may be a DoNothingAction
  10590. * @param action defines the next action to execute
  10591. * @returns The action passed in
  10592. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10593. */
  10594. then(action: Action): Action;
  10595. /**
  10596. * Internal only
  10597. * @hidden
  10598. */
  10599. _getProperty(propertyPath: string): string;
  10600. /**
  10601. * Internal only
  10602. * @hidden
  10603. */
  10604. _getEffectiveTarget(target: any, propertyPath: string): any;
  10605. /**
  10606. * Serialize placeholder for child classes
  10607. * @param parent of child
  10608. * @returns the serialized object
  10609. */
  10610. serialize(parent: any): any;
  10611. /**
  10612. * Internal only called by serialize
  10613. * @hidden
  10614. */
  10615. protected _serialize(serializedAction: any, parent?: any): any;
  10616. /**
  10617. * Internal only
  10618. * @hidden
  10619. */
  10620. static _SerializeValueAsString: (value: any) => string;
  10621. /**
  10622. * Internal only
  10623. * @hidden
  10624. */
  10625. static _GetTargetProperty: (target: import("babylonjs/scene").Scene | import("babylonjs/node").Node) => {
  10626. name: string;
  10627. targetType: string;
  10628. value: string;
  10629. };
  10630. }
  10631. }
  10632. declare module "babylonjs/Actions/condition" {
  10633. import { ActionManager } from "babylonjs/Actions/actionManager";
  10634. /**
  10635. * A Condition applied to an Action
  10636. */
  10637. export class Condition {
  10638. /**
  10639. * Internal only - manager for action
  10640. * @hidden
  10641. */
  10642. _actionManager: ActionManager;
  10643. /**
  10644. * Internal only
  10645. * @hidden
  10646. */
  10647. _evaluationId: number;
  10648. /**
  10649. * Internal only
  10650. * @hidden
  10651. */
  10652. _currentResult: boolean;
  10653. /**
  10654. * Creates a new Condition
  10655. * @param actionManager the manager of the action the condition is applied to
  10656. */
  10657. constructor(actionManager: ActionManager);
  10658. /**
  10659. * Check if the current condition is valid
  10660. * @returns a boolean
  10661. */
  10662. isValid(): boolean;
  10663. /**
  10664. * Internal only
  10665. * @hidden
  10666. */
  10667. _getProperty(propertyPath: string): string;
  10668. /**
  10669. * Internal only
  10670. * @hidden
  10671. */
  10672. _getEffectiveTarget(target: any, propertyPath: string): any;
  10673. /**
  10674. * Serialize placeholder for child classes
  10675. * @returns the serialized object
  10676. */
  10677. serialize(): any;
  10678. /**
  10679. * Internal only
  10680. * @hidden
  10681. */
  10682. protected _serialize(serializedCondition: any): any;
  10683. }
  10684. /**
  10685. * Defines specific conditional operators as extensions of Condition
  10686. */
  10687. export class ValueCondition extends Condition {
  10688. /** path to specify the property of the target the conditional operator uses */
  10689. propertyPath: string;
  10690. /** the value compared by the conditional operator against the current value of the property */
  10691. value: any;
  10692. /** the conditional operator, default ValueCondition.IsEqual */
  10693. operator: number;
  10694. /**
  10695. * Internal only
  10696. * @hidden
  10697. */
  10698. private static _IsEqual;
  10699. /**
  10700. * Internal only
  10701. * @hidden
  10702. */
  10703. private static _IsDifferent;
  10704. /**
  10705. * Internal only
  10706. * @hidden
  10707. */
  10708. private static _IsGreater;
  10709. /**
  10710. * Internal only
  10711. * @hidden
  10712. */
  10713. private static _IsLesser;
  10714. /**
  10715. * returns the number for IsEqual
  10716. */
  10717. static readonly IsEqual: number;
  10718. /**
  10719. * Returns the number for IsDifferent
  10720. */
  10721. static readonly IsDifferent: number;
  10722. /**
  10723. * Returns the number for IsGreater
  10724. */
  10725. static readonly IsGreater: number;
  10726. /**
  10727. * Returns the number for IsLesser
  10728. */
  10729. static readonly IsLesser: number;
  10730. /**
  10731. * Internal only The action manager for the condition
  10732. * @hidden
  10733. */
  10734. _actionManager: ActionManager;
  10735. /**
  10736. * Internal only
  10737. * @hidden
  10738. */
  10739. private _target;
  10740. /**
  10741. * Internal only
  10742. * @hidden
  10743. */
  10744. private _effectiveTarget;
  10745. /**
  10746. * Internal only
  10747. * @hidden
  10748. */
  10749. private _property;
  10750. /**
  10751. * Creates a new ValueCondition
  10752. * @param actionManager manager for the action the condition applies to
  10753. * @param target for the action
  10754. * @param propertyPath path to specify the property of the target the conditional operator uses
  10755. * @param value the value compared by the conditional operator against the current value of the property
  10756. * @param operator the conditional operator, default ValueCondition.IsEqual
  10757. */
  10758. constructor(actionManager: ActionManager, target: any,
  10759. /** path to specify the property of the target the conditional operator uses */
  10760. propertyPath: string,
  10761. /** the value compared by the conditional operator against the current value of the property */
  10762. value: any,
  10763. /** the conditional operator, default ValueCondition.IsEqual */
  10764. operator?: number);
  10765. /**
  10766. * Compares the given value with the property value for the specified conditional operator
  10767. * @returns the result of the comparison
  10768. */
  10769. isValid(): boolean;
  10770. /**
  10771. * Serialize the ValueCondition into a JSON compatible object
  10772. * @returns serialization object
  10773. */
  10774. serialize(): any;
  10775. /**
  10776. * Gets the name of the conditional operator for the ValueCondition
  10777. * @param operator the conditional operator
  10778. * @returns the name
  10779. */
  10780. static GetOperatorName(operator: number): string;
  10781. }
  10782. /**
  10783. * Defines a predicate condition as an extension of Condition
  10784. */
  10785. export class PredicateCondition extends Condition {
  10786. /** defines the predicate function used to validate the condition */
  10787. predicate: () => boolean;
  10788. /**
  10789. * Internal only - manager for action
  10790. * @hidden
  10791. */
  10792. _actionManager: ActionManager;
  10793. /**
  10794. * Creates a new PredicateCondition
  10795. * @param actionManager manager for the action the condition applies to
  10796. * @param predicate defines the predicate function used to validate the condition
  10797. */
  10798. constructor(actionManager: ActionManager,
  10799. /** defines the predicate function used to validate the condition */
  10800. predicate: () => boolean);
  10801. /**
  10802. * @returns the validity of the predicate condition
  10803. */
  10804. isValid(): boolean;
  10805. }
  10806. /**
  10807. * Defines a state condition as an extension of Condition
  10808. */
  10809. export class StateCondition extends Condition {
  10810. /** Value to compare with target state */
  10811. value: string;
  10812. /**
  10813. * Internal only - manager for action
  10814. * @hidden
  10815. */
  10816. _actionManager: ActionManager;
  10817. /**
  10818. * Internal only
  10819. * @hidden
  10820. */
  10821. private _target;
  10822. /**
  10823. * Creates a new StateCondition
  10824. * @param actionManager manager for the action the condition applies to
  10825. * @param target of the condition
  10826. * @param value to compare with target state
  10827. */
  10828. constructor(actionManager: ActionManager, target: any,
  10829. /** Value to compare with target state */
  10830. value: string);
  10831. /**
  10832. * Gets a boolean indicating if the current condition is met
  10833. * @returns the validity of the state
  10834. */
  10835. isValid(): boolean;
  10836. /**
  10837. * Serialize the StateCondition into a JSON compatible object
  10838. * @returns serialization object
  10839. */
  10840. serialize(): any;
  10841. }
  10842. }
  10843. declare module "babylonjs/Actions/directActions" {
  10844. import { Action } from "babylonjs/Actions/action";
  10845. import { Condition } from "babylonjs/Actions/condition";
  10846. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10847. /**
  10848. * This defines an action responsible to toggle a boolean once triggered.
  10849. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10850. */
  10851. export class SwitchBooleanAction extends Action {
  10852. /**
  10853. * The path to the boolean property in the target object
  10854. */
  10855. propertyPath: string;
  10856. private _target;
  10857. private _effectiveTarget;
  10858. private _property;
  10859. /**
  10860. * Instantiate the action
  10861. * @param triggerOptions defines the trigger options
  10862. * @param target defines the object containing the boolean
  10863. * @param propertyPath defines the path to the boolean property in the target object
  10864. * @param condition defines the trigger related conditions
  10865. */
  10866. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  10867. /** @hidden */
  10868. _prepare(): void;
  10869. /**
  10870. * Execute the action toggle the boolean value.
  10871. */
  10872. execute(): void;
  10873. /**
  10874. * Serializes the actions and its related information.
  10875. * @param parent defines the object to serialize in
  10876. * @returns the serialized object
  10877. */
  10878. serialize(parent: any): any;
  10879. }
  10880. /**
  10881. * This defines an action responsible to set a the state field of the target
  10882. * to a desired value once triggered.
  10883. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10884. */
  10885. export class SetStateAction extends Action {
  10886. /**
  10887. * The value to store in the state field.
  10888. */
  10889. value: string;
  10890. private _target;
  10891. /**
  10892. * Instantiate the action
  10893. * @param triggerOptions defines the trigger options
  10894. * @param target defines the object containing the state property
  10895. * @param value defines the value to store in the state field
  10896. * @param condition defines the trigger related conditions
  10897. */
  10898. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10899. /**
  10900. * Execute the action and store the value on the target state property.
  10901. */
  10902. execute(): void;
  10903. /**
  10904. * Serializes the actions and its related information.
  10905. * @param parent defines the object to serialize in
  10906. * @returns the serialized object
  10907. */
  10908. serialize(parent: any): any;
  10909. }
  10910. /**
  10911. * This defines an action responsible to set a property of the target
  10912. * to a desired value once triggered.
  10913. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10914. */
  10915. export class SetValueAction extends Action {
  10916. /**
  10917. * The path of the property to set in the target.
  10918. */
  10919. propertyPath: string;
  10920. /**
  10921. * The value to set in the property
  10922. */
  10923. value: any;
  10924. private _target;
  10925. private _effectiveTarget;
  10926. private _property;
  10927. /**
  10928. * Instantiate the action
  10929. * @param triggerOptions defines the trigger options
  10930. * @param target defines the object containing the property
  10931. * @param propertyPath defines the path of the property to set in the target
  10932. * @param value defines the value to set in the property
  10933. * @param condition defines the trigger related conditions
  10934. */
  10935. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10936. /** @hidden */
  10937. _prepare(): void;
  10938. /**
  10939. * Execute the action and set the targetted property to the desired value.
  10940. */
  10941. execute(): void;
  10942. /**
  10943. * Serializes the actions and its related information.
  10944. * @param parent defines the object to serialize in
  10945. * @returns the serialized object
  10946. */
  10947. serialize(parent: any): any;
  10948. }
  10949. /**
  10950. * This defines an action responsible to increment the target value
  10951. * to a desired value once triggered.
  10952. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10953. */
  10954. export class IncrementValueAction extends Action {
  10955. /**
  10956. * The path of the property to increment in the target.
  10957. */
  10958. propertyPath: string;
  10959. /**
  10960. * The value we should increment the property by.
  10961. */
  10962. value: any;
  10963. private _target;
  10964. private _effectiveTarget;
  10965. private _property;
  10966. /**
  10967. * Instantiate the action
  10968. * @param triggerOptions defines the trigger options
  10969. * @param target defines the object containing the property
  10970. * @param propertyPath defines the path of the property to increment in the target
  10971. * @param value defines the value value we should increment the property by
  10972. * @param condition defines the trigger related conditions
  10973. */
  10974. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10975. /** @hidden */
  10976. _prepare(): void;
  10977. /**
  10978. * Execute the action and increment the target of the value amount.
  10979. */
  10980. execute(): void;
  10981. /**
  10982. * Serializes the actions and its related information.
  10983. * @param parent defines the object to serialize in
  10984. * @returns the serialized object
  10985. */
  10986. serialize(parent: any): any;
  10987. }
  10988. /**
  10989. * This defines an action responsible to start an animation once triggered.
  10990. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10991. */
  10992. export class PlayAnimationAction extends Action {
  10993. /**
  10994. * Where the animation should start (animation frame)
  10995. */
  10996. from: number;
  10997. /**
  10998. * Where the animation should stop (animation frame)
  10999. */
  11000. to: number;
  11001. /**
  11002. * Define if the animation should loop or stop after the first play.
  11003. */
  11004. loop?: boolean;
  11005. private _target;
  11006. /**
  11007. * Instantiate the action
  11008. * @param triggerOptions defines the trigger options
  11009. * @param target defines the target animation or animation name
  11010. * @param from defines from where the animation should start (animation frame)
  11011. * @param end defines where the animation should stop (animation frame)
  11012. * @param loop defines if the animation should loop or stop after the first play
  11013. * @param condition defines the trigger related conditions
  11014. */
  11015. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  11016. /** @hidden */
  11017. _prepare(): void;
  11018. /**
  11019. * Execute the action and play the animation.
  11020. */
  11021. execute(): void;
  11022. /**
  11023. * Serializes the actions and its related information.
  11024. * @param parent defines the object to serialize in
  11025. * @returns the serialized object
  11026. */
  11027. serialize(parent: any): any;
  11028. }
  11029. /**
  11030. * This defines an action responsible to stop an animation once triggered.
  11031. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11032. */
  11033. export class StopAnimationAction extends Action {
  11034. private _target;
  11035. /**
  11036. * Instantiate the action
  11037. * @param triggerOptions defines the trigger options
  11038. * @param target defines the target animation or animation name
  11039. * @param condition defines the trigger related conditions
  11040. */
  11041. constructor(triggerOptions: any, target: any, condition?: Condition);
  11042. /** @hidden */
  11043. _prepare(): void;
  11044. /**
  11045. * Execute the action and stop the animation.
  11046. */
  11047. execute(): void;
  11048. /**
  11049. * Serializes the actions and its related information.
  11050. * @param parent defines the object to serialize in
  11051. * @returns the serialized object
  11052. */
  11053. serialize(parent: any): any;
  11054. }
  11055. /**
  11056. * This defines an action responsible that does nothing once triggered.
  11057. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11058. */
  11059. export class DoNothingAction extends Action {
  11060. /**
  11061. * Instantiate the action
  11062. * @param triggerOptions defines the trigger options
  11063. * @param condition defines the trigger related conditions
  11064. */
  11065. constructor(triggerOptions?: any, condition?: Condition);
  11066. /**
  11067. * Execute the action and do nothing.
  11068. */
  11069. execute(): void;
  11070. /**
  11071. * Serializes the actions and its related information.
  11072. * @param parent defines the object to serialize in
  11073. * @returns the serialized object
  11074. */
  11075. serialize(parent: any): any;
  11076. }
  11077. /**
  11078. * This defines an action responsible to trigger several actions once triggered.
  11079. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11080. */
  11081. export class CombineAction extends Action {
  11082. /**
  11083. * The list of aggregated animations to run.
  11084. */
  11085. children: Action[];
  11086. /**
  11087. * Instantiate the action
  11088. * @param triggerOptions defines the trigger options
  11089. * @param children defines the list of aggregated animations to run
  11090. * @param condition defines the trigger related conditions
  11091. */
  11092. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  11093. /** @hidden */
  11094. _prepare(): void;
  11095. /**
  11096. * Execute the action and executes all the aggregated actions.
  11097. */
  11098. execute(evt: ActionEvent): void;
  11099. /**
  11100. * Serializes the actions and its related information.
  11101. * @param parent defines the object to serialize in
  11102. * @returns the serialized object
  11103. */
  11104. serialize(parent: any): any;
  11105. }
  11106. /**
  11107. * This defines an action responsible to run code (external event) once triggered.
  11108. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11109. */
  11110. export class ExecuteCodeAction extends Action {
  11111. /**
  11112. * The callback function to run.
  11113. */
  11114. func: (evt: ActionEvent) => void;
  11115. /**
  11116. * Instantiate the action
  11117. * @param triggerOptions defines the trigger options
  11118. * @param func defines the callback function to run
  11119. * @param condition defines the trigger related conditions
  11120. */
  11121. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  11122. /**
  11123. * Execute the action and run the attached code.
  11124. */
  11125. execute(evt: ActionEvent): void;
  11126. }
  11127. /**
  11128. * This defines an action responsible to set the parent property of the target once triggered.
  11129. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11130. */
  11131. export class SetParentAction extends Action {
  11132. private _parent;
  11133. private _target;
  11134. /**
  11135. * Instantiate the action
  11136. * @param triggerOptions defines the trigger options
  11137. * @param target defines the target containing the parent property
  11138. * @param parent defines from where the animation should start (animation frame)
  11139. * @param condition defines the trigger related conditions
  11140. */
  11141. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  11142. /** @hidden */
  11143. _prepare(): void;
  11144. /**
  11145. * Execute the action and set the parent property.
  11146. */
  11147. execute(): void;
  11148. /**
  11149. * Serializes the actions and its related information.
  11150. * @param parent defines the object to serialize in
  11151. * @returns the serialized object
  11152. */
  11153. serialize(parent: any): any;
  11154. }
  11155. }
  11156. declare module "babylonjs/Actions/actionManager" {
  11157. import { Nullable } from "babylonjs/types";
  11158. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11159. import { Scene } from "babylonjs/scene";
  11160. import { IAction } from "babylonjs/Actions/action";
  11161. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  11162. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  11163. /**
  11164. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  11165. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  11166. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11167. */
  11168. export class ActionManager extends AbstractActionManager {
  11169. /**
  11170. * Nothing
  11171. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11172. */
  11173. static readonly NothingTrigger: number;
  11174. /**
  11175. * On pick
  11176. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11177. */
  11178. static readonly OnPickTrigger: number;
  11179. /**
  11180. * On left pick
  11181. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11182. */
  11183. static readonly OnLeftPickTrigger: number;
  11184. /**
  11185. * On right pick
  11186. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11187. */
  11188. static readonly OnRightPickTrigger: number;
  11189. /**
  11190. * On center pick
  11191. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11192. */
  11193. static readonly OnCenterPickTrigger: number;
  11194. /**
  11195. * On pick down
  11196. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11197. */
  11198. static readonly OnPickDownTrigger: number;
  11199. /**
  11200. * On double pick
  11201. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11202. */
  11203. static readonly OnDoublePickTrigger: number;
  11204. /**
  11205. * On pick up
  11206. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11207. */
  11208. static readonly OnPickUpTrigger: number;
  11209. /**
  11210. * On pick out.
  11211. * This trigger will only be raised if you also declared a OnPickDown
  11212. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11213. */
  11214. static readonly OnPickOutTrigger: number;
  11215. /**
  11216. * On long press
  11217. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11218. */
  11219. static readonly OnLongPressTrigger: number;
  11220. /**
  11221. * On pointer over
  11222. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11223. */
  11224. static readonly OnPointerOverTrigger: number;
  11225. /**
  11226. * On pointer out
  11227. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11228. */
  11229. static readonly OnPointerOutTrigger: number;
  11230. /**
  11231. * On every frame
  11232. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11233. */
  11234. static readonly OnEveryFrameTrigger: number;
  11235. /**
  11236. * On intersection enter
  11237. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11238. */
  11239. static readonly OnIntersectionEnterTrigger: number;
  11240. /**
  11241. * On intersection exit
  11242. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11243. */
  11244. static readonly OnIntersectionExitTrigger: number;
  11245. /**
  11246. * On key down
  11247. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11248. */
  11249. static readonly OnKeyDownTrigger: number;
  11250. /**
  11251. * On key up
  11252. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11253. */
  11254. static readonly OnKeyUpTrigger: number;
  11255. private _scene;
  11256. /**
  11257. * Creates a new action manager
  11258. * @param scene defines the hosting scene
  11259. */
  11260. constructor(scene: Scene);
  11261. /**
  11262. * Releases all associated resources
  11263. */
  11264. dispose(): void;
  11265. /**
  11266. * Gets hosting scene
  11267. * @returns the hosting scene
  11268. */
  11269. getScene(): Scene;
  11270. /**
  11271. * Does this action manager handles actions of any of the given triggers
  11272. * @param triggers defines the triggers to be tested
  11273. * @return a boolean indicating whether one (or more) of the triggers is handled
  11274. */
  11275. hasSpecificTriggers(triggers: number[]): boolean;
  11276. /**
  11277. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  11278. * speed.
  11279. * @param triggerA defines the trigger to be tested
  11280. * @param triggerB defines the trigger to be tested
  11281. * @return a boolean indicating whether one (or more) of the triggers is handled
  11282. */
  11283. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  11284. /**
  11285. * Does this action manager handles actions of a given trigger
  11286. * @param trigger defines the trigger to be tested
  11287. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  11288. * @return whether the trigger is handled
  11289. */
  11290. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  11291. /**
  11292. * Does this action manager has pointer triggers
  11293. */
  11294. readonly hasPointerTriggers: boolean;
  11295. /**
  11296. * Does this action manager has pick triggers
  11297. */
  11298. readonly hasPickTriggers: boolean;
  11299. /**
  11300. * Registers an action to this action manager
  11301. * @param action defines the action to be registered
  11302. * @return the action amended (prepared) after registration
  11303. */
  11304. registerAction(action: IAction): Nullable<IAction>;
  11305. /**
  11306. * Unregisters an action to this action manager
  11307. * @param action defines the action to be unregistered
  11308. * @return a boolean indicating whether the action has been unregistered
  11309. */
  11310. unregisterAction(action: IAction): Boolean;
  11311. /**
  11312. * Process a specific trigger
  11313. * @param trigger defines the trigger to process
  11314. * @param evt defines the event details to be processed
  11315. */
  11316. processTrigger(trigger: number, evt?: IActionEvent): void;
  11317. /** @hidden */
  11318. _getEffectiveTarget(target: any, propertyPath: string): any;
  11319. /** @hidden */
  11320. _getProperty(propertyPath: string): string;
  11321. /**
  11322. * Serialize this manager to a JSON object
  11323. * @param name defines the property name to store this manager
  11324. * @returns a JSON representation of this manager
  11325. */
  11326. serialize(name: string): any;
  11327. /**
  11328. * Creates a new ActionManager from a JSON data
  11329. * @param parsedActions defines the JSON data to read from
  11330. * @param object defines the hosting mesh
  11331. * @param scene defines the hosting scene
  11332. */
  11333. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  11334. /**
  11335. * Get a trigger name by index
  11336. * @param trigger defines the trigger index
  11337. * @returns a trigger name
  11338. */
  11339. static GetTriggerName(trigger: number): string;
  11340. }
  11341. }
  11342. declare module "babylonjs/Culling/ray" {
  11343. import { DeepImmutable, Nullable, float } from "babylonjs/types";
  11344. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  11345. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11346. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11347. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  11348. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  11349. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  11350. /**
  11351. * Class representing a ray with position and direction
  11352. */
  11353. export class Ray {
  11354. /** origin point */
  11355. origin: Vector3;
  11356. /** direction */
  11357. direction: Vector3;
  11358. /** length of the ray */
  11359. length: number;
  11360. private static readonly TmpVector3;
  11361. private _tmpRay;
  11362. /**
  11363. * Creates a new ray
  11364. * @param origin origin point
  11365. * @param direction direction
  11366. * @param length length of the ray
  11367. */
  11368. constructor(
  11369. /** origin point */
  11370. origin: Vector3,
  11371. /** direction */
  11372. direction: Vector3,
  11373. /** length of the ray */
  11374. length?: number);
  11375. /**
  11376. * Checks if the ray intersects a box
  11377. * @param minimum bound of the box
  11378. * @param maximum bound of the box
  11379. * @param intersectionTreshold extra extend to be added to the box in all direction
  11380. * @returns if the box was hit
  11381. */
  11382. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  11383. /**
  11384. * Checks if the ray intersects a box
  11385. * @param box the bounding box to check
  11386. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  11387. * @returns if the box was hit
  11388. */
  11389. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  11390. /**
  11391. * If the ray hits a sphere
  11392. * @param sphere the bounding sphere to check
  11393. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  11394. * @returns true if it hits the sphere
  11395. */
  11396. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  11397. /**
  11398. * If the ray hits a triange
  11399. * @param vertex0 triangle vertex
  11400. * @param vertex1 triangle vertex
  11401. * @param vertex2 triangle vertex
  11402. * @returns intersection information if hit
  11403. */
  11404. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  11405. /**
  11406. * Checks if ray intersects a plane
  11407. * @param plane the plane to check
  11408. * @returns the distance away it was hit
  11409. */
  11410. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  11411. /**
  11412. * Checks if ray intersects a mesh
  11413. * @param mesh the mesh to check
  11414. * @param fastCheck if only the bounding box should checked
  11415. * @returns picking info of the intersecton
  11416. */
  11417. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  11418. /**
  11419. * Checks if ray intersects a mesh
  11420. * @param meshes the meshes to check
  11421. * @param fastCheck if only the bounding box should checked
  11422. * @param results array to store result in
  11423. * @returns Array of picking infos
  11424. */
  11425. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  11426. private _comparePickingInfo;
  11427. private static smallnum;
  11428. private static rayl;
  11429. /**
  11430. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  11431. * @param sega the first point of the segment to test the intersection against
  11432. * @param segb the second point of the segment to test the intersection against
  11433. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  11434. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  11435. */
  11436. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  11437. /**
  11438. * Update the ray from viewport position
  11439. * @param x position
  11440. * @param y y position
  11441. * @param viewportWidth viewport width
  11442. * @param viewportHeight viewport height
  11443. * @param world world matrix
  11444. * @param view view matrix
  11445. * @param projection projection matrix
  11446. * @returns this ray updated
  11447. */
  11448. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11449. /**
  11450. * Creates a ray with origin and direction of 0,0,0
  11451. * @returns the new ray
  11452. */
  11453. static Zero(): Ray;
  11454. /**
  11455. * Creates a new ray from screen space and viewport
  11456. * @param x position
  11457. * @param y y position
  11458. * @param viewportWidth viewport width
  11459. * @param viewportHeight viewport height
  11460. * @param world world matrix
  11461. * @param view view matrix
  11462. * @param projection projection matrix
  11463. * @returns new ray
  11464. */
  11465. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11466. /**
  11467. * 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
  11468. * transformed to the given world matrix.
  11469. * @param origin The origin point
  11470. * @param end The end point
  11471. * @param world a matrix to transform the ray to. Default is the identity matrix.
  11472. * @returns the new ray
  11473. */
  11474. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  11475. /**
  11476. * Transforms a ray by a matrix
  11477. * @param ray ray to transform
  11478. * @param matrix matrix to apply
  11479. * @returns the resulting new ray
  11480. */
  11481. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  11482. /**
  11483. * Transforms a ray by a matrix
  11484. * @param ray ray to transform
  11485. * @param matrix matrix to apply
  11486. * @param result ray to store result in
  11487. */
  11488. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  11489. /**
  11490. * Unproject a ray from screen space to object space
  11491. * @param sourceX defines the screen space x coordinate to use
  11492. * @param sourceY defines the screen space y coordinate to use
  11493. * @param viewportWidth defines the current width of the viewport
  11494. * @param viewportHeight defines the current height of the viewport
  11495. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  11496. * @param view defines the view matrix to use
  11497. * @param projection defines the projection matrix to use
  11498. */
  11499. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  11500. }
  11501. /**
  11502. * Type used to define predicate used to select faces when a mesh intersection is detected
  11503. */
  11504. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  11505. module "babylonjs/scene" {
  11506. interface Scene {
  11507. /** @hidden */
  11508. _tempPickingRay: Nullable<Ray>;
  11509. /** @hidden */
  11510. _cachedRayForTransform: Ray;
  11511. /** @hidden */
  11512. _pickWithRayInverseMatrix: Matrix;
  11513. /** @hidden */
  11514. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  11515. /** @hidden */
  11516. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  11517. }
  11518. }
  11519. }
  11520. declare module "babylonjs/sceneComponent" {
  11521. import { Scene } from "babylonjs/scene";
  11522. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11523. import { SubMesh } from "babylonjs/Meshes/subMesh";
  11524. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  11525. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  11526. import { Nullable } from "babylonjs/types";
  11527. import { Camera } from "babylonjs/Cameras/camera";
  11528. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  11529. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11530. import { AbstractScene } from "babylonjs/abstractScene";
  11531. /**
  11532. * Groups all the scene component constants in one place to ease maintenance.
  11533. * @hidden
  11534. */
  11535. export class SceneComponentConstants {
  11536. static readonly NAME_EFFECTLAYER: string;
  11537. static readonly NAME_LAYER: string;
  11538. static readonly NAME_LENSFLARESYSTEM: string;
  11539. static readonly NAME_BOUNDINGBOXRENDERER: string;
  11540. static readonly NAME_PARTICLESYSTEM: string;
  11541. static readonly NAME_GAMEPAD: string;
  11542. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  11543. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  11544. static readonly NAME_DEPTHRENDERER: string;
  11545. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  11546. static readonly NAME_SPRITE: string;
  11547. static readonly NAME_OUTLINERENDERER: string;
  11548. static readonly NAME_PROCEDURALTEXTURE: string;
  11549. static readonly NAME_SHADOWGENERATOR: string;
  11550. static readonly NAME_OCTREE: string;
  11551. static readonly NAME_PHYSICSENGINE: string;
  11552. static readonly NAME_AUDIO: string;
  11553. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  11554. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11555. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  11556. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11557. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  11558. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  11559. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  11560. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  11561. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  11562. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  11563. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  11564. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  11565. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  11566. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  11567. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  11568. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  11569. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  11570. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  11571. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  11572. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  11573. static readonly STEP_AFTERRENDER_AUDIO: number;
  11574. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  11575. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  11576. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  11577. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  11578. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  11579. static readonly STEP_POINTERMOVE_SPRITE: number;
  11580. static readonly STEP_POINTERDOWN_SPRITE: number;
  11581. static readonly STEP_POINTERUP_SPRITE: number;
  11582. }
  11583. /**
  11584. * This represents a scene component.
  11585. *
  11586. * This is used to decouple the dependency the scene is having on the different workloads like
  11587. * layers, post processes...
  11588. */
  11589. export interface ISceneComponent {
  11590. /**
  11591. * The name of the component. Each component must have a unique name.
  11592. */
  11593. name: string;
  11594. /**
  11595. * The scene the component belongs to.
  11596. */
  11597. scene: Scene;
  11598. /**
  11599. * Register the component to one instance of a scene.
  11600. */
  11601. register(): void;
  11602. /**
  11603. * Rebuilds the elements related to this component in case of
  11604. * context lost for instance.
  11605. */
  11606. rebuild(): void;
  11607. /**
  11608. * Disposes the component and the associated ressources.
  11609. */
  11610. dispose(): void;
  11611. }
  11612. /**
  11613. * This represents a SERIALIZABLE scene component.
  11614. *
  11615. * This extends Scene Component to add Serialization methods on top.
  11616. */
  11617. export interface ISceneSerializableComponent extends ISceneComponent {
  11618. /**
  11619. * Adds all the element from the container to the scene
  11620. * @param container the container holding the elements
  11621. */
  11622. addFromContainer(container: AbstractScene): void;
  11623. /**
  11624. * Removes all the elements in the container from the scene
  11625. * @param container contains the elements to remove
  11626. * @param dispose if the removed element should be disposed (default: false)
  11627. */
  11628. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  11629. /**
  11630. * Serializes the component data to the specified json object
  11631. * @param serializationObject The object to serialize to
  11632. */
  11633. serialize(serializationObject: any): void;
  11634. }
  11635. /**
  11636. * Strong typing of a Mesh related stage step action
  11637. */
  11638. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11639. /**
  11640. * Strong typing of a Evaluate Sub Mesh related stage step action
  11641. */
  11642. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11643. /**
  11644. * Strong typing of a Active Mesh related stage step action
  11645. */
  11646. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  11647. /**
  11648. * Strong typing of a Camera related stage step action
  11649. */
  11650. export type CameraStageAction = (camera: Camera) => void;
  11651. /**
  11652. * Strong typing of a Render Target related stage step action
  11653. */
  11654. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11655. /**
  11656. * Strong typing of a RenderingGroup related stage step action
  11657. */
  11658. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11659. /**
  11660. * Strong typing of a Mesh Render related stage step action
  11661. */
  11662. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11663. /**
  11664. * Strong typing of a simple stage step action
  11665. */
  11666. export type SimpleStageAction = () => void;
  11667. /**
  11668. * Strong typing of a render target action.
  11669. */
  11670. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11671. /**
  11672. * Strong typing of a pointer move action.
  11673. */
  11674. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  11675. /**
  11676. * Strong typing of a pointer up/down action.
  11677. */
  11678. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11679. /**
  11680. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  11681. * @hidden
  11682. */
  11683. export class Stage<T extends Function> extends Array<{
  11684. index: number;
  11685. component: ISceneComponent;
  11686. action: T;
  11687. }> {
  11688. /**
  11689. * Hide ctor from the rest of the world.
  11690. * @param items The items to add.
  11691. */
  11692. private constructor();
  11693. /**
  11694. * Creates a new Stage.
  11695. * @returns A new instance of a Stage
  11696. */
  11697. static Create<T extends Function>(): Stage<T>;
  11698. /**
  11699. * Registers a step in an ordered way in the targeted stage.
  11700. * @param index Defines the position to register the step in
  11701. * @param component Defines the component attached to the step
  11702. * @param action Defines the action to launch during the step
  11703. */
  11704. registerStep(index: number, component: ISceneComponent, action: T): void;
  11705. /**
  11706. * Clears all the steps from the stage.
  11707. */
  11708. clear(): void;
  11709. }
  11710. }
  11711. declare module "babylonjs/Sprites/spriteSceneComponent" {
  11712. import { Nullable } from "babylonjs/types";
  11713. import { Observable } from "babylonjs/Misc/observable";
  11714. import { Scene } from "babylonjs/scene";
  11715. import { Sprite } from "babylonjs/Sprites/sprite";
  11716. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11717. import { Ray } from "babylonjs/Culling/ray";
  11718. import { Camera } from "babylonjs/Cameras/camera";
  11719. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11720. import { ISceneComponent } from "babylonjs/sceneComponent";
  11721. module "babylonjs/scene" {
  11722. interface Scene {
  11723. /** @hidden */
  11724. _pointerOverSprite: Nullable<Sprite>;
  11725. /** @hidden */
  11726. _pickedDownSprite: Nullable<Sprite>;
  11727. /** @hidden */
  11728. _tempSpritePickingRay: Nullable<Ray>;
  11729. /**
  11730. * All of the sprite managers added to this scene
  11731. * @see http://doc.babylonjs.com/babylon101/sprites
  11732. */
  11733. spriteManagers: Array<ISpriteManager>;
  11734. /**
  11735. * An event triggered when sprites rendering is about to start
  11736. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11737. */
  11738. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11739. /**
  11740. * An event triggered when sprites rendering is done
  11741. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11742. */
  11743. onAfterSpritesRenderingObservable: Observable<Scene>;
  11744. /** @hidden */
  11745. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11746. /** Launch a ray to try to pick a sprite in the scene
  11747. * @param x position on screen
  11748. * @param y position on screen
  11749. * @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
  11750. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11751. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11752. * @returns a PickingInfo
  11753. */
  11754. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11755. /** Use the given ray to pick a sprite in the scene
  11756. * @param ray The ray (in world space) to use to pick meshes
  11757. * @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
  11758. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11759. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11760. * @returns a PickingInfo
  11761. */
  11762. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11763. /**
  11764. * Force the sprite under the pointer
  11765. * @param sprite defines the sprite to use
  11766. */
  11767. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11768. /**
  11769. * Gets the sprite under the pointer
  11770. * @returns a Sprite or null if no sprite is under the pointer
  11771. */
  11772. getPointerOverSprite(): Nullable<Sprite>;
  11773. }
  11774. }
  11775. /**
  11776. * Defines the sprite scene component responsible to manage sprites
  11777. * in a given scene.
  11778. */
  11779. export class SpriteSceneComponent implements ISceneComponent {
  11780. /**
  11781. * The component name helpfull to identify the component in the list of scene components.
  11782. */
  11783. readonly name: string;
  11784. /**
  11785. * The scene the component belongs to.
  11786. */
  11787. scene: Scene;
  11788. /** @hidden */
  11789. private _spritePredicate;
  11790. /**
  11791. * Creates a new instance of the component for the given scene
  11792. * @param scene Defines the scene to register the component in
  11793. */
  11794. constructor(scene: Scene);
  11795. /**
  11796. * Registers the component in a given scene
  11797. */
  11798. register(): void;
  11799. /**
  11800. * Rebuilds the elements related to this component in case of
  11801. * context lost for instance.
  11802. */
  11803. rebuild(): void;
  11804. /**
  11805. * Disposes the component and the associated ressources.
  11806. */
  11807. dispose(): void;
  11808. private _pickSpriteButKeepRay;
  11809. private _pointerMove;
  11810. private _pointerDown;
  11811. private _pointerUp;
  11812. }
  11813. }
  11814. declare module "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration" {
  11815. /** @hidden */
  11816. export var fogFragmentDeclaration: {
  11817. name: string;
  11818. shader: string;
  11819. };
  11820. }
  11821. declare module "babylonjs/Shaders/ShadersInclude/fogFragment" {
  11822. /** @hidden */
  11823. export var fogFragment: {
  11824. name: string;
  11825. shader: string;
  11826. };
  11827. }
  11828. declare module "babylonjs/Shaders/sprites.fragment" {
  11829. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  11830. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  11831. /** @hidden */
  11832. export var spritesPixelShader: {
  11833. name: string;
  11834. shader: string;
  11835. };
  11836. }
  11837. declare module "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration" {
  11838. /** @hidden */
  11839. export var fogVertexDeclaration: {
  11840. name: string;
  11841. shader: string;
  11842. };
  11843. }
  11844. declare module "babylonjs/Shaders/sprites.vertex" {
  11845. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  11846. /** @hidden */
  11847. export var spritesVertexShader: {
  11848. name: string;
  11849. shader: string;
  11850. };
  11851. }
  11852. declare module "babylonjs/Sprites/spriteManager" {
  11853. import { IDisposable, Scene } from "babylonjs/scene";
  11854. import { Nullable } from "babylonjs/types";
  11855. import { Observable } from "babylonjs/Misc/observable";
  11856. import { Sprite } from "babylonjs/Sprites/sprite";
  11857. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11858. import { Camera } from "babylonjs/Cameras/camera";
  11859. import { Texture } from "babylonjs/Materials/Textures/texture";
  11860. import "babylonjs/Shaders/sprites.fragment";
  11861. import "babylonjs/Shaders/sprites.vertex";
  11862. import { Ray } from "babylonjs/Culling/ray";
  11863. /**
  11864. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11865. */
  11866. export interface ISpriteManager extends IDisposable {
  11867. /**
  11868. * Restricts the camera to viewing objects with the same layerMask.
  11869. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11870. */
  11871. layerMask: number;
  11872. /**
  11873. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11874. */
  11875. isPickable: boolean;
  11876. /**
  11877. * Specifies the rendering group id for this mesh (0 by default)
  11878. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11879. */
  11880. renderingGroupId: number;
  11881. /**
  11882. * Defines the list of sprites managed by the manager.
  11883. */
  11884. sprites: Array<Sprite>;
  11885. /**
  11886. * Tests the intersection of a sprite with a specific ray.
  11887. * @param ray The ray we are sending to test the collision
  11888. * @param camera The camera space we are sending rays in
  11889. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11890. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  11891. * @returns picking info or null.
  11892. */
  11893. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11894. /**
  11895. * Renders the list of sprites on screen.
  11896. */
  11897. render(): void;
  11898. }
  11899. /**
  11900. * Class used to manage multiple sprites on the same spritesheet
  11901. * @see http://doc.babylonjs.com/babylon101/sprites
  11902. */
  11903. export class SpriteManager implements ISpriteManager {
  11904. /** defines the manager's name */
  11905. name: string;
  11906. /** Gets the list of sprites */
  11907. sprites: Sprite[];
  11908. /** Gets or sets the rendering group id (0 by default) */
  11909. renderingGroupId: number;
  11910. /** Gets or sets camera layer mask */
  11911. layerMask: number;
  11912. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11913. fogEnabled: boolean;
  11914. /** Gets or sets a boolean indicating if the sprites are pickable */
  11915. isPickable: boolean;
  11916. /** Defines the default width of a cell in the spritesheet */
  11917. cellWidth: number;
  11918. /** Defines the default height of a cell in the spritesheet */
  11919. cellHeight: number;
  11920. /**
  11921. * An event triggered when the manager is disposed.
  11922. */
  11923. onDisposeObservable: Observable<SpriteManager>;
  11924. private _onDisposeObserver;
  11925. /**
  11926. * Callback called when the manager is disposed
  11927. */
  11928. onDispose: () => void;
  11929. private _capacity;
  11930. private _spriteTexture;
  11931. private _epsilon;
  11932. private _scene;
  11933. private _vertexData;
  11934. private _buffer;
  11935. private _vertexBuffers;
  11936. private _indexBuffer;
  11937. private _effectBase;
  11938. private _effectFog;
  11939. /**
  11940. * Gets or sets the spritesheet texture
  11941. */
  11942. texture: Texture;
  11943. /**
  11944. * Creates a new sprite manager
  11945. * @param name defines the manager's name
  11946. * @param imgUrl defines the sprite sheet url
  11947. * @param capacity defines the maximum allowed number of sprites
  11948. * @param cellSize defines the size of a sprite cell
  11949. * @param scene defines the hosting scene
  11950. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11951. * @param samplingMode defines the smapling mode to use with spritesheet
  11952. */
  11953. constructor(
  11954. /** defines the manager's name */
  11955. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  11956. private _appendSpriteVertex;
  11957. /**
  11958. * Intersects the sprites with a ray
  11959. * @param ray defines the ray to intersect with
  11960. * @param camera defines the current active camera
  11961. * @param predicate defines a predicate used to select candidate sprites
  11962. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11963. * @returns null if no hit or a PickingInfo
  11964. */
  11965. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11966. /**
  11967. * Render all child sprites
  11968. */
  11969. render(): void;
  11970. /**
  11971. * Release associated resources
  11972. */
  11973. dispose(): void;
  11974. }
  11975. }
  11976. declare module "babylonjs/Sprites/sprite" {
  11977. import { Vector3, Color4 } from "babylonjs/Maths/math";
  11978. import { Nullable } from "babylonjs/types";
  11979. import { ActionManager } from "babylonjs/Actions/actionManager";
  11980. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11981. /**
  11982. * Class used to represent a sprite
  11983. * @see http://doc.babylonjs.com/babylon101/sprites
  11984. */
  11985. export class Sprite {
  11986. /** defines the name */
  11987. name: string;
  11988. /** Gets or sets the current world position */
  11989. position: Vector3;
  11990. /** Gets or sets the main color */
  11991. color: Color4;
  11992. /** Gets or sets the width */
  11993. width: number;
  11994. /** Gets or sets the height */
  11995. height: number;
  11996. /** Gets or sets rotation angle */
  11997. angle: number;
  11998. /** Gets or sets the cell index in the sprite sheet */
  11999. cellIndex: number;
  12000. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  12001. invertU: number;
  12002. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  12003. invertV: number;
  12004. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  12005. disposeWhenFinishedAnimating: boolean;
  12006. /** Gets the list of attached animations */
  12007. animations: Animation[];
  12008. /** Gets or sets a boolean indicating if the sprite can be picked */
  12009. isPickable: boolean;
  12010. /**
  12011. * Gets or sets the associated action manager
  12012. */
  12013. actionManager: Nullable<ActionManager>;
  12014. private _animationStarted;
  12015. private _loopAnimation;
  12016. private _fromIndex;
  12017. private _toIndex;
  12018. private _delay;
  12019. private _direction;
  12020. private _manager;
  12021. private _time;
  12022. private _onAnimationEnd;
  12023. /**
  12024. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  12025. */
  12026. isVisible: boolean;
  12027. /**
  12028. * Gets or sets the sprite size
  12029. */
  12030. size: number;
  12031. /**
  12032. * Creates a new Sprite
  12033. * @param name defines the name
  12034. * @param manager defines the manager
  12035. */
  12036. constructor(
  12037. /** defines the name */
  12038. name: string, manager: ISpriteManager);
  12039. /**
  12040. * Starts an animation
  12041. * @param from defines the initial key
  12042. * @param to defines the end key
  12043. * @param loop defines if the animation must loop
  12044. * @param delay defines the start delay (in ms)
  12045. * @param onAnimationEnd defines a callback to call when animation ends
  12046. */
  12047. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  12048. /** Stops current animation (if any) */
  12049. stopAnimation(): void;
  12050. /** @hidden */
  12051. _animate(deltaTime: number): void;
  12052. /** Release associated resources */
  12053. dispose(): void;
  12054. }
  12055. }
  12056. declare module "babylonjs/Collisions/pickingInfo" {
  12057. import { Nullable } from "babylonjs/types";
  12058. import { Vector3, Vector2 } from "babylonjs/Maths/math";
  12059. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12060. import { Sprite } from "babylonjs/Sprites/sprite";
  12061. import { Ray } from "babylonjs/Culling/ray";
  12062. /**
  12063. * Information about the result of picking within a scene
  12064. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  12065. */
  12066. export class PickingInfo {
  12067. /** @hidden */
  12068. _pickingUnavailable: boolean;
  12069. /**
  12070. * If the pick collided with an object
  12071. */
  12072. hit: boolean;
  12073. /**
  12074. * Distance away where the pick collided
  12075. */
  12076. distance: number;
  12077. /**
  12078. * The location of pick collision
  12079. */
  12080. pickedPoint: Nullable<Vector3>;
  12081. /**
  12082. * The mesh corresponding the the pick collision
  12083. */
  12084. pickedMesh: Nullable<AbstractMesh>;
  12085. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calulating the texture coordinates of the collision.*/
  12086. bu: number;
  12087. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calulating the texture coordinates of the collision.*/
  12088. bv: number;
  12089. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  12090. faceId: number;
  12091. /** Id of the the submesh that was picked */
  12092. subMeshId: number;
  12093. /** If a sprite was picked, this will be the sprite the pick collided with */
  12094. pickedSprite: Nullable<Sprite>;
  12095. /**
  12096. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  12097. */
  12098. originMesh: Nullable<AbstractMesh>;
  12099. /**
  12100. * The ray that was used to perform the picking.
  12101. */
  12102. ray: Nullable<Ray>;
  12103. /**
  12104. * Gets the normal correspodning to the face the pick collided with
  12105. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  12106. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  12107. * @returns The normal correspodning to the face the pick collided with
  12108. */
  12109. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  12110. /**
  12111. * Gets the texture coordinates of where the pick occured
  12112. * @returns the vector containing the coordnates of the texture
  12113. */
  12114. getTextureCoordinates(): Nullable<Vector2>;
  12115. }
  12116. }
  12117. declare module "babylonjs/Events/pointerEvents" {
  12118. import { Nullable } from "babylonjs/types";
  12119. import { Vector2 } from "babylonjs/Maths/math";
  12120. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  12121. import { Ray } from "babylonjs/Culling/ray";
  12122. /**
  12123. * Gather the list of pointer event types as constants.
  12124. */
  12125. export class PointerEventTypes {
  12126. /**
  12127. * 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.
  12128. */
  12129. static readonly POINTERDOWN: number;
  12130. /**
  12131. * The pointerup event is fired when a pointer is no longer active.
  12132. */
  12133. static readonly POINTERUP: number;
  12134. /**
  12135. * The pointermove event is fired when a pointer changes coordinates.
  12136. */
  12137. static readonly POINTERMOVE: number;
  12138. /**
  12139. * The pointerwheel event is fired when a mouse wheel has been rotated.
  12140. */
  12141. static readonly POINTERWHEEL: number;
  12142. /**
  12143. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  12144. */
  12145. static readonly POINTERPICK: number;
  12146. /**
  12147. * The pointertap event is fired when a the object has been touched and released without drag.
  12148. */
  12149. static readonly POINTERTAP: number;
  12150. /**
  12151. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  12152. */
  12153. static readonly POINTERDOUBLETAP: number;
  12154. }
  12155. /**
  12156. * Base class of pointer info types.
  12157. */
  12158. export class PointerInfoBase {
  12159. /**
  12160. * Defines the type of event (PointerEventTypes)
  12161. */
  12162. type: number;
  12163. /**
  12164. * Defines the related dom event
  12165. */
  12166. event: PointerEvent | MouseWheelEvent;
  12167. /**
  12168. * Instantiates the base class of pointers info.
  12169. * @param type Defines the type of event (PointerEventTypes)
  12170. * @param event Defines the related dom event
  12171. */
  12172. constructor(
  12173. /**
  12174. * Defines the type of event (PointerEventTypes)
  12175. */
  12176. type: number,
  12177. /**
  12178. * Defines the related dom event
  12179. */
  12180. event: PointerEvent | MouseWheelEvent);
  12181. }
  12182. /**
  12183. * This class is used to store pointer related info for the onPrePointerObservable event.
  12184. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  12185. */
  12186. export class PointerInfoPre extends PointerInfoBase {
  12187. /**
  12188. * Ray from a pointer if availible (eg. 6dof controller)
  12189. */
  12190. ray: Nullable<Ray>;
  12191. /**
  12192. * Defines the local position of the pointer on the canvas.
  12193. */
  12194. localPosition: Vector2;
  12195. /**
  12196. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  12197. */
  12198. skipOnPointerObservable: boolean;
  12199. /**
  12200. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  12201. * @param type Defines the type of event (PointerEventTypes)
  12202. * @param event Defines the related dom event
  12203. * @param localX Defines the local x coordinates of the pointer when the event occured
  12204. * @param localY Defines the local y coordinates of the pointer when the event occured
  12205. */
  12206. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  12207. }
  12208. /**
  12209. * This type contains all the data related to a pointer event in Babylon.js.
  12210. * 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.
  12211. */
  12212. export class PointerInfo extends PointerInfoBase {
  12213. /**
  12214. * Defines the picking info associated to the info (if any)\
  12215. */
  12216. pickInfo: Nullable<PickingInfo>;
  12217. /**
  12218. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  12219. * @param type Defines the type of event (PointerEventTypes)
  12220. * @param event Defines the related dom event
  12221. * @param pickInfo Defines the picking info associated to the info (if any)\
  12222. */
  12223. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  12224. /**
  12225. * Defines the picking info associated to the info (if any)\
  12226. */
  12227. pickInfo: Nullable<PickingInfo>);
  12228. }
  12229. /**
  12230. * Data relating to a touch event on the screen.
  12231. */
  12232. export interface PointerTouch {
  12233. /**
  12234. * X coordinate of touch.
  12235. */
  12236. x: number;
  12237. /**
  12238. * Y coordinate of touch.
  12239. */
  12240. y: number;
  12241. /**
  12242. * Id of touch. Unique for each finger.
  12243. */
  12244. pointerId: number;
  12245. /**
  12246. * Event type passed from DOM.
  12247. */
  12248. type: any;
  12249. }
  12250. }
  12251. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  12252. import { Observable } from "babylonjs/Misc/observable";
  12253. import { Nullable } from "babylonjs/types";
  12254. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  12255. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12256. /**
  12257. * Manage the mouse inputs to control the movement of a free camera.
  12258. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12259. */
  12260. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  12261. /**
  12262. * Define if touch is enabled in the mouse input
  12263. */
  12264. touchEnabled: boolean;
  12265. /**
  12266. * Defines the camera the input is attached to.
  12267. */
  12268. camera: FreeCamera;
  12269. /**
  12270. * Defines the buttons associated with the input to handle camera move.
  12271. */
  12272. buttons: number[];
  12273. /**
  12274. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  12275. */
  12276. angularSensibility: number;
  12277. private _pointerInput;
  12278. private _onMouseMove;
  12279. private _observer;
  12280. private previousPosition;
  12281. /**
  12282. * Observable for when a pointer move event occurs containing the move offset
  12283. */
  12284. onPointerMovedObservable: Observable<{
  12285. offsetX: number;
  12286. offsetY: number;
  12287. }>;
  12288. /**
  12289. * @hidden
  12290. * If the camera should be rotated automatically based on pointer movement
  12291. */
  12292. _allowCameraRotation: boolean;
  12293. /**
  12294. * Manage the mouse inputs to control the movement of a free camera.
  12295. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12296. * @param touchEnabled Defines if touch is enabled or not
  12297. */
  12298. constructor(
  12299. /**
  12300. * Define if touch is enabled in the mouse input
  12301. */
  12302. touchEnabled?: boolean);
  12303. /**
  12304. * Attach the input controls to a specific dom element to get the input from.
  12305. * @param element Defines the element the controls should be listened from
  12306. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12307. */
  12308. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12309. /**
  12310. * Called on JS contextmenu event.
  12311. * Override this method to provide functionality.
  12312. */
  12313. protected onContextMenu(evt: PointerEvent): void;
  12314. /**
  12315. * Detach the current controls from the specified dom element.
  12316. * @param element Defines the element to stop listening the inputs from
  12317. */
  12318. detachControl(element: Nullable<HTMLElement>): void;
  12319. /**
  12320. * Gets the class name of the current intput.
  12321. * @returns the class name
  12322. */
  12323. getClassName(): string;
  12324. /**
  12325. * Get the friendly name associated with the input class.
  12326. * @returns the input friendly name
  12327. */
  12328. getSimpleName(): string;
  12329. }
  12330. }
  12331. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  12332. import { Nullable } from "babylonjs/types";
  12333. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  12334. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12335. /**
  12336. * Manage the touch inputs to control the movement of a free camera.
  12337. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12338. */
  12339. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  12340. /**
  12341. * Defines the camera the input is attached to.
  12342. */
  12343. camera: FreeCamera;
  12344. /**
  12345. * Defines the touch sensibility for rotation.
  12346. * The higher the faster.
  12347. */
  12348. touchAngularSensibility: number;
  12349. /**
  12350. * Defines the touch sensibility for move.
  12351. * The higher the faster.
  12352. */
  12353. touchMoveSensibility: number;
  12354. private _offsetX;
  12355. private _offsetY;
  12356. private _pointerPressed;
  12357. private _pointerInput;
  12358. private _observer;
  12359. private _onLostFocus;
  12360. /**
  12361. * Attach the input controls to a specific dom element to get the input from.
  12362. * @param element Defines the element the controls should be listened from
  12363. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12364. */
  12365. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12366. /**
  12367. * Detach the current controls from the specified dom element.
  12368. * @param element Defines the element to stop listening the inputs from
  12369. */
  12370. detachControl(element: Nullable<HTMLElement>): void;
  12371. /**
  12372. * Update the current camera state depending on the inputs that have been used this frame.
  12373. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  12374. */
  12375. checkInputs(): void;
  12376. /**
  12377. * Gets the class name of the current intput.
  12378. * @returns the class name
  12379. */
  12380. getClassName(): string;
  12381. /**
  12382. * Get the friendly name associated with the input class.
  12383. * @returns the input friendly name
  12384. */
  12385. getSimpleName(): string;
  12386. }
  12387. }
  12388. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  12389. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12390. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  12391. import { FreeCameraKeyboardMoveInput } from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  12392. import { FreeCameraMouseInput } from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  12393. import { Nullable } from "babylonjs/types";
  12394. /**
  12395. * Default Inputs manager for the FreeCamera.
  12396. * It groups all the default supported inputs for ease of use.
  12397. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12398. */
  12399. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  12400. /**
  12401. * @hidden
  12402. */
  12403. _keyboardInput: Nullable<FreeCameraKeyboardMoveInput>;
  12404. /**
  12405. * @hidden
  12406. */
  12407. _mouseInput: Nullable<FreeCameraMouseInput>;
  12408. /**
  12409. * Instantiates a new FreeCameraInputsManager.
  12410. * @param camera Defines the camera the inputs belong to
  12411. */
  12412. constructor(camera: FreeCamera);
  12413. /**
  12414. * Add keyboard input support to the input manager.
  12415. * @returns the current input manager
  12416. */
  12417. addKeyboard(): FreeCameraInputsManager;
  12418. /**
  12419. * Add mouse input support to the input manager.
  12420. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  12421. * @returns the current input manager
  12422. */
  12423. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  12424. /**
  12425. * Removes the mouse input support from the manager
  12426. * @returns the current input manager
  12427. */
  12428. removeMouse(): FreeCameraInputsManager;
  12429. /**
  12430. * Add touch input support to the input manager.
  12431. * @returns the current input manager
  12432. */
  12433. addTouch(): FreeCameraInputsManager;
  12434. }
  12435. }
  12436. declare module "babylonjs/Cameras/freeCamera" {
  12437. import { Vector3 } from "babylonjs/Maths/math";
  12438. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12439. import { Scene } from "babylonjs/scene";
  12440. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  12441. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  12442. /**
  12443. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12444. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  12445. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12446. */
  12447. export class FreeCamera extends TargetCamera {
  12448. /**
  12449. * Define the collision ellipsoid of the camera.
  12450. * This is helpful to simulate a camera body like the player body around the camera
  12451. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  12452. */
  12453. ellipsoid: Vector3;
  12454. /**
  12455. * Define an offset for the position of the ellipsoid around the camera.
  12456. * This can be helpful to determine the center of the body near the gravity center of the body
  12457. * instead of its head.
  12458. */
  12459. ellipsoidOffset: Vector3;
  12460. /**
  12461. * Enable or disable collisions of the camera with the rest of the scene objects.
  12462. */
  12463. checkCollisions: boolean;
  12464. /**
  12465. * Enable or disable gravity on the camera.
  12466. */
  12467. applyGravity: boolean;
  12468. /**
  12469. * Define the input manager associated to the camera.
  12470. */
  12471. inputs: FreeCameraInputsManager;
  12472. /**
  12473. * Gets the input sensibility for a mouse input. (default is 2000.0)
  12474. * Higher values reduce sensitivity.
  12475. */
  12476. /**
  12477. * Sets the input sensibility for a mouse input. (default is 2000.0)
  12478. * Higher values reduce sensitivity.
  12479. */
  12480. angularSensibility: number;
  12481. /**
  12482. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  12483. */
  12484. keysUp: number[];
  12485. /**
  12486. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  12487. */
  12488. keysDown: number[];
  12489. /**
  12490. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  12491. */
  12492. keysLeft: number[];
  12493. /**
  12494. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  12495. */
  12496. keysRight: number[];
  12497. /**
  12498. * Event raised when the camera collide with a mesh in the scene.
  12499. */
  12500. onCollide: (collidedMesh: AbstractMesh) => void;
  12501. private _collider;
  12502. private _needMoveForGravity;
  12503. private _oldPosition;
  12504. private _diffPosition;
  12505. private _newPosition;
  12506. /** @hidden */
  12507. _localDirection: Vector3;
  12508. /** @hidden */
  12509. _transformedDirection: Vector3;
  12510. /**
  12511. * Instantiates a Free Camera.
  12512. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12513. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  12514. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12515. * @param name Define the name of the camera in the scene
  12516. * @param position Define the start position of the camera in the scene
  12517. * @param scene Define the scene the camera belongs to
  12518. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  12519. */
  12520. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  12521. /**
  12522. * Attached controls to the current camera.
  12523. * @param element Defines the element the controls should be listened from
  12524. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12525. */
  12526. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12527. /**
  12528. * Detach the current controls from the camera.
  12529. * The camera will stop reacting to inputs.
  12530. * @param element Defines the element to stop listening the inputs from
  12531. */
  12532. detachControl(element: HTMLElement): void;
  12533. private _collisionMask;
  12534. /**
  12535. * Define a collision mask to limit the list of object the camera can collide with
  12536. */
  12537. collisionMask: number;
  12538. /** @hidden */
  12539. _collideWithWorld(displacement: Vector3): void;
  12540. private _onCollisionPositionChange;
  12541. /** @hidden */
  12542. _checkInputs(): void;
  12543. /** @hidden */
  12544. _decideIfNeedsToMove(): boolean;
  12545. /** @hidden */
  12546. _updatePosition(): void;
  12547. /**
  12548. * Destroy the camera and release the current resources hold by it.
  12549. */
  12550. dispose(): void;
  12551. /**
  12552. * Gets the current object class name.
  12553. * @return the class name
  12554. */
  12555. getClassName(): string;
  12556. }
  12557. }
  12558. declare module "babylonjs/Gamepads/gamepad" {
  12559. import { Observable } from "babylonjs/Misc/observable";
  12560. /**
  12561. * Represents a gamepad control stick position
  12562. */
  12563. export class StickValues {
  12564. /**
  12565. * The x component of the control stick
  12566. */
  12567. x: number;
  12568. /**
  12569. * The y component of the control stick
  12570. */
  12571. y: number;
  12572. /**
  12573. * Initializes the gamepad x and y control stick values
  12574. * @param x The x component of the gamepad control stick value
  12575. * @param y The y component of the gamepad control stick value
  12576. */
  12577. constructor(
  12578. /**
  12579. * The x component of the control stick
  12580. */
  12581. x: number,
  12582. /**
  12583. * The y component of the control stick
  12584. */
  12585. y: number);
  12586. }
  12587. /**
  12588. * An interface which manages callbacks for gamepad button changes
  12589. */
  12590. export interface GamepadButtonChanges {
  12591. /**
  12592. * Called when a gamepad has been changed
  12593. */
  12594. changed: boolean;
  12595. /**
  12596. * Called when a gamepad press event has been triggered
  12597. */
  12598. pressChanged: boolean;
  12599. /**
  12600. * Called when a touch event has been triggered
  12601. */
  12602. touchChanged: boolean;
  12603. /**
  12604. * Called when a value has changed
  12605. */
  12606. valueChanged: boolean;
  12607. }
  12608. /**
  12609. * Represents a gamepad
  12610. */
  12611. export class Gamepad {
  12612. /**
  12613. * The id of the gamepad
  12614. */
  12615. id: string;
  12616. /**
  12617. * The index of the gamepad
  12618. */
  12619. index: number;
  12620. /**
  12621. * The browser gamepad
  12622. */
  12623. browserGamepad: any;
  12624. /**
  12625. * Specifies what type of gamepad this represents
  12626. */
  12627. type: number;
  12628. private _leftStick;
  12629. private _rightStick;
  12630. /** @hidden */
  12631. _isConnected: boolean;
  12632. private _leftStickAxisX;
  12633. private _leftStickAxisY;
  12634. private _rightStickAxisX;
  12635. private _rightStickAxisY;
  12636. /**
  12637. * Triggered when the left control stick has been changed
  12638. */
  12639. private _onleftstickchanged;
  12640. /**
  12641. * Triggered when the right control stick has been changed
  12642. */
  12643. private _onrightstickchanged;
  12644. /**
  12645. * Represents a gamepad controller
  12646. */
  12647. static GAMEPAD: number;
  12648. /**
  12649. * Represents a generic controller
  12650. */
  12651. static GENERIC: number;
  12652. /**
  12653. * Represents an XBox controller
  12654. */
  12655. static XBOX: number;
  12656. /**
  12657. * Represents a pose-enabled controller
  12658. */
  12659. static POSE_ENABLED: number;
  12660. /**
  12661. * Specifies whether the left control stick should be Y-inverted
  12662. */
  12663. protected _invertLeftStickY: boolean;
  12664. /**
  12665. * Specifies if the gamepad has been connected
  12666. */
  12667. readonly isConnected: boolean;
  12668. /**
  12669. * Initializes the gamepad
  12670. * @param id The id of the gamepad
  12671. * @param index The index of the gamepad
  12672. * @param browserGamepad The browser gamepad
  12673. * @param leftStickX The x component of the left joystick
  12674. * @param leftStickY The y component of the left joystick
  12675. * @param rightStickX The x component of the right joystick
  12676. * @param rightStickY The y component of the right joystick
  12677. */
  12678. constructor(
  12679. /**
  12680. * The id of the gamepad
  12681. */
  12682. id: string,
  12683. /**
  12684. * The index of the gamepad
  12685. */
  12686. index: number,
  12687. /**
  12688. * The browser gamepad
  12689. */
  12690. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12691. /**
  12692. * Callback triggered when the left joystick has changed
  12693. * @param callback
  12694. */
  12695. onleftstickchanged(callback: (values: StickValues) => void): void;
  12696. /**
  12697. * Callback triggered when the right joystick has changed
  12698. * @param callback
  12699. */
  12700. onrightstickchanged(callback: (values: StickValues) => void): void;
  12701. /**
  12702. * Gets the left joystick
  12703. */
  12704. /**
  12705. * Sets the left joystick values
  12706. */
  12707. leftStick: StickValues;
  12708. /**
  12709. * Gets the right joystick
  12710. */
  12711. /**
  12712. * Sets the right joystick value
  12713. */
  12714. rightStick: StickValues;
  12715. /**
  12716. * Updates the gamepad joystick positions
  12717. */
  12718. update(): void;
  12719. /**
  12720. * Disposes the gamepad
  12721. */
  12722. dispose(): void;
  12723. }
  12724. /**
  12725. * Represents a generic gamepad
  12726. */
  12727. export class GenericPad extends Gamepad {
  12728. private _buttons;
  12729. private _onbuttondown;
  12730. private _onbuttonup;
  12731. /**
  12732. * Observable triggered when a button has been pressed
  12733. */
  12734. onButtonDownObservable: Observable<number>;
  12735. /**
  12736. * Observable triggered when a button has been released
  12737. */
  12738. onButtonUpObservable: Observable<number>;
  12739. /**
  12740. * Callback triggered when a button has been pressed
  12741. * @param callback Called when a button has been pressed
  12742. */
  12743. onbuttondown(callback: (buttonPressed: number) => void): void;
  12744. /**
  12745. * Callback triggered when a button has been released
  12746. * @param callback Called when a button has been released
  12747. */
  12748. onbuttonup(callback: (buttonReleased: number) => void): void;
  12749. /**
  12750. * Initializes the generic gamepad
  12751. * @param id The id of the generic gamepad
  12752. * @param index The index of the generic gamepad
  12753. * @param browserGamepad The browser gamepad
  12754. */
  12755. constructor(id: string, index: number, browserGamepad: any);
  12756. private _setButtonValue;
  12757. /**
  12758. * Updates the generic gamepad
  12759. */
  12760. update(): void;
  12761. /**
  12762. * Disposes the generic gamepad
  12763. */
  12764. dispose(): void;
  12765. }
  12766. }
  12767. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  12768. import { Observable } from "babylonjs/Misc/observable";
  12769. import { Nullable } from "babylonjs/types";
  12770. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math";
  12771. import { TransformNode } from "babylonjs/Meshes/transformNode";
  12772. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12773. import { Ray } from "babylonjs/Culling/ray";
  12774. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  12775. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  12776. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  12777. /**
  12778. * Defines the types of pose enabled controllers that are supported
  12779. */
  12780. export enum PoseEnabledControllerType {
  12781. /**
  12782. * HTC Vive
  12783. */
  12784. VIVE = 0,
  12785. /**
  12786. * Oculus Rift
  12787. */
  12788. OCULUS = 1,
  12789. /**
  12790. * Windows mixed reality
  12791. */
  12792. WINDOWS = 2,
  12793. /**
  12794. * Samsung gear VR
  12795. */
  12796. GEAR_VR = 3,
  12797. /**
  12798. * Google Daydream
  12799. */
  12800. DAYDREAM = 4,
  12801. /**
  12802. * Generic
  12803. */
  12804. GENERIC = 5
  12805. }
  12806. /**
  12807. * Defines the MutableGamepadButton interface for the state of a gamepad button
  12808. */
  12809. export interface MutableGamepadButton {
  12810. /**
  12811. * Value of the button/trigger
  12812. */
  12813. value: number;
  12814. /**
  12815. * If the button/trigger is currently touched
  12816. */
  12817. touched: boolean;
  12818. /**
  12819. * If the button/trigger is currently pressed
  12820. */
  12821. pressed: boolean;
  12822. }
  12823. /**
  12824. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  12825. * @hidden
  12826. */
  12827. export interface ExtendedGamepadButton extends GamepadButton {
  12828. /**
  12829. * If the button/trigger is currently pressed
  12830. */
  12831. readonly pressed: boolean;
  12832. /**
  12833. * If the button/trigger is currently touched
  12834. */
  12835. readonly touched: boolean;
  12836. /**
  12837. * Value of the button/trigger
  12838. */
  12839. readonly value: number;
  12840. }
  12841. /** @hidden */
  12842. export interface _GamePadFactory {
  12843. /**
  12844. * Returns wether or not the current gamepad can be created for this type of controller.
  12845. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  12846. * @returns true if it can be created, otherwise false
  12847. */
  12848. canCreate(gamepadInfo: any): boolean;
  12849. /**
  12850. * Creates a new instance of the Gamepad.
  12851. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  12852. * @returns the new gamepad instance
  12853. */
  12854. create(gamepadInfo: any): Gamepad;
  12855. }
  12856. /**
  12857. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  12858. */
  12859. export class PoseEnabledControllerHelper {
  12860. /** @hidden */
  12861. static _ControllerFactories: _GamePadFactory[];
  12862. /** @hidden */
  12863. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  12864. /**
  12865. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  12866. * @param vrGamepad the gamepad to initialized
  12867. * @returns a vr controller of the type the gamepad identified as
  12868. */
  12869. static InitiateController(vrGamepad: any): Gamepad;
  12870. }
  12871. /**
  12872. * Defines the PoseEnabledController object that contains state of a vr capable controller
  12873. */
  12874. export class PoseEnabledController extends Gamepad implements PoseControlled {
  12875. private _deviceRoomPosition;
  12876. private _deviceRoomRotationQuaternion;
  12877. /**
  12878. * The device position in babylon space
  12879. */
  12880. devicePosition: Vector3;
  12881. /**
  12882. * The device rotation in babylon space
  12883. */
  12884. deviceRotationQuaternion: Quaternion;
  12885. /**
  12886. * The scale factor of the device in babylon space
  12887. */
  12888. deviceScaleFactor: number;
  12889. /**
  12890. * (Likely devicePosition should be used instead) The device position in its room space
  12891. */
  12892. position: Vector3;
  12893. /**
  12894. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  12895. */
  12896. rotationQuaternion: Quaternion;
  12897. /**
  12898. * The type of controller (Eg. Windows mixed reality)
  12899. */
  12900. controllerType: PoseEnabledControllerType;
  12901. protected _calculatedPosition: Vector3;
  12902. private _calculatedRotation;
  12903. /**
  12904. * The raw pose from the device
  12905. */
  12906. rawPose: DevicePose;
  12907. private _trackPosition;
  12908. private _maxRotationDistFromHeadset;
  12909. private _draggedRoomRotation;
  12910. /**
  12911. * @hidden
  12912. */
  12913. _disableTrackPosition(fixedPosition: Vector3): void;
  12914. /**
  12915. * Internal, the mesh attached to the controller
  12916. * @hidden
  12917. */
  12918. _mesh: Nullable<AbstractMesh>;
  12919. private _poseControlledCamera;
  12920. private _leftHandSystemQuaternion;
  12921. /**
  12922. * Internal, matrix used to convert room space to babylon space
  12923. * @hidden
  12924. */
  12925. _deviceToWorld: Matrix;
  12926. /**
  12927. * Node to be used when casting a ray from the controller
  12928. * @hidden
  12929. */
  12930. _pointingPoseNode: Nullable<TransformNode>;
  12931. /**
  12932. * Name of the child mesh that can be used to cast a ray from the controller
  12933. */
  12934. static readonly POINTING_POSE: string;
  12935. /**
  12936. * Creates a new PoseEnabledController from a gamepad
  12937. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  12938. */
  12939. constructor(browserGamepad: any);
  12940. private _workingMatrix;
  12941. /**
  12942. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  12943. */
  12944. update(): void;
  12945. /**
  12946. * Updates only the pose device and mesh without doing any button event checking
  12947. */
  12948. protected _updatePoseAndMesh(): void;
  12949. /**
  12950. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  12951. * @param poseData raw pose fromthe device
  12952. */
  12953. updateFromDevice(poseData: DevicePose): void;
  12954. /**
  12955. * @hidden
  12956. */
  12957. _meshAttachedObservable: Observable<AbstractMesh>;
  12958. /**
  12959. * Attaches a mesh to the controller
  12960. * @param mesh the mesh to be attached
  12961. */
  12962. attachToMesh(mesh: AbstractMesh): void;
  12963. /**
  12964. * Attaches the controllers mesh to a camera
  12965. * @param camera the camera the mesh should be attached to
  12966. */
  12967. attachToPoseControlledCamera(camera: TargetCamera): void;
  12968. /**
  12969. * Disposes of the controller
  12970. */
  12971. dispose(): void;
  12972. /**
  12973. * The mesh that is attached to the controller
  12974. */
  12975. readonly mesh: Nullable<AbstractMesh>;
  12976. /**
  12977. * Gets the ray of the controller in the direction the controller is pointing
  12978. * @param length the length the resulting ray should be
  12979. * @returns a ray in the direction the controller is pointing
  12980. */
  12981. getForwardRay(length?: number): Ray;
  12982. }
  12983. }
  12984. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  12985. import { Observable } from "babylonjs/Misc/observable";
  12986. import { Scene } from "babylonjs/scene";
  12987. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12988. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  12989. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  12990. /**
  12991. * Defines the WebVRController object that represents controllers tracked in 3D space
  12992. */
  12993. export abstract class WebVRController extends PoseEnabledController {
  12994. /**
  12995. * Internal, the default controller model for the controller
  12996. */
  12997. protected _defaultModel: AbstractMesh;
  12998. /**
  12999. * Fired when the trigger state has changed
  13000. */
  13001. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  13002. /**
  13003. * Fired when the main button state has changed
  13004. */
  13005. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  13006. /**
  13007. * Fired when the secondary button state has changed
  13008. */
  13009. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  13010. /**
  13011. * Fired when the pad state has changed
  13012. */
  13013. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  13014. /**
  13015. * Fired when controllers stick values have changed
  13016. */
  13017. onPadValuesChangedObservable: Observable<StickValues>;
  13018. /**
  13019. * Array of button availible on the controller
  13020. */
  13021. protected _buttons: Array<MutableGamepadButton>;
  13022. private _onButtonStateChange;
  13023. /**
  13024. * Fired when a controller button's state has changed
  13025. * @param callback the callback containing the button that was modified
  13026. */
  13027. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  13028. /**
  13029. * X and Y axis corrisponding to the controllers joystick
  13030. */
  13031. pad: StickValues;
  13032. /**
  13033. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  13034. */
  13035. hand: string;
  13036. /**
  13037. * The default controller model for the controller
  13038. */
  13039. readonly defaultModel: AbstractMesh;
  13040. /**
  13041. * Creates a new WebVRController from a gamepad
  13042. * @param vrGamepad the gamepad that the WebVRController should be created from
  13043. */
  13044. constructor(vrGamepad: any);
  13045. /**
  13046. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  13047. */
  13048. update(): void;
  13049. /**
  13050. * Function to be called when a button is modified
  13051. */
  13052. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  13053. /**
  13054. * Loads a mesh and attaches it to the controller
  13055. * @param scene the scene the mesh should be added to
  13056. * @param meshLoaded callback for when the mesh has been loaded
  13057. */
  13058. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  13059. private _setButtonValue;
  13060. private _changes;
  13061. private _checkChanges;
  13062. /**
  13063. * Disposes of th webVRCOntroller
  13064. */
  13065. dispose(): void;
  13066. }
  13067. }
  13068. declare module "babylonjs/Lights/hemisphericLight" {
  13069. import { Nullable } from "babylonjs/types";
  13070. import { Scene } from "babylonjs/scene";
  13071. import { Matrix, Vector3, Color3 } from "babylonjs/Maths/math";
  13072. import { Effect } from "babylonjs/Materials/effect";
  13073. import { Light } from "babylonjs/Lights/light";
  13074. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  13075. /**
  13076. * The HemisphericLight simulates the ambient environment light,
  13077. * so the passed direction is the light reflection direction, not the incoming direction.
  13078. */
  13079. export class HemisphericLight extends Light {
  13080. /**
  13081. * The groundColor is the light in the opposite direction to the one specified during creation.
  13082. * 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.
  13083. */
  13084. groundColor: Color3;
  13085. /**
  13086. * The light reflection direction, not the incoming direction.
  13087. */
  13088. direction: Vector3;
  13089. /**
  13090. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  13091. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  13092. * The HemisphericLight can't cast shadows.
  13093. * Documentation : https://doc.babylonjs.com/babylon101/lights
  13094. * @param name The friendly name of the light
  13095. * @param direction The direction of the light reflection
  13096. * @param scene The scene the light belongs to
  13097. */
  13098. constructor(name: string, direction: Vector3, scene: Scene);
  13099. protected _buildUniformLayout(): void;
  13100. /**
  13101. * Returns the string "HemisphericLight".
  13102. * @return The class name
  13103. */
  13104. getClassName(): string;
  13105. /**
  13106. * Sets the HemisphericLight direction towards the passed target (Vector3).
  13107. * Returns the updated direction.
  13108. * @param target The target the direction should point to
  13109. * @return The computed direction
  13110. */
  13111. setDirectionToTarget(target: Vector3): Vector3;
  13112. /**
  13113. * Returns the shadow generator associated to the light.
  13114. * @returns Always null for hemispheric lights because it does not support shadows.
  13115. */
  13116. getShadowGenerator(): Nullable<IShadowGenerator>;
  13117. /**
  13118. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  13119. * @param effect The effect to update
  13120. * @param lightIndex The index of the light in the effect to update
  13121. * @returns The hemispheric light
  13122. */
  13123. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  13124. /**
  13125. * Computes the world matrix of the node
  13126. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  13127. * @param useWasUpdatedFlag defines a reserved property
  13128. * @returns the world matrix
  13129. */
  13130. computeWorldMatrix(): Matrix;
  13131. /**
  13132. * Returns the integer 3.
  13133. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  13134. */
  13135. getTypeID(): number;
  13136. /**
  13137. * Prepares the list of defines specific to the light type.
  13138. * @param defines the list of defines
  13139. * @param lightIndex defines the index of the light for the effect
  13140. */
  13141. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  13142. }
  13143. }
  13144. declare module "babylonjs/Shaders/vrMultiviewToSingleview.fragment" {
  13145. /** @hidden */
  13146. export var vrMultiviewToSingleviewPixelShader: {
  13147. name: string;
  13148. shader: string;
  13149. };
  13150. }
  13151. declare module "babylonjs/Materials/Textures/MultiviewRenderTarget" {
  13152. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  13153. import { Scene } from "babylonjs/scene";
  13154. /**
  13155. * Renders to multiple views with a single draw call
  13156. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  13157. */
  13158. export class MultiviewRenderTarget extends RenderTargetTexture {
  13159. /**
  13160. * Creates a multiview render target
  13161. * @param scene scene used with the render target
  13162. * @param size the size of the render target (used for each view)
  13163. */
  13164. constructor(scene: Scene, size?: number | {
  13165. width: number;
  13166. height: number;
  13167. } | {
  13168. ratio: number;
  13169. });
  13170. /**
  13171. * @hidden
  13172. * @param faceIndex the face index, if its a cube texture
  13173. */
  13174. _bindFrameBuffer(faceIndex?: number): void;
  13175. /**
  13176. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  13177. * @returns the view count
  13178. */
  13179. getViewCount(): number;
  13180. }
  13181. }
  13182. declare module "babylonjs/Engines/Extensions/engine.multiview" {
  13183. import { Camera } from "babylonjs/Cameras/camera";
  13184. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  13185. import { Nullable } from "babylonjs/types";
  13186. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  13187. import { Matrix } from "babylonjs/Maths/math";
  13188. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  13189. module "babylonjs/Engines/engine" {
  13190. interface Engine {
  13191. /**
  13192. * Creates a new multiview render target
  13193. * @param width defines the width of the texture
  13194. * @param height defines the height of the texture
  13195. * @returns the created multiview texture
  13196. */
  13197. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  13198. /**
  13199. * Binds a multiview framebuffer to be drawn to
  13200. * @param multiviewTexture texture to bind
  13201. */
  13202. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  13203. }
  13204. }
  13205. module "babylonjs/Cameras/camera" {
  13206. interface Camera {
  13207. /**
  13208. * @hidden
  13209. * 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)
  13210. */
  13211. _useMultiviewToSingleView: boolean;
  13212. /**
  13213. * @hidden
  13214. * 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)
  13215. */
  13216. _multiviewTexture: Nullable<RenderTargetTexture>;
  13217. /**
  13218. * @hidden
  13219. * ensures the multiview texture of the camera exists and has the specified width/height
  13220. * @param width height to set on the multiview texture
  13221. * @param height width to set on the multiview texture
  13222. */
  13223. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  13224. }
  13225. }
  13226. module "babylonjs/scene" {
  13227. interface Scene {
  13228. /** @hidden */
  13229. _transformMatrixR: Matrix;
  13230. /** @hidden */
  13231. _multiviewSceneUbo: Nullable<UniformBuffer>;
  13232. /** @hidden */
  13233. _createMultiviewUbo(): void;
  13234. /** @hidden */
  13235. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  13236. /** @hidden */
  13237. _renderMultiviewToSingleView(camera: Camera): void;
  13238. }
  13239. }
  13240. }
  13241. declare module "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess" {
  13242. import { Camera } from "babylonjs/Cameras/camera";
  13243. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  13244. import "babylonjs/Shaders/vrMultiviewToSingleview.fragment";
  13245. import "babylonjs/Engines/Extensions/engine.multiview";
  13246. /**
  13247. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  13248. * This will not be used for webXR as it supports displaying texture arrays directly
  13249. */
  13250. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  13251. /**
  13252. * Initializes a VRMultiviewToSingleview
  13253. * @param name name of the post process
  13254. * @param camera camera to be applied to
  13255. * @param scaleFactor scaling factor to the size of the output texture
  13256. */
  13257. constructor(name: string, camera: Camera, scaleFactor: number);
  13258. }
  13259. }
  13260. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  13261. declare module "babylonjs/Cameras/VR/webVRCamera" {
  13262. import { Nullable } from "babylonjs/types";
  13263. import { Observable } from "babylonjs/Misc/observable";
  13264. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  13265. import { Scene } from "babylonjs/scene";
  13266. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math";
  13267. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  13268. import { Node } from "babylonjs/node";
  13269. import { Ray } from "babylonjs/Culling/ray";
  13270. import "babylonjs/Cameras/RigModes/webVRRigMode";
  13271. /**
  13272. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  13273. * IMPORTANT!! The data is right-hand data.
  13274. * @export
  13275. * @interface DevicePose
  13276. */
  13277. export interface DevicePose {
  13278. /**
  13279. * The position of the device, values in array are [x,y,z].
  13280. */
  13281. readonly position: Nullable<Float32Array>;
  13282. /**
  13283. * The linearVelocity of the device, values in array are [x,y,z].
  13284. */
  13285. readonly linearVelocity: Nullable<Float32Array>;
  13286. /**
  13287. * The linearAcceleration of the device, values in array are [x,y,z].
  13288. */
  13289. readonly linearAcceleration: Nullable<Float32Array>;
  13290. /**
  13291. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  13292. */
  13293. readonly orientation: Nullable<Float32Array>;
  13294. /**
  13295. * The angularVelocity of the device, values in array are [x,y,z].
  13296. */
  13297. readonly angularVelocity: Nullable<Float32Array>;
  13298. /**
  13299. * The angularAcceleration of the device, values in array are [x,y,z].
  13300. */
  13301. readonly angularAcceleration: Nullable<Float32Array>;
  13302. }
  13303. /**
  13304. * Interface representing a pose controlled object in Babylon.
  13305. * A pose controlled object has both regular pose values as well as pose values
  13306. * from an external device such as a VR head mounted display
  13307. */
  13308. export interface PoseControlled {
  13309. /**
  13310. * The position of the object in babylon space.
  13311. */
  13312. position: Vector3;
  13313. /**
  13314. * The rotation quaternion of the object in babylon space.
  13315. */
  13316. rotationQuaternion: Quaternion;
  13317. /**
  13318. * The position of the device in babylon space.
  13319. */
  13320. devicePosition?: Vector3;
  13321. /**
  13322. * The rotation quaternion of the device in babylon space.
  13323. */
  13324. deviceRotationQuaternion: Quaternion;
  13325. /**
  13326. * The raw pose coming from the device.
  13327. */
  13328. rawPose: Nullable<DevicePose>;
  13329. /**
  13330. * The scale of the device to be used when translating from device space to babylon space.
  13331. */
  13332. deviceScaleFactor: number;
  13333. /**
  13334. * Updates the poseControlled values based on the input device pose.
  13335. * @param poseData the pose data to update the object with
  13336. */
  13337. updateFromDevice(poseData: DevicePose): void;
  13338. }
  13339. /**
  13340. * Set of options to customize the webVRCamera
  13341. */
  13342. export interface WebVROptions {
  13343. /**
  13344. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  13345. */
  13346. trackPosition?: boolean;
  13347. /**
  13348. * Sets the scale of the vrDevice in babylon space. (default: 1)
  13349. */
  13350. positionScale?: number;
  13351. /**
  13352. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  13353. */
  13354. displayName?: string;
  13355. /**
  13356. * Should the native controller meshes be initialized. (default: true)
  13357. */
  13358. controllerMeshes?: boolean;
  13359. /**
  13360. * Creating a default HemiLight only on controllers. (default: true)
  13361. */
  13362. defaultLightingOnControllers?: boolean;
  13363. /**
  13364. * If you don't want to use the default VR button of the helper. (default: false)
  13365. */
  13366. useCustomVRButton?: boolean;
  13367. /**
  13368. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  13369. */
  13370. customVRButton?: HTMLButtonElement;
  13371. /**
  13372. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  13373. */
  13374. rayLength?: number;
  13375. /**
  13376. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  13377. */
  13378. defaultHeight?: number;
  13379. /**
  13380. * If multiview should be used if availible (default: false)
  13381. */
  13382. useMultiview?: boolean;
  13383. }
  13384. /**
  13385. * This represents a WebVR camera.
  13386. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  13387. * @example http://doc.babylonjs.com/how_to/webvr_camera
  13388. */
  13389. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  13390. private webVROptions;
  13391. /**
  13392. * @hidden
  13393. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  13394. */
  13395. _vrDevice: any;
  13396. /**
  13397. * The rawPose of the vrDevice.
  13398. */
  13399. rawPose: Nullable<DevicePose>;
  13400. private _onVREnabled;
  13401. private _specsVersion;
  13402. private _attached;
  13403. private _frameData;
  13404. protected _descendants: Array<Node>;
  13405. private _deviceRoomPosition;
  13406. /** @hidden */
  13407. _deviceRoomRotationQuaternion: Quaternion;
  13408. private _standingMatrix;
  13409. /**
  13410. * Represents device position in babylon space.
  13411. */
  13412. devicePosition: Vector3;
  13413. /**
  13414. * Represents device rotation in babylon space.
  13415. */
  13416. deviceRotationQuaternion: Quaternion;
  13417. /**
  13418. * The scale of the device to be used when translating from device space to babylon space.
  13419. */
  13420. deviceScaleFactor: number;
  13421. private _deviceToWorld;
  13422. private _worldToDevice;
  13423. /**
  13424. * References to the webVR controllers for the vrDevice.
  13425. */
  13426. controllers: Array<WebVRController>;
  13427. /**
  13428. * Emits an event when a controller is attached.
  13429. */
  13430. onControllersAttachedObservable: Observable<WebVRController[]>;
  13431. /**
  13432. * Emits an event when a controller's mesh has been loaded;
  13433. */
  13434. onControllerMeshLoadedObservable: Observable<WebVRController>;
  13435. /**
  13436. * Emits an event when the HMD's pose has been updated.
  13437. */
  13438. onPoseUpdatedFromDeviceObservable: Observable<any>;
  13439. private _poseSet;
  13440. /**
  13441. * If the rig cameras be used as parent instead of this camera.
  13442. */
  13443. rigParenting: boolean;
  13444. private _lightOnControllers;
  13445. private _defaultHeight?;
  13446. /**
  13447. * Instantiates a WebVRFreeCamera.
  13448. * @param name The name of the WebVRFreeCamera
  13449. * @param position The starting anchor position for the camera
  13450. * @param scene The scene the camera belongs to
  13451. * @param webVROptions a set of customizable options for the webVRCamera
  13452. */
  13453. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  13454. /**
  13455. * Gets the device distance from the ground in meters.
  13456. * @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.
  13457. */
  13458. deviceDistanceToRoomGround(): number;
  13459. /**
  13460. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  13461. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  13462. */
  13463. useStandingMatrix(callback?: (bool: boolean) => void): void;
  13464. /**
  13465. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  13466. * @returns A promise with a boolean set to if the standing matrix is supported.
  13467. */
  13468. useStandingMatrixAsync(): Promise<boolean>;
  13469. /**
  13470. * Disposes the camera
  13471. */
  13472. dispose(): void;
  13473. /**
  13474. * Gets a vrController by name.
  13475. * @param name The name of the controller to retreive
  13476. * @returns the controller matching the name specified or null if not found
  13477. */
  13478. getControllerByName(name: string): Nullable<WebVRController>;
  13479. private _leftController;
  13480. /**
  13481. * The controller corrisponding to the users left hand.
  13482. */
  13483. readonly leftController: Nullable<WebVRController>;
  13484. private _rightController;
  13485. /**
  13486. * The controller corrisponding to the users right hand.
  13487. */
  13488. readonly rightController: Nullable<WebVRController>;
  13489. /**
  13490. * Casts a ray forward from the vrCamera's gaze.
  13491. * @param length Length of the ray (default: 100)
  13492. * @returns the ray corrisponding to the gaze
  13493. */
  13494. getForwardRay(length?: number): Ray;
  13495. /**
  13496. * @hidden
  13497. * Updates the camera based on device's frame data
  13498. */
  13499. _checkInputs(): void;
  13500. /**
  13501. * Updates the poseControlled values based on the input device pose.
  13502. * @param poseData Pose coming from the device
  13503. */
  13504. updateFromDevice(poseData: DevicePose): void;
  13505. private _htmlElementAttached;
  13506. private _detachIfAttached;
  13507. /**
  13508. * WebVR's attach control will start broadcasting frames to the device.
  13509. * Note that in certain browsers (chrome for example) this function must be called
  13510. * within a user-interaction callback. Example:
  13511. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  13512. *
  13513. * @param element html element to attach the vrDevice to
  13514. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  13515. */
  13516. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  13517. /**
  13518. * Detaches the camera from the html element and disables VR
  13519. *
  13520. * @param element html element to detach from
  13521. */
  13522. detachControl(element: HTMLElement): void;
  13523. /**
  13524. * @returns the name of this class
  13525. */
  13526. getClassName(): string;
  13527. /**
  13528. * Calls resetPose on the vrDisplay
  13529. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  13530. */
  13531. resetToCurrentRotation(): void;
  13532. /**
  13533. * @hidden
  13534. * Updates the rig cameras (left and right eye)
  13535. */
  13536. _updateRigCameras(): void;
  13537. private _workingVector;
  13538. private _oneVector;
  13539. private _workingMatrix;
  13540. private updateCacheCalled;
  13541. private _correctPositionIfNotTrackPosition;
  13542. /**
  13543. * @hidden
  13544. * Updates the cached values of the camera
  13545. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  13546. */
  13547. _updateCache(ignoreParentClass?: boolean): void;
  13548. /**
  13549. * @hidden
  13550. * Get current device position in babylon world
  13551. */
  13552. _computeDevicePosition(): void;
  13553. /**
  13554. * Updates the current device position and rotation in the babylon world
  13555. */
  13556. update(): void;
  13557. /**
  13558. * @hidden
  13559. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  13560. * @returns an identity matrix
  13561. */
  13562. _getViewMatrix(): Matrix;
  13563. private _tmpMatrix;
  13564. /**
  13565. * This function is called by the two RIG cameras.
  13566. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  13567. * @hidden
  13568. */
  13569. _getWebVRViewMatrix(): Matrix;
  13570. /** @hidden */
  13571. _getWebVRProjectionMatrix(): Matrix;
  13572. private _onGamepadConnectedObserver;
  13573. private _onGamepadDisconnectedObserver;
  13574. private _updateCacheWhenTrackingDisabledObserver;
  13575. /**
  13576. * Initializes the controllers and their meshes
  13577. */
  13578. initControllers(): void;
  13579. }
  13580. }
  13581. declare module "babylonjs/PostProcesses/postProcess" {
  13582. import { Nullable } from "babylonjs/types";
  13583. import { SmartArray } from "babylonjs/Misc/smartArray";
  13584. import { Observable } from "babylonjs/Misc/observable";
  13585. import { Color4, Vector2 } from "babylonjs/Maths/math";
  13586. import { Camera } from "babylonjs/Cameras/camera";
  13587. import { Effect } from "babylonjs/Materials/effect";
  13588. import "babylonjs/Shaders/postprocess.vertex";
  13589. import { IInspectable } from "babylonjs/Misc/iInspectable";
  13590. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  13591. import { Engine } from "babylonjs/Engines/engine";
  13592. /**
  13593. * Size options for a post process
  13594. */
  13595. export type PostProcessOptions = {
  13596. width: number;
  13597. height: number;
  13598. };
  13599. /**
  13600. * PostProcess can be used to apply a shader to a texture after it has been rendered
  13601. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  13602. */
  13603. export class PostProcess {
  13604. /** Name of the PostProcess. */
  13605. name: string;
  13606. /**
  13607. * Gets or sets the unique id of the post process
  13608. */
  13609. uniqueId: number;
  13610. /**
  13611. * Width of the texture to apply the post process on
  13612. */
  13613. width: number;
  13614. /**
  13615. * Height of the texture to apply the post process on
  13616. */
  13617. height: number;
  13618. /**
  13619. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  13620. * @hidden
  13621. */
  13622. _outputTexture: Nullable<InternalTexture>;
  13623. /**
  13624. * Sampling mode used by the shader
  13625. * See https://doc.babylonjs.com/classes/3.1/texture
  13626. */
  13627. renderTargetSamplingMode: number;
  13628. /**
  13629. * Clear color to use when screen clearing
  13630. */
  13631. clearColor: Color4;
  13632. /**
  13633. * If the buffer needs to be cleared before applying the post process. (default: true)
  13634. * Should be set to false if shader will overwrite all previous pixels.
  13635. */
  13636. autoClear: boolean;
  13637. /**
  13638. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  13639. */
  13640. alphaMode: number;
  13641. /**
  13642. * Sets the setAlphaBlendConstants of the babylon engine
  13643. */
  13644. alphaConstants: Color4;
  13645. /**
  13646. * Animations to be used for the post processing
  13647. */
  13648. animations: import("babylonjs/Animations/animation").Animation[];
  13649. /**
  13650. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  13651. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  13652. */
  13653. enablePixelPerfectMode: boolean;
  13654. /**
  13655. * Force the postprocess to be applied without taking in account viewport
  13656. */
  13657. forceFullscreenViewport: boolean;
  13658. /**
  13659. * List of inspectable custom properties (used by the Inspector)
  13660. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  13661. */
  13662. inspectableCustomProperties: IInspectable[];
  13663. /**
  13664. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  13665. *
  13666. * | Value | Type | Description |
  13667. * | ----- | ----------------------------------- | ----------- |
  13668. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  13669. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  13670. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  13671. *
  13672. */
  13673. scaleMode: number;
  13674. /**
  13675. * Force textures to be a power of two (default: false)
  13676. */
  13677. alwaysForcePOT: boolean;
  13678. private _samples;
  13679. /**
  13680. * Number of sample textures (default: 1)
  13681. */
  13682. samples: number;
  13683. /**
  13684. * Modify the scale of the post process to be the same as the viewport (default: false)
  13685. */
  13686. adaptScaleToCurrentViewport: boolean;
  13687. private _camera;
  13688. private _scene;
  13689. private _engine;
  13690. private _options;
  13691. private _reusable;
  13692. private _textureType;
  13693. /**
  13694. * Smart array of input and output textures for the post process.
  13695. * @hidden
  13696. */
  13697. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  13698. /**
  13699. * The index in _textures that corresponds to the output texture.
  13700. * @hidden
  13701. */
  13702. _currentRenderTextureInd: number;
  13703. private _effect;
  13704. private _samplers;
  13705. private _fragmentUrl;
  13706. private _vertexUrl;
  13707. private _parameters;
  13708. private _scaleRatio;
  13709. protected _indexParameters: any;
  13710. private _shareOutputWithPostProcess;
  13711. private _texelSize;
  13712. private _forcedOutputTexture;
  13713. /**
  13714. * Returns the fragment url or shader name used in the post process.
  13715. * @returns the fragment url or name in the shader store.
  13716. */
  13717. getEffectName(): string;
  13718. /**
  13719. * An event triggered when the postprocess is activated.
  13720. */
  13721. onActivateObservable: Observable<Camera>;
  13722. private _onActivateObserver;
  13723. /**
  13724. * A function that is added to the onActivateObservable
  13725. */
  13726. onActivate: Nullable<(camera: Camera) => void>;
  13727. /**
  13728. * An event triggered when the postprocess changes its size.
  13729. */
  13730. onSizeChangedObservable: Observable<PostProcess>;
  13731. private _onSizeChangedObserver;
  13732. /**
  13733. * A function that is added to the onSizeChangedObservable
  13734. */
  13735. onSizeChanged: (postProcess: PostProcess) => void;
  13736. /**
  13737. * An event triggered when the postprocess applies its effect.
  13738. */
  13739. onApplyObservable: Observable<Effect>;
  13740. private _onApplyObserver;
  13741. /**
  13742. * A function that is added to the onApplyObservable
  13743. */
  13744. onApply: (effect: Effect) => void;
  13745. /**
  13746. * An event triggered before rendering the postprocess
  13747. */
  13748. onBeforeRenderObservable: Observable<Effect>;
  13749. private _onBeforeRenderObserver;
  13750. /**
  13751. * A function that is added to the onBeforeRenderObservable
  13752. */
  13753. onBeforeRender: (effect: Effect) => void;
  13754. /**
  13755. * An event triggered after rendering the postprocess
  13756. */
  13757. onAfterRenderObservable: Observable<Effect>;
  13758. private _onAfterRenderObserver;
  13759. /**
  13760. * A function that is added to the onAfterRenderObservable
  13761. */
  13762. onAfterRender: (efect: Effect) => void;
  13763. /**
  13764. * 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
  13765. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  13766. */
  13767. inputTexture: InternalTexture;
  13768. /**
  13769. * Gets the camera which post process is applied to.
  13770. * @returns The camera the post process is applied to.
  13771. */
  13772. getCamera(): Camera;
  13773. /**
  13774. * Gets the texel size of the postprocess.
  13775. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  13776. */
  13777. readonly texelSize: Vector2;
  13778. /**
  13779. * Creates a new instance PostProcess
  13780. * @param name The name of the PostProcess.
  13781. * @param fragmentUrl The url of the fragment shader to be used.
  13782. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  13783. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  13784. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  13785. * @param camera The camera to apply the render pass to.
  13786. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  13787. * @param engine The engine which the post process will be applied. (default: current engine)
  13788. * @param reusable If the post process can be reused on the same frame. (default: false)
  13789. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  13790. * @param textureType Type of textures used when performing the post process. (default: 0)
  13791. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  13792. * @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
  13793. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  13794. */
  13795. constructor(
  13796. /** Name of the PostProcess. */
  13797. 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);
  13798. /**
  13799. * Gets a string idenfifying the name of the class
  13800. * @returns "PostProcess" string
  13801. */
  13802. getClassName(): string;
  13803. /**
  13804. * Gets the engine which this post process belongs to.
  13805. * @returns The engine the post process was enabled with.
  13806. */
  13807. getEngine(): Engine;
  13808. /**
  13809. * The effect that is created when initializing the post process.
  13810. * @returns The created effect corrisponding the the postprocess.
  13811. */
  13812. getEffect(): Effect;
  13813. /**
  13814. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  13815. * @param postProcess The post process to share the output with.
  13816. * @returns This post process.
  13817. */
  13818. shareOutputWith(postProcess: PostProcess): PostProcess;
  13819. /**
  13820. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  13821. * This should be called if the post process that shares output with this post process is disabled/disposed.
  13822. */
  13823. useOwnOutput(): void;
  13824. /**
  13825. * Updates the effect with the current post process compile time values and recompiles the shader.
  13826. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  13827. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  13828. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  13829. * @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
  13830. * @param onCompiled Called when the shader has been compiled.
  13831. * @param onError Called if there is an error when compiling a shader.
  13832. */
  13833. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  13834. /**
  13835. * The post process is reusable if it can be used multiple times within one frame.
  13836. * @returns If the post process is reusable
  13837. */
  13838. isReusable(): boolean;
  13839. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  13840. markTextureDirty(): void;
  13841. /**
  13842. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  13843. * 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.
  13844. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  13845. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  13846. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  13847. * @returns The target texture that was bound to be written to.
  13848. */
  13849. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  13850. /**
  13851. * If the post process is supported.
  13852. */
  13853. readonly isSupported: boolean;
  13854. /**
  13855. * The aspect ratio of the output texture.
  13856. */
  13857. readonly aspectRatio: number;
  13858. /**
  13859. * Get a value indicating if the post-process is ready to be used
  13860. * @returns true if the post-process is ready (shader is compiled)
  13861. */
  13862. isReady(): boolean;
  13863. /**
  13864. * Binds all textures and uniforms to the shader, this will be run on every pass.
  13865. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  13866. */
  13867. apply(): Nullable<Effect>;
  13868. private _disposeTextures;
  13869. /**
  13870. * Disposes the post process.
  13871. * @param camera The camera to dispose the post process on.
  13872. */
  13873. dispose(camera?: Camera): void;
  13874. }
  13875. }
  13876. declare module "babylonjs/PostProcesses/postProcessManager" {
  13877. import { Nullable } from "babylonjs/types";
  13878. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  13879. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  13880. import { Scene } from "babylonjs/scene";
  13881. /**
  13882. * PostProcessManager is used to manage one or more post processes or post process pipelines
  13883. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  13884. */
  13885. export class PostProcessManager {
  13886. private _scene;
  13887. private _indexBuffer;
  13888. private _vertexBuffers;
  13889. /**
  13890. * Creates a new instance PostProcess
  13891. * @param scene The scene that the post process is associated with.
  13892. */
  13893. constructor(scene: Scene);
  13894. private _prepareBuffers;
  13895. private _buildIndexBuffer;
  13896. /**
  13897. * Rebuilds the vertex buffers of the manager.
  13898. * @hidden
  13899. */
  13900. _rebuild(): void;
  13901. /**
  13902. * Prepares a frame to be run through a post process.
  13903. * @param sourceTexture The input texture to the post procesess. (default: null)
  13904. * @param postProcesses An array of post processes to be run. (default: null)
  13905. * @returns True if the post processes were able to be run.
  13906. * @hidden
  13907. */
  13908. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  13909. /**
  13910. * Manually render a set of post processes to a texture.
  13911. * @param postProcesses An array of post processes to be run.
  13912. * @param targetTexture The target texture to render to.
  13913. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  13914. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  13915. * @param lodLevel defines which lod of the texture to render to
  13916. */
  13917. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  13918. /**
  13919. * Finalize the result of the output of the postprocesses.
  13920. * @param doNotPresent If true the result will not be displayed to the screen.
  13921. * @param targetTexture The target texture to render to.
  13922. * @param faceIndex The index of the face to bind the target texture to.
  13923. * @param postProcesses The array of post processes to render.
  13924. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  13925. * @hidden
  13926. */
  13927. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  13928. /**
  13929. * Disposes of the post process manager.
  13930. */
  13931. dispose(): void;
  13932. }
  13933. }
  13934. declare module "babylonjs/Layers/layerSceneComponent" {
  13935. import { Scene } from "babylonjs/scene";
  13936. import { ISceneComponent } from "babylonjs/sceneComponent";
  13937. import { Layer } from "babylonjs/Layers/layer";
  13938. module "babylonjs/abstractScene" {
  13939. interface AbstractScene {
  13940. /**
  13941. * The list of layers (background and foreground) of the scene
  13942. */
  13943. layers: Array<Layer>;
  13944. }
  13945. }
  13946. /**
  13947. * Defines the layer scene component responsible to manage any layers
  13948. * in a given scene.
  13949. */
  13950. export class LayerSceneComponent implements ISceneComponent {
  13951. /**
  13952. * The component name helpfull to identify the component in the list of scene components.
  13953. */
  13954. readonly name: string;
  13955. /**
  13956. * The scene the component belongs to.
  13957. */
  13958. scene: Scene;
  13959. private _engine;
  13960. /**
  13961. * Creates a new instance of the component for the given scene
  13962. * @param scene Defines the scene to register the component in
  13963. */
  13964. constructor(scene: Scene);
  13965. /**
  13966. * Registers the component in a given scene
  13967. */
  13968. register(): void;
  13969. /**
  13970. * Rebuilds the elements related to this component in case of
  13971. * context lost for instance.
  13972. */
  13973. rebuild(): void;
  13974. /**
  13975. * Disposes the component and the associated ressources.
  13976. */
  13977. dispose(): void;
  13978. private _draw;
  13979. private _drawCameraPredicate;
  13980. private _drawCameraBackground;
  13981. private _drawCameraForeground;
  13982. private _drawRenderTargetPredicate;
  13983. private _drawRenderTargetBackground;
  13984. private _drawRenderTargetForeground;
  13985. }
  13986. }
  13987. declare module "babylonjs/Shaders/layer.fragment" {
  13988. /** @hidden */
  13989. export var layerPixelShader: {
  13990. name: string;
  13991. shader: string;
  13992. };
  13993. }
  13994. declare module "babylonjs/Shaders/layer.vertex" {
  13995. /** @hidden */
  13996. export var layerVertexShader: {
  13997. name: string;
  13998. shader: string;
  13999. };
  14000. }
  14001. declare module "babylonjs/Layers/layer" {
  14002. import { Observable } from "babylonjs/Misc/observable";
  14003. import { Nullable } from "babylonjs/types";
  14004. import { Scene } from "babylonjs/scene";
  14005. import { Vector2, Color4 } from "babylonjs/Maths/math";
  14006. import { Texture } from "babylonjs/Materials/Textures/texture";
  14007. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  14008. import "babylonjs/Shaders/layer.fragment";
  14009. import "babylonjs/Shaders/layer.vertex";
  14010. /**
  14011. * This represents a full screen 2d layer.
  14012. * This can be useful to display a picture in the background of your scene for instance.
  14013. * @see https://www.babylonjs-playground.com/#08A2BS#1
  14014. */
  14015. export class Layer {
  14016. /**
  14017. * Define the name of the layer.
  14018. */
  14019. name: string;
  14020. /**
  14021. * Define the texture the layer should display.
  14022. */
  14023. texture: Nullable<Texture>;
  14024. /**
  14025. * Is the layer in background or foreground.
  14026. */
  14027. isBackground: boolean;
  14028. /**
  14029. * Define the color of the layer (instead of texture).
  14030. */
  14031. color: Color4;
  14032. /**
  14033. * Define the scale of the layer in order to zoom in out of the texture.
  14034. */
  14035. scale: Vector2;
  14036. /**
  14037. * Define an offset for the layer in order to shift the texture.
  14038. */
  14039. offset: Vector2;
  14040. /**
  14041. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  14042. */
  14043. alphaBlendingMode: number;
  14044. /**
  14045. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  14046. * Alpha test will not mix with the background color in case of transparency.
  14047. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  14048. */
  14049. alphaTest: boolean;
  14050. /**
  14051. * Define a mask to restrict the layer to only some of the scene cameras.
  14052. */
  14053. layerMask: number;
  14054. /**
  14055. * Define the list of render target the layer is visible into.
  14056. */
  14057. renderTargetTextures: RenderTargetTexture[];
  14058. /**
  14059. * Define if the layer is only used in renderTarget or if it also
  14060. * renders in the main frame buffer of the canvas.
  14061. */
  14062. renderOnlyInRenderTargetTextures: boolean;
  14063. private _scene;
  14064. private _vertexBuffers;
  14065. private _indexBuffer;
  14066. private _effect;
  14067. private _alphaTestEffect;
  14068. /**
  14069. * An event triggered when the layer is disposed.
  14070. */
  14071. onDisposeObservable: Observable<Layer>;
  14072. private _onDisposeObserver;
  14073. /**
  14074. * Back compatibility with callback before the onDisposeObservable existed.
  14075. * The set callback will be triggered when the layer has been disposed.
  14076. */
  14077. onDispose: () => void;
  14078. /**
  14079. * An event triggered before rendering the scene
  14080. */
  14081. onBeforeRenderObservable: Observable<Layer>;
  14082. private _onBeforeRenderObserver;
  14083. /**
  14084. * Back compatibility with callback before the onBeforeRenderObservable existed.
  14085. * The set callback will be triggered just before rendering the layer.
  14086. */
  14087. onBeforeRender: () => void;
  14088. /**
  14089. * An event triggered after rendering the scene
  14090. */
  14091. onAfterRenderObservable: Observable<Layer>;
  14092. private _onAfterRenderObserver;
  14093. /**
  14094. * Back compatibility with callback before the onAfterRenderObservable existed.
  14095. * The set callback will be triggered just after rendering the layer.
  14096. */
  14097. onAfterRender: () => void;
  14098. /**
  14099. * Instantiates a new layer.
  14100. * This represents a full screen 2d layer.
  14101. * This can be useful to display a picture in the background of your scene for instance.
  14102. * @see https://www.babylonjs-playground.com/#08A2BS#1
  14103. * @param name Define the name of the layer in the scene
  14104. * @param imgUrl Define the url of the texture to display in the layer
  14105. * @param scene Define the scene the layer belongs to
  14106. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  14107. * @param color Defines a color for the layer
  14108. */
  14109. constructor(
  14110. /**
  14111. * Define the name of the layer.
  14112. */
  14113. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  14114. private _createIndexBuffer;
  14115. /** @hidden */
  14116. _rebuild(): void;
  14117. /**
  14118. * Renders the layer in the scene.
  14119. */
  14120. render(): void;
  14121. /**
  14122. * Disposes and releases the associated ressources.
  14123. */
  14124. dispose(): void;
  14125. }
  14126. }
  14127. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  14128. import { Scene } from "babylonjs/scene";
  14129. import { ISceneComponent } from "babylonjs/sceneComponent";
  14130. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  14131. module "babylonjs/abstractScene" {
  14132. interface AbstractScene {
  14133. /**
  14134. * The list of procedural textures added to the scene
  14135. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  14136. */
  14137. proceduralTextures: Array<ProceduralTexture>;
  14138. }
  14139. }
  14140. /**
  14141. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  14142. * in a given scene.
  14143. */
  14144. export class ProceduralTextureSceneComponent implements ISceneComponent {
  14145. /**
  14146. * The component name helpfull to identify the component in the list of scene components.
  14147. */
  14148. readonly name: string;
  14149. /**
  14150. * The scene the component belongs to.
  14151. */
  14152. scene: Scene;
  14153. /**
  14154. * Creates a new instance of the component for the given scene
  14155. * @param scene Defines the scene to register the component in
  14156. */
  14157. constructor(scene: Scene);
  14158. /**
  14159. * Registers the component in a given scene
  14160. */
  14161. register(): void;
  14162. /**
  14163. * Rebuilds the elements related to this component in case of
  14164. * context lost for instance.
  14165. */
  14166. rebuild(): void;
  14167. /**
  14168. * Disposes the component and the associated ressources.
  14169. */
  14170. dispose(): void;
  14171. private _beforeClear;
  14172. }
  14173. }
  14174. declare module "babylonjs/Shaders/procedural.vertex" {
  14175. /** @hidden */
  14176. export var proceduralVertexShader: {
  14177. name: string;
  14178. shader: string;
  14179. };
  14180. }
  14181. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  14182. import { Observable } from "babylonjs/Misc/observable";
  14183. import { Nullable } from "babylonjs/types";
  14184. import { Scene } from "babylonjs/scene";
  14185. import { Matrix, Vector3, Vector2, Color3, Color4 } from "babylonjs/Maths/math";
  14186. import { Effect } from "babylonjs/Materials/effect";
  14187. import { Texture } from "babylonjs/Materials/Textures/texture";
  14188. import "babylonjs/Shaders/procedural.vertex";
  14189. /**
  14190. * 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.
  14191. * This is the base class of any Procedural texture and contains most of the shareable code.
  14192. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  14193. */
  14194. export class ProceduralTexture extends Texture {
  14195. isCube: boolean;
  14196. /**
  14197. * Define if the texture is enabled or not (disabled texture will not render)
  14198. */
  14199. isEnabled: boolean;
  14200. /**
  14201. * Define if the texture must be cleared before rendering (default is true)
  14202. */
  14203. autoClear: boolean;
  14204. /**
  14205. * Callback called when the texture is generated
  14206. */
  14207. onGenerated: () => void;
  14208. /**
  14209. * Event raised when the texture is generated
  14210. */
  14211. onGeneratedObservable: Observable<ProceduralTexture>;
  14212. /** @hidden */
  14213. _generateMipMaps: boolean;
  14214. /** @hidden **/
  14215. _effect: Effect;
  14216. /** @hidden */
  14217. _textures: {
  14218. [key: string]: Texture;
  14219. };
  14220. private _size;
  14221. private _currentRefreshId;
  14222. private _refreshRate;
  14223. private _vertexBuffers;
  14224. private _indexBuffer;
  14225. private _uniforms;
  14226. private _samplers;
  14227. private _fragment;
  14228. private _floats;
  14229. private _ints;
  14230. private _floatsArrays;
  14231. private _colors3;
  14232. private _colors4;
  14233. private _vectors2;
  14234. private _vectors3;
  14235. private _matrices;
  14236. private _fallbackTexture;
  14237. private _fallbackTextureUsed;
  14238. private _engine;
  14239. private _cachedDefines;
  14240. private _contentUpdateId;
  14241. private _contentData;
  14242. /**
  14243. * Instantiates a new procedural texture.
  14244. * 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.
  14245. * This is the base class of any Procedural texture and contains most of the shareable code.
  14246. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  14247. * @param name Define the name of the texture
  14248. * @param size Define the size of the texture to create
  14249. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  14250. * @param scene Define the scene the texture belongs to
  14251. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  14252. * @param generateMipMaps Define if the texture should creates mip maps or not
  14253. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  14254. */
  14255. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  14256. /**
  14257. * The effect that is created when initializing the post process.
  14258. * @returns The created effect corrisponding the the postprocess.
  14259. */
  14260. getEffect(): Effect;
  14261. /**
  14262. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  14263. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  14264. */
  14265. getContent(): Nullable<ArrayBufferView>;
  14266. private _createIndexBuffer;
  14267. /** @hidden */
  14268. _rebuild(): void;
  14269. /**
  14270. * Resets the texture in order to recreate its associated resources.
  14271. * This can be called in case of context loss
  14272. */
  14273. reset(): void;
  14274. protected _getDefines(): string;
  14275. /**
  14276. * Is the texture ready to be used ? (rendered at least once)
  14277. * @returns true if ready, otherwise, false.
  14278. */
  14279. isReady(): boolean;
  14280. /**
  14281. * Resets the refresh counter of the texture and start bak from scratch.
  14282. * Could be useful to regenerate the texture if it is setup to render only once.
  14283. */
  14284. resetRefreshCounter(): void;
  14285. /**
  14286. * Set the fragment shader to use in order to render the texture.
  14287. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  14288. */
  14289. setFragment(fragment: any): void;
  14290. /**
  14291. * Define the refresh rate of the texture or the rendering frequency.
  14292. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  14293. */
  14294. refreshRate: number;
  14295. /** @hidden */
  14296. _shouldRender(): boolean;
  14297. /**
  14298. * Get the size the texture is rendering at.
  14299. * @returns the size (texture is always squared)
  14300. */
  14301. getRenderSize(): number;
  14302. /**
  14303. * Resize the texture to new value.
  14304. * @param size Define the new size the texture should have
  14305. * @param generateMipMaps Define whether the new texture should create mip maps
  14306. */
  14307. resize(size: number, generateMipMaps: boolean): void;
  14308. private _checkUniform;
  14309. /**
  14310. * Set a texture in the shader program used to render.
  14311. * @param name Define the name of the uniform samplers as defined in the shader
  14312. * @param texture Define the texture to bind to this sampler
  14313. * @return the texture itself allowing "fluent" like uniform updates
  14314. */
  14315. setTexture(name: string, texture: Texture): ProceduralTexture;
  14316. /**
  14317. * Set a float in the shader.
  14318. * @param name Define the name of the uniform as defined in the shader
  14319. * @param value Define the value to give to the uniform
  14320. * @return the texture itself allowing "fluent" like uniform updates
  14321. */
  14322. setFloat(name: string, value: number): ProceduralTexture;
  14323. /**
  14324. * Set a int in the shader.
  14325. * @param name Define the name of the uniform as defined in the shader
  14326. * @param value Define the value to give to the uniform
  14327. * @return the texture itself allowing "fluent" like uniform updates
  14328. */
  14329. setInt(name: string, value: number): ProceduralTexture;
  14330. /**
  14331. * Set an array of floats in the shader.
  14332. * @param name Define the name of the uniform as defined in the shader
  14333. * @param value Define the value to give to the uniform
  14334. * @return the texture itself allowing "fluent" like uniform updates
  14335. */
  14336. setFloats(name: string, value: number[]): ProceduralTexture;
  14337. /**
  14338. * Set a vec3 in the shader from a Color3.
  14339. * @param name Define the name of the uniform as defined in the shader
  14340. * @param value Define the value to give to the uniform
  14341. * @return the texture itself allowing "fluent" like uniform updates
  14342. */
  14343. setColor3(name: string, value: Color3): ProceduralTexture;
  14344. /**
  14345. * Set a vec4 in the shader from a Color4.
  14346. * @param name Define the name of the uniform as defined in the shader
  14347. * @param value Define the value to give to the uniform
  14348. * @return the texture itself allowing "fluent" like uniform updates
  14349. */
  14350. setColor4(name: string, value: Color4): ProceduralTexture;
  14351. /**
  14352. * Set a vec2 in the shader from a Vector2.
  14353. * @param name Define the name of the uniform as defined in the shader
  14354. * @param value Define the value to give to the uniform
  14355. * @return the texture itself allowing "fluent" like uniform updates
  14356. */
  14357. setVector2(name: string, value: Vector2): ProceduralTexture;
  14358. /**
  14359. * Set a vec3 in the shader from a Vector3.
  14360. * @param name Define the name of the uniform as defined in the shader
  14361. * @param value Define the value to give to the uniform
  14362. * @return the texture itself allowing "fluent" like uniform updates
  14363. */
  14364. setVector3(name: string, value: Vector3): ProceduralTexture;
  14365. /**
  14366. * Set a mat4 in the shader from a MAtrix.
  14367. * @param name Define the name of the uniform as defined in the shader
  14368. * @param value Define the value to give to the uniform
  14369. * @return the texture itself allowing "fluent" like uniform updates
  14370. */
  14371. setMatrix(name: string, value: Matrix): ProceduralTexture;
  14372. /**
  14373. * Render the texture to its associated render target.
  14374. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  14375. */
  14376. render(useCameraPostProcess?: boolean): void;
  14377. /**
  14378. * Clone the texture.
  14379. * @returns the cloned texture
  14380. */
  14381. clone(): ProceduralTexture;
  14382. /**
  14383. * Dispose the texture and release its asoociated resources.
  14384. */
  14385. dispose(): void;
  14386. }
  14387. }
  14388. declare module "babylonjs/Particles/baseParticleSystem" {
  14389. import { Nullable } from "babylonjs/types";
  14390. import { Color4, Vector2, Vector3 } from "babylonjs/Maths/math";
  14391. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14392. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  14393. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  14394. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  14395. import { Scene } from "babylonjs/scene";
  14396. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/tools";
  14397. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  14398. import { Texture } from "babylonjs/Materials/Textures/texture";
  14399. import { Animation } from "babylonjs/Animations/animation";
  14400. /**
  14401. * This represents the base class for particle system in Babylon.
  14402. * 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.
  14403. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  14404. * @example https://doc.babylonjs.com/babylon101/particles
  14405. */
  14406. export class BaseParticleSystem {
  14407. /**
  14408. * Source color is added to the destination color without alpha affecting the result
  14409. */
  14410. static BLENDMODE_ONEONE: number;
  14411. /**
  14412. * Blend current color and particle color using particle’s alpha
  14413. */
  14414. static BLENDMODE_STANDARD: number;
  14415. /**
  14416. * Add current color and particle color multiplied by particle’s alpha
  14417. */
  14418. static BLENDMODE_ADD: number;
  14419. /**
  14420. * Multiply current color with particle color
  14421. */
  14422. static BLENDMODE_MULTIPLY: number;
  14423. /**
  14424. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  14425. */
  14426. static BLENDMODE_MULTIPLYADD: number;
  14427. /**
  14428. * List of animations used by the particle system.
  14429. */
  14430. animations: Animation[];
  14431. /**
  14432. * The id of the Particle system.
  14433. */
  14434. id: string;
  14435. /**
  14436. * The friendly name of the Particle system.
  14437. */
  14438. name: string;
  14439. /**
  14440. * The rendering group used by the Particle system to chose when to render.
  14441. */
  14442. renderingGroupId: number;
  14443. /**
  14444. * The emitter represents the Mesh or position we are attaching the particle system to.
  14445. */
  14446. emitter: Nullable<AbstractMesh | Vector3>;
  14447. /**
  14448. * The maximum number of particles to emit per frame
  14449. */
  14450. emitRate: number;
  14451. /**
  14452. * If you want to launch only a few particles at once, that can be done, as well.
  14453. */
  14454. manualEmitCount: number;
  14455. /**
  14456. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  14457. */
  14458. updateSpeed: number;
  14459. /**
  14460. * The amount of time the particle system is running (depends of the overall update speed).
  14461. */
  14462. targetStopDuration: number;
  14463. /**
  14464. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  14465. */
  14466. disposeOnStop: boolean;
  14467. /**
  14468. * Minimum power of emitting particles.
  14469. */
  14470. minEmitPower: number;
  14471. /**
  14472. * Maximum power of emitting particles.
  14473. */
  14474. maxEmitPower: number;
  14475. /**
  14476. * Minimum life time of emitting particles.
  14477. */
  14478. minLifeTime: number;
  14479. /**
  14480. * Maximum life time of emitting particles.
  14481. */
  14482. maxLifeTime: number;
  14483. /**
  14484. * Minimum Size of emitting particles.
  14485. */
  14486. minSize: number;
  14487. /**
  14488. * Maximum Size of emitting particles.
  14489. */
  14490. maxSize: number;
  14491. /**
  14492. * Minimum scale of emitting particles on X axis.
  14493. */
  14494. minScaleX: number;
  14495. /**
  14496. * Maximum scale of emitting particles on X axis.
  14497. */
  14498. maxScaleX: number;
  14499. /**
  14500. * Minimum scale of emitting particles on Y axis.
  14501. */
  14502. minScaleY: number;
  14503. /**
  14504. * Maximum scale of emitting particles on Y axis.
  14505. */
  14506. maxScaleY: number;
  14507. /**
  14508. * Gets or sets the minimal initial rotation in radians.
  14509. */
  14510. minInitialRotation: number;
  14511. /**
  14512. * Gets or sets the maximal initial rotation in radians.
  14513. */
  14514. maxInitialRotation: number;
  14515. /**
  14516. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  14517. */
  14518. minAngularSpeed: number;
  14519. /**
  14520. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  14521. */
  14522. maxAngularSpeed: number;
  14523. /**
  14524. * The texture used to render each particle. (this can be a spritesheet)
  14525. */
  14526. particleTexture: Nullable<Texture>;
  14527. /**
  14528. * The layer mask we are rendering the particles through.
  14529. */
  14530. layerMask: number;
  14531. /**
  14532. * This can help using your own shader to render the particle system.
  14533. * The according effect will be created
  14534. */
  14535. customShader: any;
  14536. /**
  14537. * By default particle system starts as soon as they are created. This prevents the
  14538. * automatic start to happen and let you decide when to start emitting particles.
  14539. */
  14540. preventAutoStart: boolean;
  14541. private _noiseTexture;
  14542. /**
  14543. * Gets or sets a texture used to add random noise to particle positions
  14544. */
  14545. noiseTexture: Nullable<ProceduralTexture>;
  14546. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  14547. noiseStrength: Vector3;
  14548. /**
  14549. * Callback triggered when the particle animation is ending.
  14550. */
  14551. onAnimationEnd: Nullable<() => void>;
  14552. /**
  14553. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  14554. */
  14555. blendMode: number;
  14556. /**
  14557. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  14558. * to override the particles.
  14559. */
  14560. forceDepthWrite: boolean;
  14561. /** 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 */
  14562. preWarmCycles: number;
  14563. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  14564. preWarmStepOffset: number;
  14565. /**
  14566. * 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)
  14567. */
  14568. spriteCellChangeSpeed: number;
  14569. /**
  14570. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  14571. */
  14572. startSpriteCellID: number;
  14573. /**
  14574. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  14575. */
  14576. endSpriteCellID: number;
  14577. /**
  14578. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  14579. */
  14580. spriteCellWidth: number;
  14581. /**
  14582. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  14583. */
  14584. spriteCellHeight: number;
  14585. /**
  14586. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  14587. */
  14588. spriteRandomStartCell: boolean;
  14589. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  14590. translationPivot: Vector2;
  14591. /** @hidden */
  14592. protected _isAnimationSheetEnabled: boolean;
  14593. /**
  14594. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  14595. */
  14596. beginAnimationOnStart: boolean;
  14597. /**
  14598. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  14599. */
  14600. beginAnimationFrom: number;
  14601. /**
  14602. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  14603. */
  14604. beginAnimationTo: number;
  14605. /**
  14606. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  14607. */
  14608. beginAnimationLoop: boolean;
  14609. /**
  14610. * Gets or sets a world offset applied to all particles
  14611. */
  14612. worldOffset: Vector3;
  14613. /**
  14614. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  14615. */
  14616. isAnimationSheetEnabled: boolean;
  14617. /**
  14618. * Get hosting scene
  14619. * @returns the scene
  14620. */
  14621. getScene(): Scene;
  14622. /**
  14623. * You can use gravity if you want to give an orientation to your particles.
  14624. */
  14625. gravity: Vector3;
  14626. protected _colorGradients: Nullable<Array<ColorGradient>>;
  14627. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  14628. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  14629. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  14630. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  14631. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  14632. protected _dragGradients: Nullable<Array<FactorGradient>>;
  14633. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  14634. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  14635. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  14636. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  14637. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  14638. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  14639. /**
  14640. * Defines the delay in milliseconds before starting the system (0 by default)
  14641. */
  14642. startDelay: number;
  14643. /**
  14644. * Gets the current list of drag gradients.
  14645. * You must use addDragGradient and removeDragGradient to udpate this list
  14646. * @returns the list of drag gradients
  14647. */
  14648. getDragGradients(): Nullable<Array<FactorGradient>>;
  14649. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  14650. limitVelocityDamping: number;
  14651. /**
  14652. * Gets the current list of limit velocity gradients.
  14653. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  14654. * @returns the list of limit velocity gradients
  14655. */
  14656. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  14657. /**
  14658. * Gets the current list of color gradients.
  14659. * You must use addColorGradient and removeColorGradient to udpate this list
  14660. * @returns the list of color gradients
  14661. */
  14662. getColorGradients(): Nullable<Array<ColorGradient>>;
  14663. /**
  14664. * Gets the current list of size gradients.
  14665. * You must use addSizeGradient and removeSizeGradient to udpate this list
  14666. * @returns the list of size gradients
  14667. */
  14668. getSizeGradients(): Nullable<Array<FactorGradient>>;
  14669. /**
  14670. * Gets the current list of color remap gradients.
  14671. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  14672. * @returns the list of color remap gradients
  14673. */
  14674. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  14675. /**
  14676. * Gets the current list of alpha remap gradients.
  14677. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  14678. * @returns the list of alpha remap gradients
  14679. */
  14680. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  14681. /**
  14682. * Gets the current list of life time gradients.
  14683. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  14684. * @returns the list of life time gradients
  14685. */
  14686. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  14687. /**
  14688. * Gets the current list of angular speed gradients.
  14689. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  14690. * @returns the list of angular speed gradients
  14691. */
  14692. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  14693. /**
  14694. * Gets the current list of velocity gradients.
  14695. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  14696. * @returns the list of velocity gradients
  14697. */
  14698. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  14699. /**
  14700. * Gets the current list of start size gradients.
  14701. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  14702. * @returns the list of start size gradients
  14703. */
  14704. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  14705. /**
  14706. * Gets the current list of emit rate gradients.
  14707. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  14708. * @returns the list of emit rate gradients
  14709. */
  14710. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  14711. /**
  14712. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14713. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14714. */
  14715. direction1: Vector3;
  14716. /**
  14717. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14718. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14719. */
  14720. direction2: Vector3;
  14721. /**
  14722. * 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.
  14723. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14724. */
  14725. minEmitBox: Vector3;
  14726. /**
  14727. * 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.
  14728. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14729. */
  14730. maxEmitBox: Vector3;
  14731. /**
  14732. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  14733. */
  14734. color1: Color4;
  14735. /**
  14736. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  14737. */
  14738. color2: Color4;
  14739. /**
  14740. * Color the particle will have at the end of its lifetime
  14741. */
  14742. colorDead: Color4;
  14743. /**
  14744. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  14745. */
  14746. textureMask: Color4;
  14747. /**
  14748. * The particle emitter type defines the emitter used by the particle system.
  14749. * It can be for example box, sphere, or cone...
  14750. */
  14751. particleEmitterType: IParticleEmitterType;
  14752. /** @hidden */
  14753. _isSubEmitter: boolean;
  14754. /**
  14755. * Gets or sets the billboard mode to use when isBillboardBased = true.
  14756. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  14757. */
  14758. billboardMode: number;
  14759. protected _isBillboardBased: boolean;
  14760. /**
  14761. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  14762. */
  14763. isBillboardBased: boolean;
  14764. /**
  14765. * The scene the particle system belongs to.
  14766. */
  14767. protected _scene: Scene;
  14768. /**
  14769. * Local cache of defines for image processing.
  14770. */
  14771. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  14772. /**
  14773. * Default configuration related to image processing available in the standard Material.
  14774. */
  14775. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  14776. /**
  14777. * Gets the image processing configuration used either in this material.
  14778. */
  14779. /**
  14780. * Sets the Default image processing configuration used either in the this material.
  14781. *
  14782. * If sets to null, the scene one is in use.
  14783. */
  14784. imageProcessingConfiguration: ImageProcessingConfiguration;
  14785. /**
  14786. * Attaches a new image processing configuration to the Standard Material.
  14787. * @param configuration
  14788. */
  14789. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  14790. /** @hidden */
  14791. protected _reset(): void;
  14792. /** @hidden */
  14793. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  14794. /**
  14795. * Instantiates a particle system.
  14796. * 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.
  14797. * @param name The name of the particle system
  14798. */
  14799. constructor(name: string);
  14800. /**
  14801. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  14802. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14803. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14804. * @returns the emitter
  14805. */
  14806. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  14807. /**
  14808. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  14809. * @param radius The radius of the hemisphere to emit from
  14810. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14811. * @returns the emitter
  14812. */
  14813. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  14814. /**
  14815. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  14816. * @param radius The radius of the sphere to emit from
  14817. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14818. * @returns the emitter
  14819. */
  14820. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  14821. /**
  14822. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  14823. * @param radius The radius of the sphere to emit from
  14824. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  14825. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  14826. * @returns the emitter
  14827. */
  14828. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  14829. /**
  14830. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  14831. * @param radius The radius of the emission cylinder
  14832. * @param height The height of the emission cylinder
  14833. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  14834. * @param directionRandomizer How much to randomize the particle direction [0-1]
  14835. * @returns the emitter
  14836. */
  14837. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  14838. /**
  14839. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  14840. * @param radius The radius of the cylinder to emit from
  14841. * @param height The height of the emission cylinder
  14842. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  14843. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  14844. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  14845. * @returns the emitter
  14846. */
  14847. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  14848. /**
  14849. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  14850. * @param radius The radius of the cone to emit from
  14851. * @param angle The base angle of the cone
  14852. * @returns the emitter
  14853. */
  14854. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  14855. /**
  14856. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  14857. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14858. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14859. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14860. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14861. * @returns the emitter
  14862. */
  14863. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  14864. }
  14865. }
  14866. declare module "babylonjs/Particles/subEmitter" {
  14867. import { Scene } from "babylonjs/scene";
  14868. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  14869. /**
  14870. * Type of sub emitter
  14871. */
  14872. export enum SubEmitterType {
  14873. /**
  14874. * Attached to the particle over it's lifetime
  14875. */
  14876. ATTACHED = 0,
  14877. /**
  14878. * Created when the particle dies
  14879. */
  14880. END = 1
  14881. }
  14882. /**
  14883. * Sub emitter class used to emit particles from an existing particle
  14884. */
  14885. export class SubEmitter {
  14886. /**
  14887. * the particle system to be used by the sub emitter
  14888. */
  14889. particleSystem: ParticleSystem;
  14890. /**
  14891. * Type of the submitter (Default: END)
  14892. */
  14893. type: SubEmitterType;
  14894. /**
  14895. * 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)
  14896. * Note: This only is supported when using an emitter of type Mesh
  14897. */
  14898. inheritDirection: boolean;
  14899. /**
  14900. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  14901. */
  14902. inheritedVelocityAmount: number;
  14903. /**
  14904. * Creates a sub emitter
  14905. * @param particleSystem the particle system to be used by the sub emitter
  14906. */
  14907. constructor(
  14908. /**
  14909. * the particle system to be used by the sub emitter
  14910. */
  14911. particleSystem: ParticleSystem);
  14912. /**
  14913. * Clones the sub emitter
  14914. * @returns the cloned sub emitter
  14915. */
  14916. clone(): SubEmitter;
  14917. /**
  14918. * Serialize current object to a JSON object
  14919. * @returns the serialized object
  14920. */
  14921. serialize(): any;
  14922. /** @hidden */
  14923. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  14924. /**
  14925. * Creates a new SubEmitter from a serialized JSON version
  14926. * @param serializationObject defines the JSON object to read from
  14927. * @param scene defines the hosting scene
  14928. * @param rootUrl defines the rootUrl for data loading
  14929. * @returns a new SubEmitter
  14930. */
  14931. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  14932. /** Release associated resources */
  14933. dispose(): void;
  14934. }
  14935. }
  14936. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration" {
  14937. /** @hidden */
  14938. export var clipPlaneFragmentDeclaration: {
  14939. name: string;
  14940. shader: string;
  14941. };
  14942. }
  14943. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  14944. /** @hidden */
  14945. export var imageProcessingDeclaration: {
  14946. name: string;
  14947. shader: string;
  14948. };
  14949. }
  14950. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  14951. /** @hidden */
  14952. export var imageProcessingFunctions: {
  14953. name: string;
  14954. shader: string;
  14955. };
  14956. }
  14957. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragment" {
  14958. /** @hidden */
  14959. export var clipPlaneFragment: {
  14960. name: string;
  14961. shader: string;
  14962. };
  14963. }
  14964. declare module "babylonjs/Shaders/particles.fragment" {
  14965. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  14966. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  14967. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  14968. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  14969. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  14970. /** @hidden */
  14971. export var particlesPixelShader: {
  14972. name: string;
  14973. shader: string;
  14974. };
  14975. }
  14976. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration" {
  14977. /** @hidden */
  14978. export var clipPlaneVertexDeclaration: {
  14979. name: string;
  14980. shader: string;
  14981. };
  14982. }
  14983. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertex" {
  14984. /** @hidden */
  14985. export var clipPlaneVertex: {
  14986. name: string;
  14987. shader: string;
  14988. };
  14989. }
  14990. declare module "babylonjs/Shaders/particles.vertex" {
  14991. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  14992. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  14993. /** @hidden */
  14994. export var particlesVertexShader: {
  14995. name: string;
  14996. shader: string;
  14997. };
  14998. }
  14999. declare module "babylonjs/Particles/particleSystem" {
  15000. import { Nullable } from "babylonjs/types";
  15001. import { IAnimatable, FactorGradient, Color3Gradient } from "babylonjs/Misc/tools";
  15002. import { Observable } from "babylonjs/Misc/observable";
  15003. import { Color4, Color3, Vector3, Matrix } from "babylonjs/Maths/math";
  15004. import { Effect } from "babylonjs/Materials/effect";
  15005. import { Scene, IDisposable } from "babylonjs/scene";
  15006. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  15007. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  15008. import { Particle } from "babylonjs/Particles/particle";
  15009. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  15010. import "babylonjs/Shaders/particles.fragment";
  15011. import "babylonjs/Shaders/particles.vertex";
  15012. /**
  15013. * This represents a particle system in Babylon.
  15014. * 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.
  15015. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  15016. * @example https://doc.babylonjs.com/babylon101/particles
  15017. */
  15018. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  15019. /**
  15020. * Billboard mode will only apply to Y axis
  15021. */
  15022. static readonly BILLBOARDMODE_Y: number;
  15023. /**
  15024. * Billboard mode will apply to all axes
  15025. */
  15026. static readonly BILLBOARDMODE_ALL: number;
  15027. /**
  15028. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  15029. */
  15030. static readonly BILLBOARDMODE_STRETCHED: number;
  15031. /**
  15032. * This function can be defined to provide custom update for active particles.
  15033. * This function will be called instead of regular update (age, position, color, etc.).
  15034. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  15035. */
  15036. updateFunction: (particles: Particle[]) => void;
  15037. private _emitterWorldMatrix;
  15038. /**
  15039. * This function can be defined to specify initial direction for every new particle.
  15040. * It by default use the emitterType defined function
  15041. */
  15042. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  15043. /**
  15044. * This function can be defined to specify initial position for every new particle.
  15045. * It by default use the emitterType defined function
  15046. */
  15047. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  15048. /**
  15049. * @hidden
  15050. */
  15051. _inheritedVelocityOffset: Vector3;
  15052. /**
  15053. * An event triggered when the system is disposed
  15054. */
  15055. onDisposeObservable: Observable<ParticleSystem>;
  15056. private _onDisposeObserver;
  15057. /**
  15058. * Sets a callback that will be triggered when the system is disposed
  15059. */
  15060. onDispose: () => void;
  15061. private _particles;
  15062. private _epsilon;
  15063. private _capacity;
  15064. private _stockParticles;
  15065. private _newPartsExcess;
  15066. private _vertexData;
  15067. private _vertexBuffer;
  15068. private _vertexBuffers;
  15069. private _spriteBuffer;
  15070. private _indexBuffer;
  15071. private _effect;
  15072. private _customEffect;
  15073. private _cachedDefines;
  15074. private _scaledColorStep;
  15075. private _colorDiff;
  15076. private _scaledDirection;
  15077. private _scaledGravity;
  15078. private _currentRenderId;
  15079. private _alive;
  15080. private _useInstancing;
  15081. private _started;
  15082. private _stopped;
  15083. private _actualFrame;
  15084. private _scaledUpdateSpeed;
  15085. private _vertexBufferSize;
  15086. /** @hidden */
  15087. _currentEmitRateGradient: Nullable<FactorGradient>;
  15088. /** @hidden */
  15089. _currentEmitRate1: number;
  15090. /** @hidden */
  15091. _currentEmitRate2: number;
  15092. /** @hidden */
  15093. _currentStartSizeGradient: Nullable<FactorGradient>;
  15094. /** @hidden */
  15095. _currentStartSize1: number;
  15096. /** @hidden */
  15097. _currentStartSize2: number;
  15098. private readonly _rawTextureWidth;
  15099. private _rampGradientsTexture;
  15100. private _useRampGradients;
  15101. /** Gets or sets a boolean indicating that ramp gradients must be used
  15102. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  15103. */
  15104. useRampGradients: boolean;
  15105. /**
  15106. * 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.
  15107. * 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: [])
  15108. */
  15109. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  15110. private _subEmitters;
  15111. /**
  15112. * @hidden
  15113. * If the particle systems emitter should be disposed when the particle system is disposed
  15114. */
  15115. _disposeEmitterOnDispose: boolean;
  15116. /**
  15117. * The current active Sub-systems, this property is used by the root particle system only.
  15118. */
  15119. activeSubSystems: Array<ParticleSystem>;
  15120. private _rootParticleSystem;
  15121. /**
  15122. * Gets the current list of active particles
  15123. */
  15124. readonly particles: Particle[];
  15125. /**
  15126. * Returns the string "ParticleSystem"
  15127. * @returns a string containing the class name
  15128. */
  15129. getClassName(): string;
  15130. /**
  15131. * Instantiates a particle system.
  15132. * 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.
  15133. * @param name The name of the particle system
  15134. * @param capacity The max number of particles alive at the same time
  15135. * @param scene The scene the particle system belongs to
  15136. * @param customEffect a custom effect used to change the way particles are rendered by default
  15137. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  15138. * @param epsilon Offset used to render the particles
  15139. */
  15140. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  15141. private _addFactorGradient;
  15142. private _removeFactorGradient;
  15143. /**
  15144. * Adds a new life time gradient
  15145. * @param gradient defines the gradient to use (between 0 and 1)
  15146. * @param factor defines the life time factor to affect to the specified gradient
  15147. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15148. * @returns the current particle system
  15149. */
  15150. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15151. /**
  15152. * Remove a specific life time gradient
  15153. * @param gradient defines the gradient to remove
  15154. * @returns the current particle system
  15155. */
  15156. removeLifeTimeGradient(gradient: number): IParticleSystem;
  15157. /**
  15158. * Adds a new size gradient
  15159. * @param gradient defines the gradient to use (between 0 and 1)
  15160. * @param factor defines the size factor to affect to the specified gradient
  15161. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15162. * @returns the current particle system
  15163. */
  15164. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15165. /**
  15166. * Remove a specific size gradient
  15167. * @param gradient defines the gradient to remove
  15168. * @returns the current particle system
  15169. */
  15170. removeSizeGradient(gradient: number): IParticleSystem;
  15171. /**
  15172. * Adds a new color remap gradient
  15173. * @param gradient defines the gradient to use (between 0 and 1)
  15174. * @param min defines the color remap minimal range
  15175. * @param max defines the color remap maximal range
  15176. * @returns the current particle system
  15177. */
  15178. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  15179. /**
  15180. * Remove a specific color remap gradient
  15181. * @param gradient defines the gradient to remove
  15182. * @returns the current particle system
  15183. */
  15184. removeColorRemapGradient(gradient: number): IParticleSystem;
  15185. /**
  15186. * Adds a new alpha remap gradient
  15187. * @param gradient defines the gradient to use (between 0 and 1)
  15188. * @param min defines the alpha remap minimal range
  15189. * @param max defines the alpha remap maximal range
  15190. * @returns the current particle system
  15191. */
  15192. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  15193. /**
  15194. * Remove a specific alpha remap gradient
  15195. * @param gradient defines the gradient to remove
  15196. * @returns the current particle system
  15197. */
  15198. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  15199. /**
  15200. * Adds a new angular speed gradient
  15201. * @param gradient defines the gradient to use (between 0 and 1)
  15202. * @param factor defines the angular speed to affect to the specified gradient
  15203. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15204. * @returns the current particle system
  15205. */
  15206. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15207. /**
  15208. * Remove a specific angular speed gradient
  15209. * @param gradient defines the gradient to remove
  15210. * @returns the current particle system
  15211. */
  15212. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  15213. /**
  15214. * Adds a new velocity gradient
  15215. * @param gradient defines the gradient to use (between 0 and 1)
  15216. * @param factor defines the velocity to affect to the specified gradient
  15217. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15218. * @returns the current particle system
  15219. */
  15220. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15221. /**
  15222. * Remove a specific velocity gradient
  15223. * @param gradient defines the gradient to remove
  15224. * @returns the current particle system
  15225. */
  15226. removeVelocityGradient(gradient: number): IParticleSystem;
  15227. /**
  15228. * Adds a new limit velocity gradient
  15229. * @param gradient defines the gradient to use (between 0 and 1)
  15230. * @param factor defines the limit velocity value to affect to the specified gradient
  15231. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15232. * @returns the current particle system
  15233. */
  15234. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15235. /**
  15236. * Remove a specific limit velocity gradient
  15237. * @param gradient defines the gradient to remove
  15238. * @returns the current particle system
  15239. */
  15240. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  15241. /**
  15242. * Adds a new drag gradient
  15243. * @param gradient defines the gradient to use (between 0 and 1)
  15244. * @param factor defines the drag value to affect to the specified gradient
  15245. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15246. * @returns the current particle system
  15247. */
  15248. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15249. /**
  15250. * Remove a specific drag gradient
  15251. * @param gradient defines the gradient to remove
  15252. * @returns the current particle system
  15253. */
  15254. removeDragGradient(gradient: number): IParticleSystem;
  15255. /**
  15256. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  15257. * @param gradient defines the gradient to use (between 0 and 1)
  15258. * @param factor defines the emit rate value to affect to the specified gradient
  15259. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15260. * @returns the current particle system
  15261. */
  15262. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15263. /**
  15264. * Remove a specific emit rate gradient
  15265. * @param gradient defines the gradient to remove
  15266. * @returns the current particle system
  15267. */
  15268. removeEmitRateGradient(gradient: number): IParticleSystem;
  15269. /**
  15270. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  15271. * @param gradient defines the gradient to use (between 0 and 1)
  15272. * @param factor defines the start size value to affect to the specified gradient
  15273. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15274. * @returns the current particle system
  15275. */
  15276. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15277. /**
  15278. * Remove a specific start size gradient
  15279. * @param gradient defines the gradient to remove
  15280. * @returns the current particle system
  15281. */
  15282. removeStartSizeGradient(gradient: number): IParticleSystem;
  15283. private _createRampGradientTexture;
  15284. /**
  15285. * Gets the current list of ramp gradients.
  15286. * You must use addRampGradient and removeRampGradient to udpate this list
  15287. * @returns the list of ramp gradients
  15288. */
  15289. getRampGradients(): Nullable<Array<Color3Gradient>>;
  15290. /**
  15291. * Adds a new ramp gradient used to remap particle colors
  15292. * @param gradient defines the gradient to use (between 0 and 1)
  15293. * @param color defines the color to affect to the specified gradient
  15294. * @returns the current particle system
  15295. */
  15296. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  15297. /**
  15298. * Remove a specific ramp gradient
  15299. * @param gradient defines the gradient to remove
  15300. * @returns the current particle system
  15301. */
  15302. removeRampGradient(gradient: number): ParticleSystem;
  15303. /**
  15304. * Adds a new color gradient
  15305. * @param gradient defines the gradient to use (between 0 and 1)
  15306. * @param color1 defines the color to affect to the specified gradient
  15307. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  15308. * @returns this particle system
  15309. */
  15310. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  15311. /**
  15312. * Remove a specific color gradient
  15313. * @param gradient defines the gradient to remove
  15314. * @returns this particle system
  15315. */
  15316. removeColorGradient(gradient: number): IParticleSystem;
  15317. private _fetchR;
  15318. protected _reset(): void;
  15319. private _resetEffect;
  15320. private _createVertexBuffers;
  15321. private _createIndexBuffer;
  15322. /**
  15323. * Gets the maximum number of particles active at the same time.
  15324. * @returns The max number of active particles.
  15325. */
  15326. getCapacity(): number;
  15327. /**
  15328. * Gets whether there are still active particles in the system.
  15329. * @returns True if it is alive, otherwise false.
  15330. */
  15331. isAlive(): boolean;
  15332. /**
  15333. * Gets if the system has been started. (Note: this will still be true after stop is called)
  15334. * @returns True if it has been started, otherwise false.
  15335. */
  15336. isStarted(): boolean;
  15337. private _prepareSubEmitterInternalArray;
  15338. /**
  15339. * Starts the particle system and begins to emit
  15340. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  15341. */
  15342. start(delay?: number): void;
  15343. /**
  15344. * Stops the particle system.
  15345. * @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.
  15346. */
  15347. stop(stopSubEmitters?: boolean): void;
  15348. /**
  15349. * Remove all active particles
  15350. */
  15351. reset(): void;
  15352. /**
  15353. * @hidden (for internal use only)
  15354. */
  15355. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  15356. /**
  15357. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  15358. * Its lifetime will start back at 0.
  15359. */
  15360. recycleParticle: (particle: Particle) => void;
  15361. private _stopSubEmitters;
  15362. private _createParticle;
  15363. private _removeFromRoot;
  15364. private _emitFromParticle;
  15365. private _update;
  15366. /** @hidden */
  15367. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  15368. /** @hidden */
  15369. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  15370. /** @hidden */
  15371. private _getEffect;
  15372. /**
  15373. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  15374. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  15375. */
  15376. animate(preWarmOnly?: boolean): void;
  15377. private _appendParticleVertices;
  15378. /**
  15379. * Rebuilds the particle system.
  15380. */
  15381. rebuild(): void;
  15382. /**
  15383. * Is this system ready to be used/rendered
  15384. * @return true if the system is ready
  15385. */
  15386. isReady(): boolean;
  15387. private _render;
  15388. /**
  15389. * Renders the particle system in its current state.
  15390. * @returns the current number of particles
  15391. */
  15392. render(): number;
  15393. /**
  15394. * Disposes the particle system and free the associated resources
  15395. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  15396. */
  15397. dispose(disposeTexture?: boolean): void;
  15398. /**
  15399. * Clones the particle system.
  15400. * @param name The name of the cloned object
  15401. * @param newEmitter The new emitter to use
  15402. * @returns the cloned particle system
  15403. */
  15404. clone(name: string, newEmitter: any): ParticleSystem;
  15405. /**
  15406. * Serializes the particle system to a JSON object.
  15407. * @returns the JSON object
  15408. */
  15409. serialize(): any;
  15410. /** @hidden */
  15411. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  15412. /** @hidden */
  15413. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  15414. /**
  15415. * Parses a JSON object to create a particle system.
  15416. * @param parsedParticleSystem The JSON object to parse
  15417. * @param scene The scene to create the particle system in
  15418. * @param rootUrl The root url to use to load external dependencies like texture
  15419. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  15420. * @returns the Parsed particle system
  15421. */
  15422. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  15423. }
  15424. }
  15425. declare module "babylonjs/Particles/particle" {
  15426. import { Nullable } from "babylonjs/types";
  15427. import { Color4, Vector2, Vector3, Vector4 } from "babylonjs/Maths/math";
  15428. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  15429. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  15430. import { ColorGradient, FactorGradient } from "babylonjs/Misc/tools";
  15431. /**
  15432. * A particle represents one of the element emitted by a particle system.
  15433. * This is mainly define by its coordinates, direction, velocity and age.
  15434. */
  15435. export class Particle {
  15436. /**
  15437. * The particle system the particle belongs to.
  15438. */
  15439. particleSystem: ParticleSystem;
  15440. private static _Count;
  15441. /**
  15442. * Unique ID of the particle
  15443. */
  15444. id: number;
  15445. /**
  15446. * The world position of the particle in the scene.
  15447. */
  15448. position: Vector3;
  15449. /**
  15450. * The world direction of the particle in the scene.
  15451. */
  15452. direction: Vector3;
  15453. /**
  15454. * The color of the particle.
  15455. */
  15456. color: Color4;
  15457. /**
  15458. * The color change of the particle per step.
  15459. */
  15460. colorStep: Color4;
  15461. /**
  15462. * Defines how long will the life of the particle be.
  15463. */
  15464. lifeTime: number;
  15465. /**
  15466. * The current age of the particle.
  15467. */
  15468. age: number;
  15469. /**
  15470. * The current size of the particle.
  15471. */
  15472. size: number;
  15473. /**
  15474. * The current scale of the particle.
  15475. */
  15476. scale: Vector2;
  15477. /**
  15478. * The current angle of the particle.
  15479. */
  15480. angle: number;
  15481. /**
  15482. * Defines how fast is the angle changing.
  15483. */
  15484. angularSpeed: number;
  15485. /**
  15486. * Defines the cell index used by the particle to be rendered from a sprite.
  15487. */
  15488. cellIndex: number;
  15489. /**
  15490. * The information required to support color remapping
  15491. */
  15492. remapData: Vector4;
  15493. /** @hidden */
  15494. _randomCellOffset?: number;
  15495. /** @hidden */
  15496. _initialDirection: Nullable<Vector3>;
  15497. /** @hidden */
  15498. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  15499. /** @hidden */
  15500. _initialStartSpriteCellID: number;
  15501. /** @hidden */
  15502. _initialEndSpriteCellID: number;
  15503. /** @hidden */
  15504. _currentColorGradient: Nullable<ColorGradient>;
  15505. /** @hidden */
  15506. _currentColor1: Color4;
  15507. /** @hidden */
  15508. _currentColor2: Color4;
  15509. /** @hidden */
  15510. _currentSizeGradient: Nullable<FactorGradient>;
  15511. /** @hidden */
  15512. _currentSize1: number;
  15513. /** @hidden */
  15514. _currentSize2: number;
  15515. /** @hidden */
  15516. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  15517. /** @hidden */
  15518. _currentAngularSpeed1: number;
  15519. /** @hidden */
  15520. _currentAngularSpeed2: number;
  15521. /** @hidden */
  15522. _currentVelocityGradient: Nullable<FactorGradient>;
  15523. /** @hidden */
  15524. _currentVelocity1: number;
  15525. /** @hidden */
  15526. _currentVelocity2: number;
  15527. /** @hidden */
  15528. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  15529. /** @hidden */
  15530. _currentLimitVelocity1: number;
  15531. /** @hidden */
  15532. _currentLimitVelocity2: number;
  15533. /** @hidden */
  15534. _currentDragGradient: Nullable<FactorGradient>;
  15535. /** @hidden */
  15536. _currentDrag1: number;
  15537. /** @hidden */
  15538. _currentDrag2: number;
  15539. /** @hidden */
  15540. _randomNoiseCoordinates1: Vector3;
  15541. /** @hidden */
  15542. _randomNoiseCoordinates2: Vector3;
  15543. /**
  15544. * Creates a new instance Particle
  15545. * @param particleSystem the particle system the particle belongs to
  15546. */
  15547. constructor(
  15548. /**
  15549. * The particle system the particle belongs to.
  15550. */
  15551. particleSystem: ParticleSystem);
  15552. private updateCellInfoFromSystem;
  15553. /**
  15554. * Defines how the sprite cell index is updated for the particle
  15555. */
  15556. updateCellIndex(): void;
  15557. /** @hidden */
  15558. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  15559. /** @hidden */
  15560. _inheritParticleInfoToSubEmitters(): void;
  15561. /** @hidden */
  15562. _reset(): void;
  15563. /**
  15564. * Copy the properties of particle to another one.
  15565. * @param other the particle to copy the information to.
  15566. */
  15567. copyTo(other: Particle): void;
  15568. }
  15569. }
  15570. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  15571. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15572. import { Effect } from "babylonjs/Materials/effect";
  15573. import { Particle } from "babylonjs/Particles/particle";
  15574. /**
  15575. * Particle emitter represents a volume emitting particles.
  15576. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  15577. */
  15578. export interface IParticleEmitterType {
  15579. /**
  15580. * Called by the particle System when the direction is computed for the created particle.
  15581. * @param worldMatrix is the world matrix of the particle system
  15582. * @param directionToUpdate is the direction vector to update with the result
  15583. * @param particle is the particle we are computed the direction for
  15584. */
  15585. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15586. /**
  15587. * Called by the particle System when the position is computed for the created particle.
  15588. * @param worldMatrix is the world matrix of the particle system
  15589. * @param positionToUpdate is the position vector to update with the result
  15590. * @param particle is the particle we are computed the position for
  15591. */
  15592. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15593. /**
  15594. * Clones the current emitter and returns a copy of it
  15595. * @returns the new emitter
  15596. */
  15597. clone(): IParticleEmitterType;
  15598. /**
  15599. * Called by the GPUParticleSystem to setup the update shader
  15600. * @param effect defines the update shader
  15601. */
  15602. applyToShader(effect: Effect): void;
  15603. /**
  15604. * Returns a string to use to update the GPU particles update shader
  15605. * @returns the effect defines string
  15606. */
  15607. getEffectDefines(): string;
  15608. /**
  15609. * Returns a string representing the class name
  15610. * @returns a string containing the class name
  15611. */
  15612. getClassName(): string;
  15613. /**
  15614. * Serializes the particle system to a JSON object.
  15615. * @returns the JSON object
  15616. */
  15617. serialize(): any;
  15618. /**
  15619. * Parse properties from a JSON object
  15620. * @param serializationObject defines the JSON object
  15621. */
  15622. parse(serializationObject: any): void;
  15623. }
  15624. }
  15625. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  15626. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15627. import { Effect } from "babylonjs/Materials/effect";
  15628. import { Particle } from "babylonjs/Particles/particle";
  15629. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15630. /**
  15631. * Particle emitter emitting particles from the inside of a box.
  15632. * It emits the particles randomly between 2 given directions.
  15633. */
  15634. export class BoxParticleEmitter implements IParticleEmitterType {
  15635. /**
  15636. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15637. */
  15638. direction1: Vector3;
  15639. /**
  15640. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15641. */
  15642. direction2: Vector3;
  15643. /**
  15644. * 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.
  15645. */
  15646. minEmitBox: Vector3;
  15647. /**
  15648. * 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.
  15649. */
  15650. maxEmitBox: Vector3;
  15651. /**
  15652. * Creates a new instance BoxParticleEmitter
  15653. */
  15654. constructor();
  15655. /**
  15656. * Called by the particle System when the direction is computed for the created particle.
  15657. * @param worldMatrix is the world matrix of the particle system
  15658. * @param directionToUpdate is the direction vector to update with the result
  15659. * @param particle is the particle we are computed the direction for
  15660. */
  15661. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15662. /**
  15663. * Called by the particle System when the position is computed for the created particle.
  15664. * @param worldMatrix is the world matrix of the particle system
  15665. * @param positionToUpdate is the position vector to update with the result
  15666. * @param particle is the particle we are computed the position for
  15667. */
  15668. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15669. /**
  15670. * Clones the current emitter and returns a copy of it
  15671. * @returns the new emitter
  15672. */
  15673. clone(): BoxParticleEmitter;
  15674. /**
  15675. * Called by the GPUParticleSystem to setup the update shader
  15676. * @param effect defines the update shader
  15677. */
  15678. applyToShader(effect: Effect): void;
  15679. /**
  15680. * Returns a string to use to update the GPU particles update shader
  15681. * @returns a string containng the defines string
  15682. */
  15683. getEffectDefines(): string;
  15684. /**
  15685. * Returns the string "BoxParticleEmitter"
  15686. * @returns a string containing the class name
  15687. */
  15688. getClassName(): string;
  15689. /**
  15690. * Serializes the particle system to a JSON object.
  15691. * @returns the JSON object
  15692. */
  15693. serialize(): any;
  15694. /**
  15695. * Parse properties from a JSON object
  15696. * @param serializationObject defines the JSON object
  15697. */
  15698. parse(serializationObject: any): void;
  15699. }
  15700. }
  15701. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  15702. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15703. import { Effect } from "babylonjs/Materials/effect";
  15704. import { Particle } from "babylonjs/Particles/particle";
  15705. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15706. /**
  15707. * Particle emitter emitting particles from the inside of a cone.
  15708. * It emits the particles alongside the cone volume from the base to the particle.
  15709. * The emission direction might be randomized.
  15710. */
  15711. export class ConeParticleEmitter implements IParticleEmitterType {
  15712. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  15713. directionRandomizer: number;
  15714. private _radius;
  15715. private _angle;
  15716. private _height;
  15717. /**
  15718. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  15719. */
  15720. radiusRange: number;
  15721. /**
  15722. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  15723. */
  15724. heightRange: number;
  15725. /**
  15726. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  15727. */
  15728. emitFromSpawnPointOnly: boolean;
  15729. /**
  15730. * Gets or sets the radius of the emission cone
  15731. */
  15732. radius: number;
  15733. /**
  15734. * Gets or sets the angle of the emission cone
  15735. */
  15736. angle: number;
  15737. private _buildHeight;
  15738. /**
  15739. * Creates a new instance ConeParticleEmitter
  15740. * @param radius the radius of the emission cone (1 by default)
  15741. * @param angle the cone base angle (PI by default)
  15742. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  15743. */
  15744. constructor(radius?: number, angle?: number,
  15745. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  15746. directionRandomizer?: number);
  15747. /**
  15748. * Called by the particle System when the direction is computed for the created particle.
  15749. * @param worldMatrix is the world matrix of the particle system
  15750. * @param directionToUpdate is the direction vector to update with the result
  15751. * @param particle is the particle we are computed the direction for
  15752. */
  15753. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15754. /**
  15755. * Called by the particle System when the position is computed for the created particle.
  15756. * @param worldMatrix is the world matrix of the particle system
  15757. * @param positionToUpdate is the position vector to update with the result
  15758. * @param particle is the particle we are computed the position for
  15759. */
  15760. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15761. /**
  15762. * Clones the current emitter and returns a copy of it
  15763. * @returns the new emitter
  15764. */
  15765. clone(): ConeParticleEmitter;
  15766. /**
  15767. * Called by the GPUParticleSystem to setup the update shader
  15768. * @param effect defines the update shader
  15769. */
  15770. applyToShader(effect: Effect): void;
  15771. /**
  15772. * Returns a string to use to update the GPU particles update shader
  15773. * @returns a string containng the defines string
  15774. */
  15775. getEffectDefines(): string;
  15776. /**
  15777. * Returns the string "ConeParticleEmitter"
  15778. * @returns a string containing the class name
  15779. */
  15780. getClassName(): string;
  15781. /**
  15782. * Serializes the particle system to a JSON object.
  15783. * @returns the JSON object
  15784. */
  15785. serialize(): any;
  15786. /**
  15787. * Parse properties from a JSON object
  15788. * @param serializationObject defines the JSON object
  15789. */
  15790. parse(serializationObject: any): void;
  15791. }
  15792. }
  15793. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  15794. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15795. import { Effect } from "babylonjs/Materials/effect";
  15796. import { Particle } from "babylonjs/Particles/particle";
  15797. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15798. /**
  15799. * Particle emitter emitting particles from the inside of a cylinder.
  15800. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  15801. */
  15802. export class CylinderParticleEmitter implements IParticleEmitterType {
  15803. /**
  15804. * The radius of the emission cylinder.
  15805. */
  15806. radius: number;
  15807. /**
  15808. * The height of the emission cylinder.
  15809. */
  15810. height: number;
  15811. /**
  15812. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15813. */
  15814. radiusRange: number;
  15815. /**
  15816. * How much to randomize the particle direction [0-1].
  15817. */
  15818. directionRandomizer: number;
  15819. /**
  15820. * Creates a new instance CylinderParticleEmitter
  15821. * @param radius the radius of the emission cylinder (1 by default)
  15822. * @param height the height of the emission cylinder (1 by default)
  15823. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15824. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  15825. */
  15826. constructor(
  15827. /**
  15828. * The radius of the emission cylinder.
  15829. */
  15830. radius?: number,
  15831. /**
  15832. * The height of the emission cylinder.
  15833. */
  15834. height?: number,
  15835. /**
  15836. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15837. */
  15838. radiusRange?: number,
  15839. /**
  15840. * How much to randomize the particle direction [0-1].
  15841. */
  15842. directionRandomizer?: number);
  15843. /**
  15844. * Called by the particle System when the direction is computed for the created particle.
  15845. * @param worldMatrix is the world matrix of the particle system
  15846. * @param directionToUpdate is the direction vector to update with the result
  15847. * @param particle is the particle we are computed the direction for
  15848. */
  15849. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15850. /**
  15851. * Called by the particle System when the position is computed for the created particle.
  15852. * @param worldMatrix is the world matrix of the particle system
  15853. * @param positionToUpdate is the position vector to update with the result
  15854. * @param particle is the particle we are computed the position for
  15855. */
  15856. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15857. /**
  15858. * Clones the current emitter and returns a copy of it
  15859. * @returns the new emitter
  15860. */
  15861. clone(): CylinderParticleEmitter;
  15862. /**
  15863. * Called by the GPUParticleSystem to setup the update shader
  15864. * @param effect defines the update shader
  15865. */
  15866. applyToShader(effect: Effect): void;
  15867. /**
  15868. * Returns a string to use to update the GPU particles update shader
  15869. * @returns a string containng the defines string
  15870. */
  15871. getEffectDefines(): string;
  15872. /**
  15873. * Returns the string "CylinderParticleEmitter"
  15874. * @returns a string containing the class name
  15875. */
  15876. getClassName(): string;
  15877. /**
  15878. * Serializes the particle system to a JSON object.
  15879. * @returns the JSON object
  15880. */
  15881. serialize(): any;
  15882. /**
  15883. * Parse properties from a JSON object
  15884. * @param serializationObject defines the JSON object
  15885. */
  15886. parse(serializationObject: any): void;
  15887. }
  15888. /**
  15889. * Particle emitter emitting particles from the inside of a cylinder.
  15890. * It emits the particles randomly between two vectors.
  15891. */
  15892. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  15893. /**
  15894. * The min limit of the emission direction.
  15895. */
  15896. direction1: Vector3;
  15897. /**
  15898. * The max limit of the emission direction.
  15899. */
  15900. direction2: Vector3;
  15901. /**
  15902. * Creates a new instance CylinderDirectedParticleEmitter
  15903. * @param radius the radius of the emission cylinder (1 by default)
  15904. * @param height the height of the emission cylinder (1 by default)
  15905. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15906. * @param direction1 the min limit of the emission direction (up vector by default)
  15907. * @param direction2 the max limit of the emission direction (up vector by default)
  15908. */
  15909. constructor(radius?: number, height?: number, radiusRange?: number,
  15910. /**
  15911. * The min limit of the emission direction.
  15912. */
  15913. direction1?: Vector3,
  15914. /**
  15915. * The max limit of the emission direction.
  15916. */
  15917. direction2?: Vector3);
  15918. /**
  15919. * Called by the particle System when the direction is computed for the created particle.
  15920. * @param worldMatrix is the world matrix of the particle system
  15921. * @param directionToUpdate is the direction vector to update with the result
  15922. * @param particle is the particle we are computed the direction for
  15923. */
  15924. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15925. /**
  15926. * Clones the current emitter and returns a copy of it
  15927. * @returns the new emitter
  15928. */
  15929. clone(): CylinderDirectedParticleEmitter;
  15930. /**
  15931. * Called by the GPUParticleSystem to setup the update shader
  15932. * @param effect defines the update shader
  15933. */
  15934. applyToShader(effect: Effect): void;
  15935. /**
  15936. * Returns a string to use to update the GPU particles update shader
  15937. * @returns a string containng the defines string
  15938. */
  15939. getEffectDefines(): string;
  15940. /**
  15941. * Returns the string "CylinderDirectedParticleEmitter"
  15942. * @returns a string containing the class name
  15943. */
  15944. getClassName(): string;
  15945. /**
  15946. * Serializes the particle system to a JSON object.
  15947. * @returns the JSON object
  15948. */
  15949. serialize(): any;
  15950. /**
  15951. * Parse properties from a JSON object
  15952. * @param serializationObject defines the JSON object
  15953. */
  15954. parse(serializationObject: any): void;
  15955. }
  15956. }
  15957. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  15958. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15959. import { Effect } from "babylonjs/Materials/effect";
  15960. import { Particle } from "babylonjs/Particles/particle";
  15961. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15962. /**
  15963. * Particle emitter emitting particles from the inside of a hemisphere.
  15964. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  15965. */
  15966. export class HemisphericParticleEmitter implements IParticleEmitterType {
  15967. /**
  15968. * The radius of the emission hemisphere.
  15969. */
  15970. radius: number;
  15971. /**
  15972. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15973. */
  15974. radiusRange: number;
  15975. /**
  15976. * How much to randomize the particle direction [0-1].
  15977. */
  15978. directionRandomizer: number;
  15979. /**
  15980. * Creates a new instance HemisphericParticleEmitter
  15981. * @param radius the radius of the emission hemisphere (1 by default)
  15982. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15983. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  15984. */
  15985. constructor(
  15986. /**
  15987. * The radius of the emission hemisphere.
  15988. */
  15989. radius?: number,
  15990. /**
  15991. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15992. */
  15993. radiusRange?: number,
  15994. /**
  15995. * How much to randomize the particle direction [0-1].
  15996. */
  15997. directionRandomizer?: number);
  15998. /**
  15999. * Called by the particle System when the direction is computed for the created particle.
  16000. * @param worldMatrix is the world matrix of the particle system
  16001. * @param directionToUpdate is the direction vector to update with the result
  16002. * @param particle is the particle we are computed the direction for
  16003. */
  16004. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16005. /**
  16006. * Called by the particle System when the position is computed for the created particle.
  16007. * @param worldMatrix is the world matrix of the particle system
  16008. * @param positionToUpdate is the position vector to update with the result
  16009. * @param particle is the particle we are computed the position for
  16010. */
  16011. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  16012. /**
  16013. * Clones the current emitter and returns a copy of it
  16014. * @returns the new emitter
  16015. */
  16016. clone(): HemisphericParticleEmitter;
  16017. /**
  16018. * Called by the GPUParticleSystem to setup the update shader
  16019. * @param effect defines the update shader
  16020. */
  16021. applyToShader(effect: Effect): void;
  16022. /**
  16023. * Returns a string to use to update the GPU particles update shader
  16024. * @returns a string containng the defines string
  16025. */
  16026. getEffectDefines(): string;
  16027. /**
  16028. * Returns the string "HemisphericParticleEmitter"
  16029. * @returns a string containing the class name
  16030. */
  16031. getClassName(): string;
  16032. /**
  16033. * Serializes the particle system to a JSON object.
  16034. * @returns the JSON object
  16035. */
  16036. serialize(): any;
  16037. /**
  16038. * Parse properties from a JSON object
  16039. * @param serializationObject defines the JSON object
  16040. */
  16041. parse(serializationObject: any): void;
  16042. }
  16043. }
  16044. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  16045. import { Vector3, Matrix } from "babylonjs/Maths/math";
  16046. import { Effect } from "babylonjs/Materials/effect";
  16047. import { Particle } from "babylonjs/Particles/particle";
  16048. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  16049. /**
  16050. * Particle emitter emitting particles from a point.
  16051. * It emits the particles randomly between 2 given directions.
  16052. */
  16053. export class PointParticleEmitter implements IParticleEmitterType {
  16054. /**
  16055. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16056. */
  16057. direction1: Vector3;
  16058. /**
  16059. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16060. */
  16061. direction2: Vector3;
  16062. /**
  16063. * Creates a new instance PointParticleEmitter
  16064. */
  16065. constructor();
  16066. /**
  16067. * Called by the particle System when the direction is computed for the created particle.
  16068. * @param worldMatrix is the world matrix of the particle system
  16069. * @param directionToUpdate is the direction vector to update with the result
  16070. * @param particle is the particle we are computed the direction for
  16071. */
  16072. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16073. /**
  16074. * Called by the particle System when the position is computed for the created particle.
  16075. * @param worldMatrix is the world matrix of the particle system
  16076. * @param positionToUpdate is the position vector to update with the result
  16077. * @param particle is the particle we are computed the position for
  16078. */
  16079. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  16080. /**
  16081. * Clones the current emitter and returns a copy of it
  16082. * @returns the new emitter
  16083. */
  16084. clone(): PointParticleEmitter;
  16085. /**
  16086. * Called by the GPUParticleSystem to setup the update shader
  16087. * @param effect defines the update shader
  16088. */
  16089. applyToShader(effect: Effect): void;
  16090. /**
  16091. * Returns a string to use to update the GPU particles update shader
  16092. * @returns a string containng the defines string
  16093. */
  16094. getEffectDefines(): string;
  16095. /**
  16096. * Returns the string "PointParticleEmitter"
  16097. * @returns a string containing the class name
  16098. */
  16099. getClassName(): string;
  16100. /**
  16101. * Serializes the particle system to a JSON object.
  16102. * @returns the JSON object
  16103. */
  16104. serialize(): any;
  16105. /**
  16106. * Parse properties from a JSON object
  16107. * @param serializationObject defines the JSON object
  16108. */
  16109. parse(serializationObject: any): void;
  16110. }
  16111. }
  16112. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  16113. import { Vector3, Matrix } from "babylonjs/Maths/math";
  16114. import { Effect } from "babylonjs/Materials/effect";
  16115. import { Particle } from "babylonjs/Particles/particle";
  16116. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  16117. /**
  16118. * Particle emitter emitting particles from the inside of a sphere.
  16119. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  16120. */
  16121. export class SphereParticleEmitter implements IParticleEmitterType {
  16122. /**
  16123. * The radius of the emission sphere.
  16124. */
  16125. radius: number;
  16126. /**
  16127. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16128. */
  16129. radiusRange: number;
  16130. /**
  16131. * How much to randomize the particle direction [0-1].
  16132. */
  16133. directionRandomizer: number;
  16134. /**
  16135. * Creates a new instance SphereParticleEmitter
  16136. * @param radius the radius of the emission sphere (1 by default)
  16137. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16138. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  16139. */
  16140. constructor(
  16141. /**
  16142. * The radius of the emission sphere.
  16143. */
  16144. radius?: number,
  16145. /**
  16146. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16147. */
  16148. radiusRange?: number,
  16149. /**
  16150. * How much to randomize the particle direction [0-1].
  16151. */
  16152. directionRandomizer?: number);
  16153. /**
  16154. * Called by the particle System when the direction is computed for the created particle.
  16155. * @param worldMatrix is the world matrix of the particle system
  16156. * @param directionToUpdate is the direction vector to update with the result
  16157. * @param particle is the particle we are computed the direction for
  16158. */
  16159. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16160. /**
  16161. * Called by the particle System when the position is computed for the created particle.
  16162. * @param worldMatrix is the world matrix of the particle system
  16163. * @param positionToUpdate is the position vector to update with the result
  16164. * @param particle is the particle we are computed the position for
  16165. */
  16166. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  16167. /**
  16168. * Clones the current emitter and returns a copy of it
  16169. * @returns the new emitter
  16170. */
  16171. clone(): SphereParticleEmitter;
  16172. /**
  16173. * Called by the GPUParticleSystem to setup the update shader
  16174. * @param effect defines the update shader
  16175. */
  16176. applyToShader(effect: Effect): void;
  16177. /**
  16178. * Returns a string to use to update the GPU particles update shader
  16179. * @returns a string containng the defines string
  16180. */
  16181. getEffectDefines(): string;
  16182. /**
  16183. * Returns the string "SphereParticleEmitter"
  16184. * @returns a string containing the class name
  16185. */
  16186. getClassName(): string;
  16187. /**
  16188. * Serializes the particle system to a JSON object.
  16189. * @returns the JSON object
  16190. */
  16191. serialize(): any;
  16192. /**
  16193. * Parse properties from a JSON object
  16194. * @param serializationObject defines the JSON object
  16195. */
  16196. parse(serializationObject: any): void;
  16197. }
  16198. /**
  16199. * Particle emitter emitting particles from the inside of a sphere.
  16200. * It emits the particles randomly between two vectors.
  16201. */
  16202. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  16203. /**
  16204. * The min limit of the emission direction.
  16205. */
  16206. direction1: Vector3;
  16207. /**
  16208. * The max limit of the emission direction.
  16209. */
  16210. direction2: Vector3;
  16211. /**
  16212. * Creates a new instance SphereDirectedParticleEmitter
  16213. * @param radius the radius of the emission sphere (1 by default)
  16214. * @param direction1 the min limit of the emission direction (up vector by default)
  16215. * @param direction2 the max limit of the emission direction (up vector by default)
  16216. */
  16217. constructor(radius?: number,
  16218. /**
  16219. * The min limit of the emission direction.
  16220. */
  16221. direction1?: Vector3,
  16222. /**
  16223. * The max limit of the emission direction.
  16224. */
  16225. direction2?: Vector3);
  16226. /**
  16227. * Called by the particle System when the direction is computed for the created particle.
  16228. * @param worldMatrix is the world matrix of the particle system
  16229. * @param directionToUpdate is the direction vector to update with the result
  16230. * @param particle is the particle we are computed the direction for
  16231. */
  16232. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16233. /**
  16234. * Clones the current emitter and returns a copy of it
  16235. * @returns the new emitter
  16236. */
  16237. clone(): SphereDirectedParticleEmitter;
  16238. /**
  16239. * Called by the GPUParticleSystem to setup the update shader
  16240. * @param effect defines the update shader
  16241. */
  16242. applyToShader(effect: Effect): void;
  16243. /**
  16244. * Returns a string to use to update the GPU particles update shader
  16245. * @returns a string containng the defines string
  16246. */
  16247. getEffectDefines(): string;
  16248. /**
  16249. * Returns the string "SphereDirectedParticleEmitter"
  16250. * @returns a string containing the class name
  16251. */
  16252. getClassName(): string;
  16253. /**
  16254. * Serializes the particle system to a JSON object.
  16255. * @returns the JSON object
  16256. */
  16257. serialize(): any;
  16258. /**
  16259. * Parse properties from a JSON object
  16260. * @param serializationObject defines the JSON object
  16261. */
  16262. parse(serializationObject: any): void;
  16263. }
  16264. }
  16265. declare module "babylonjs/Particles/EmitterTypes/index" {
  16266. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  16267. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  16268. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  16269. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  16270. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  16271. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  16272. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  16273. }
  16274. declare module "babylonjs/Particles/IParticleSystem" {
  16275. import { Nullable } from "babylonjs/types";
  16276. import { Color4, Color3, Vector2, Vector3 } from "babylonjs/Maths/math";
  16277. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16278. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  16279. import { Texture } from "babylonjs/Materials/Textures/texture";
  16280. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  16281. import { Scene } from "babylonjs/scene";
  16282. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/tools";
  16283. import { Animation } from "babylonjs/Animations/animation";
  16284. /**
  16285. * Interface representing a particle system in Babylon.js.
  16286. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  16287. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  16288. */
  16289. export interface IParticleSystem {
  16290. /**
  16291. * List of animations used by the particle system.
  16292. */
  16293. animations: Animation[];
  16294. /**
  16295. * The id of the Particle system.
  16296. */
  16297. id: string;
  16298. /**
  16299. * The name of the Particle system.
  16300. */
  16301. name: string;
  16302. /**
  16303. * The emitter represents the Mesh or position we are attaching the particle system to.
  16304. */
  16305. emitter: Nullable<AbstractMesh | Vector3>;
  16306. /**
  16307. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  16308. */
  16309. isBillboardBased: boolean;
  16310. /**
  16311. * The rendering group used by the Particle system to chose when to render.
  16312. */
  16313. renderingGroupId: number;
  16314. /**
  16315. * The layer mask we are rendering the particles through.
  16316. */
  16317. layerMask: number;
  16318. /**
  16319. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  16320. */
  16321. updateSpeed: number;
  16322. /**
  16323. * The amount of time the particle system is running (depends of the overall update speed).
  16324. */
  16325. targetStopDuration: number;
  16326. /**
  16327. * The texture used to render each particle. (this can be a spritesheet)
  16328. */
  16329. particleTexture: Nullable<Texture>;
  16330. /**
  16331. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  16332. */
  16333. blendMode: number;
  16334. /**
  16335. * Minimum life time of emitting particles.
  16336. */
  16337. minLifeTime: number;
  16338. /**
  16339. * Maximum life time of emitting particles.
  16340. */
  16341. maxLifeTime: number;
  16342. /**
  16343. * Minimum Size of emitting particles.
  16344. */
  16345. minSize: number;
  16346. /**
  16347. * Maximum Size of emitting particles.
  16348. */
  16349. maxSize: number;
  16350. /**
  16351. * Minimum scale of emitting particles on X axis.
  16352. */
  16353. minScaleX: number;
  16354. /**
  16355. * Maximum scale of emitting particles on X axis.
  16356. */
  16357. maxScaleX: number;
  16358. /**
  16359. * Minimum scale of emitting particles on Y axis.
  16360. */
  16361. minScaleY: number;
  16362. /**
  16363. * Maximum scale of emitting particles on Y axis.
  16364. */
  16365. maxScaleY: number;
  16366. /**
  16367. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  16368. */
  16369. color1: Color4;
  16370. /**
  16371. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  16372. */
  16373. color2: Color4;
  16374. /**
  16375. * Color the particle will have at the end of its lifetime.
  16376. */
  16377. colorDead: Color4;
  16378. /**
  16379. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  16380. */
  16381. emitRate: number;
  16382. /**
  16383. * You can use gravity if you want to give an orientation to your particles.
  16384. */
  16385. gravity: Vector3;
  16386. /**
  16387. * Minimum power of emitting particles.
  16388. */
  16389. minEmitPower: number;
  16390. /**
  16391. * Maximum power of emitting particles.
  16392. */
  16393. maxEmitPower: number;
  16394. /**
  16395. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  16396. */
  16397. minAngularSpeed: number;
  16398. /**
  16399. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  16400. */
  16401. maxAngularSpeed: number;
  16402. /**
  16403. * Gets or sets the minimal initial rotation in radians.
  16404. */
  16405. minInitialRotation: number;
  16406. /**
  16407. * Gets or sets the maximal initial rotation in radians.
  16408. */
  16409. maxInitialRotation: number;
  16410. /**
  16411. * The particle emitter type defines the emitter used by the particle system.
  16412. * It can be for example box, sphere, or cone...
  16413. */
  16414. particleEmitterType: Nullable<IParticleEmitterType>;
  16415. /**
  16416. * Defines the delay in milliseconds before starting the system (0 by default)
  16417. */
  16418. startDelay: number;
  16419. /**
  16420. * 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
  16421. */
  16422. preWarmCycles: number;
  16423. /**
  16424. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  16425. */
  16426. preWarmStepOffset: number;
  16427. /**
  16428. * 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)
  16429. */
  16430. spriteCellChangeSpeed: number;
  16431. /**
  16432. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  16433. */
  16434. startSpriteCellID: number;
  16435. /**
  16436. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  16437. */
  16438. endSpriteCellID: number;
  16439. /**
  16440. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  16441. */
  16442. spriteCellWidth: number;
  16443. /**
  16444. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  16445. */
  16446. spriteCellHeight: number;
  16447. /**
  16448. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  16449. */
  16450. spriteRandomStartCell: boolean;
  16451. /**
  16452. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  16453. */
  16454. isAnimationSheetEnabled: boolean;
  16455. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  16456. translationPivot: Vector2;
  16457. /**
  16458. * Gets or sets a texture used to add random noise to particle positions
  16459. */
  16460. noiseTexture: Nullable<BaseTexture>;
  16461. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  16462. noiseStrength: Vector3;
  16463. /**
  16464. * Gets or sets the billboard mode to use when isBillboardBased = true.
  16465. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  16466. */
  16467. billboardMode: number;
  16468. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  16469. limitVelocityDamping: number;
  16470. /**
  16471. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  16472. */
  16473. beginAnimationOnStart: boolean;
  16474. /**
  16475. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  16476. */
  16477. beginAnimationFrom: number;
  16478. /**
  16479. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  16480. */
  16481. beginAnimationTo: number;
  16482. /**
  16483. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  16484. */
  16485. beginAnimationLoop: boolean;
  16486. /**
  16487. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  16488. */
  16489. disposeOnStop: boolean;
  16490. /**
  16491. * Gets the maximum number of particles active at the same time.
  16492. * @returns The max number of active particles.
  16493. */
  16494. getCapacity(): number;
  16495. /**
  16496. * Gets if the system has been started. (Note: this will still be true after stop is called)
  16497. * @returns True if it has been started, otherwise false.
  16498. */
  16499. isStarted(): boolean;
  16500. /**
  16501. * Animates the particle system for this frame.
  16502. */
  16503. animate(): void;
  16504. /**
  16505. * Renders the particle system in its current state.
  16506. * @returns the current number of particles
  16507. */
  16508. render(): number;
  16509. /**
  16510. * Dispose the particle system and frees its associated resources.
  16511. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  16512. */
  16513. dispose(disposeTexture?: boolean): void;
  16514. /**
  16515. * Clones the particle system.
  16516. * @param name The name of the cloned object
  16517. * @param newEmitter The new emitter to use
  16518. * @returns the cloned particle system
  16519. */
  16520. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  16521. /**
  16522. * Serializes the particle system to a JSON object.
  16523. * @returns the JSON object
  16524. */
  16525. serialize(): any;
  16526. /**
  16527. * Rebuild the particle system
  16528. */
  16529. rebuild(): void;
  16530. /**
  16531. * Starts the particle system and begins to emit
  16532. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  16533. */
  16534. start(delay?: number): void;
  16535. /**
  16536. * Stops the particle system.
  16537. */
  16538. stop(): void;
  16539. /**
  16540. * Remove all active particles
  16541. */
  16542. reset(): void;
  16543. /**
  16544. * Is this system ready to be used/rendered
  16545. * @return true if the system is ready
  16546. */
  16547. isReady(): boolean;
  16548. /**
  16549. * Adds a new color gradient
  16550. * @param gradient defines the gradient to use (between 0 and 1)
  16551. * @param color1 defines the color to affect to the specified gradient
  16552. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  16553. * @returns the current particle system
  16554. */
  16555. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  16556. /**
  16557. * Remove a specific color gradient
  16558. * @param gradient defines the gradient to remove
  16559. * @returns the current particle system
  16560. */
  16561. removeColorGradient(gradient: number): IParticleSystem;
  16562. /**
  16563. * Adds a new size gradient
  16564. * @param gradient defines the gradient to use (between 0 and 1)
  16565. * @param factor defines the size factor to affect to the specified gradient
  16566. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16567. * @returns the current particle system
  16568. */
  16569. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16570. /**
  16571. * Remove a specific size gradient
  16572. * @param gradient defines the gradient to remove
  16573. * @returns the current particle system
  16574. */
  16575. removeSizeGradient(gradient: number): IParticleSystem;
  16576. /**
  16577. * Gets the current list of color gradients.
  16578. * You must use addColorGradient and removeColorGradient to udpate this list
  16579. * @returns the list of color gradients
  16580. */
  16581. getColorGradients(): Nullable<Array<ColorGradient>>;
  16582. /**
  16583. * Gets the current list of size gradients.
  16584. * You must use addSizeGradient and removeSizeGradient to udpate this list
  16585. * @returns the list of size gradients
  16586. */
  16587. getSizeGradients(): Nullable<Array<FactorGradient>>;
  16588. /**
  16589. * Gets the current list of angular speed gradients.
  16590. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  16591. * @returns the list of angular speed gradients
  16592. */
  16593. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  16594. /**
  16595. * Adds a new angular speed gradient
  16596. * @param gradient defines the gradient to use (between 0 and 1)
  16597. * @param factor defines the angular speed to affect to the specified gradient
  16598. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16599. * @returns the current particle system
  16600. */
  16601. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16602. /**
  16603. * Remove a specific angular speed gradient
  16604. * @param gradient defines the gradient to remove
  16605. * @returns the current particle system
  16606. */
  16607. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  16608. /**
  16609. * Gets the current list of velocity gradients.
  16610. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  16611. * @returns the list of velocity gradients
  16612. */
  16613. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  16614. /**
  16615. * Adds a new velocity gradient
  16616. * @param gradient defines the gradient to use (between 0 and 1)
  16617. * @param factor defines the velocity to affect to the specified gradient
  16618. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16619. * @returns the current particle system
  16620. */
  16621. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16622. /**
  16623. * Remove a specific velocity gradient
  16624. * @param gradient defines the gradient to remove
  16625. * @returns the current particle system
  16626. */
  16627. removeVelocityGradient(gradient: number): IParticleSystem;
  16628. /**
  16629. * Gets the current list of limit velocity gradients.
  16630. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  16631. * @returns the list of limit velocity gradients
  16632. */
  16633. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  16634. /**
  16635. * Adds a new limit velocity gradient
  16636. * @param gradient defines the gradient to use (between 0 and 1)
  16637. * @param factor defines the limit velocity to affect to the specified gradient
  16638. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16639. * @returns the current particle system
  16640. */
  16641. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16642. /**
  16643. * Remove a specific limit velocity gradient
  16644. * @param gradient defines the gradient to remove
  16645. * @returns the current particle system
  16646. */
  16647. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  16648. /**
  16649. * Adds a new drag gradient
  16650. * @param gradient defines the gradient to use (between 0 and 1)
  16651. * @param factor defines the drag to affect to the specified gradient
  16652. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16653. * @returns the current particle system
  16654. */
  16655. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16656. /**
  16657. * Remove a specific drag gradient
  16658. * @param gradient defines the gradient to remove
  16659. * @returns the current particle system
  16660. */
  16661. removeDragGradient(gradient: number): IParticleSystem;
  16662. /**
  16663. * Gets the current list of drag gradients.
  16664. * You must use addDragGradient and removeDragGradient to udpate this list
  16665. * @returns the list of drag gradients
  16666. */
  16667. getDragGradients(): Nullable<Array<FactorGradient>>;
  16668. /**
  16669. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  16670. * @param gradient defines the gradient to use (between 0 and 1)
  16671. * @param factor defines the emit rate to affect to the specified gradient
  16672. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16673. * @returns the current particle system
  16674. */
  16675. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16676. /**
  16677. * Remove a specific emit rate gradient
  16678. * @param gradient defines the gradient to remove
  16679. * @returns the current particle system
  16680. */
  16681. removeEmitRateGradient(gradient: number): IParticleSystem;
  16682. /**
  16683. * Gets the current list of emit rate gradients.
  16684. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  16685. * @returns the list of emit rate gradients
  16686. */
  16687. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  16688. /**
  16689. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  16690. * @param gradient defines the gradient to use (between 0 and 1)
  16691. * @param factor defines the start size to affect to the specified gradient
  16692. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16693. * @returns the current particle system
  16694. */
  16695. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16696. /**
  16697. * Remove a specific start size gradient
  16698. * @param gradient defines the gradient to remove
  16699. * @returns the current particle system
  16700. */
  16701. removeStartSizeGradient(gradient: number): IParticleSystem;
  16702. /**
  16703. * Gets the current list of start size gradients.
  16704. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  16705. * @returns the list of start size gradients
  16706. */
  16707. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  16708. /**
  16709. * Adds a new life time gradient
  16710. * @param gradient defines the gradient to use (between 0 and 1)
  16711. * @param factor defines the life time factor to affect to the specified gradient
  16712. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16713. * @returns the current particle system
  16714. */
  16715. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16716. /**
  16717. * Remove a specific life time gradient
  16718. * @param gradient defines the gradient to remove
  16719. * @returns the current particle system
  16720. */
  16721. removeLifeTimeGradient(gradient: number): IParticleSystem;
  16722. /**
  16723. * Gets the current list of life time gradients.
  16724. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  16725. * @returns the list of life time gradients
  16726. */
  16727. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  16728. /**
  16729. * Gets the current list of color gradients.
  16730. * You must use addColorGradient and removeColorGradient to udpate this list
  16731. * @returns the list of color gradients
  16732. */
  16733. getColorGradients(): Nullable<Array<ColorGradient>>;
  16734. /**
  16735. * Adds a new ramp gradient used to remap particle colors
  16736. * @param gradient defines the gradient to use (between 0 and 1)
  16737. * @param color defines the color to affect to the specified gradient
  16738. * @returns the current particle system
  16739. */
  16740. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  16741. /**
  16742. * Gets the current list of ramp gradients.
  16743. * You must use addRampGradient and removeRampGradient to udpate this list
  16744. * @returns the list of ramp gradients
  16745. */
  16746. getRampGradients(): Nullable<Array<Color3Gradient>>;
  16747. /** Gets or sets a boolean indicating that ramp gradients must be used
  16748. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  16749. */
  16750. useRampGradients: boolean;
  16751. /**
  16752. * Adds a new color remap gradient
  16753. * @param gradient defines the gradient to use (between 0 and 1)
  16754. * @param min defines the color remap minimal range
  16755. * @param max defines the color remap maximal range
  16756. * @returns the current particle system
  16757. */
  16758. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  16759. /**
  16760. * Gets the current list of color remap gradients.
  16761. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  16762. * @returns the list of color remap gradients
  16763. */
  16764. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  16765. /**
  16766. * Adds a new alpha remap gradient
  16767. * @param gradient defines the gradient to use (between 0 and 1)
  16768. * @param min defines the alpha remap minimal range
  16769. * @param max defines the alpha remap maximal range
  16770. * @returns the current particle system
  16771. */
  16772. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  16773. /**
  16774. * Gets the current list of alpha remap gradients.
  16775. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  16776. * @returns the list of alpha remap gradients
  16777. */
  16778. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  16779. /**
  16780. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  16781. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16782. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16783. * @returns the emitter
  16784. */
  16785. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  16786. /**
  16787. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  16788. * @param radius The radius of the hemisphere to emit from
  16789. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16790. * @returns the emitter
  16791. */
  16792. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  16793. /**
  16794. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  16795. * @param radius The radius of the sphere to emit from
  16796. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16797. * @returns the emitter
  16798. */
  16799. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  16800. /**
  16801. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  16802. * @param radius The radius of the sphere to emit from
  16803. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  16804. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  16805. * @returns the emitter
  16806. */
  16807. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  16808. /**
  16809. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  16810. * @param radius The radius of the emission cylinder
  16811. * @param height The height of the emission cylinder
  16812. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  16813. * @param directionRandomizer How much to randomize the particle direction [0-1]
  16814. * @returns the emitter
  16815. */
  16816. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  16817. /**
  16818. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  16819. * @param radius The radius of the cylinder to emit from
  16820. * @param height The height of the emission cylinder
  16821. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16822. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  16823. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  16824. * @returns the emitter
  16825. */
  16826. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  16827. /**
  16828. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  16829. * @param radius The radius of the cone to emit from
  16830. * @param angle The base angle of the cone
  16831. * @returns the emitter
  16832. */
  16833. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  16834. /**
  16835. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  16836. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16837. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16838. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16839. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16840. * @returns the emitter
  16841. */
  16842. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  16843. /**
  16844. * Get hosting scene
  16845. * @returns the scene
  16846. */
  16847. getScene(): Scene;
  16848. }
  16849. }
  16850. declare module "babylonjs/Meshes/instancedMesh" {
  16851. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  16852. import { Vector3 } from "babylonjs/Maths/math";
  16853. import { Camera } from "babylonjs/Cameras/camera";
  16854. import { Node } from "babylonjs/node";
  16855. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16856. import { Mesh } from "babylonjs/Meshes/mesh";
  16857. import { Material } from "babylonjs/Materials/material";
  16858. import { Skeleton } from "babylonjs/Bones/skeleton";
  16859. /**
  16860. * Creates an instance based on a source mesh.
  16861. */
  16862. export class InstancedMesh extends AbstractMesh {
  16863. private _sourceMesh;
  16864. private _currentLOD;
  16865. /** @hidden */
  16866. _indexInSourceMeshInstanceArray: number;
  16867. constructor(name: string, source: Mesh);
  16868. /**
  16869. * Returns the string "InstancedMesh".
  16870. */
  16871. getClassName(): string;
  16872. /**
  16873. * If the source mesh receives shadows
  16874. */
  16875. readonly receiveShadows: boolean;
  16876. /**
  16877. * The material of the source mesh
  16878. */
  16879. readonly material: Nullable<Material>;
  16880. /**
  16881. * Visibility of the source mesh
  16882. */
  16883. readonly visibility: number;
  16884. /**
  16885. * Skeleton of the source mesh
  16886. */
  16887. readonly skeleton: Nullable<Skeleton>;
  16888. /**
  16889. * Rendering ground id of the source mesh
  16890. */
  16891. renderingGroupId: number;
  16892. /**
  16893. * Returns the total number of vertices (integer).
  16894. */
  16895. getTotalVertices(): number;
  16896. /**
  16897. * Returns a positive integer : the total number of indices in this mesh geometry.
  16898. * @returns the numner of indices or zero if the mesh has no geometry.
  16899. */
  16900. getTotalIndices(): number;
  16901. /**
  16902. * The source mesh of the instance
  16903. */
  16904. readonly sourceMesh: Mesh;
  16905. /**
  16906. * Is this node ready to be used/rendered
  16907. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  16908. * @return {boolean} is it ready
  16909. */
  16910. isReady(completeCheck?: boolean): boolean;
  16911. /**
  16912. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  16913. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  16914. * @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.
  16915. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  16916. */
  16917. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  16918. /**
  16919. * Sets the vertex data of the mesh geometry for the requested `kind`.
  16920. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  16921. * The `data` are either a numeric array either a Float32Array.
  16922. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  16923. * 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).
  16924. * Note that a new underlying VertexBuffer object is created each call.
  16925. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  16926. *
  16927. * Possible `kind` values :
  16928. * - VertexBuffer.PositionKind
  16929. * - VertexBuffer.UVKind
  16930. * - VertexBuffer.UV2Kind
  16931. * - VertexBuffer.UV3Kind
  16932. * - VertexBuffer.UV4Kind
  16933. * - VertexBuffer.UV5Kind
  16934. * - VertexBuffer.UV6Kind
  16935. * - VertexBuffer.ColorKind
  16936. * - VertexBuffer.MatricesIndicesKind
  16937. * - VertexBuffer.MatricesIndicesExtraKind
  16938. * - VertexBuffer.MatricesWeightsKind
  16939. * - VertexBuffer.MatricesWeightsExtraKind
  16940. *
  16941. * Returns the Mesh.
  16942. */
  16943. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  16944. /**
  16945. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  16946. * If the mesh has no geometry, it is simply returned as it is.
  16947. * The `data` are either a numeric array either a Float32Array.
  16948. * No new underlying VertexBuffer object is created.
  16949. * 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.
  16950. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  16951. *
  16952. * Possible `kind` values :
  16953. * - VertexBuffer.PositionKind
  16954. * - VertexBuffer.UVKind
  16955. * - VertexBuffer.UV2Kind
  16956. * - VertexBuffer.UV3Kind
  16957. * - VertexBuffer.UV4Kind
  16958. * - VertexBuffer.UV5Kind
  16959. * - VertexBuffer.UV6Kind
  16960. * - VertexBuffer.ColorKind
  16961. * - VertexBuffer.MatricesIndicesKind
  16962. * - VertexBuffer.MatricesIndicesExtraKind
  16963. * - VertexBuffer.MatricesWeightsKind
  16964. * - VertexBuffer.MatricesWeightsExtraKind
  16965. *
  16966. * Returns the Mesh.
  16967. */
  16968. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  16969. /**
  16970. * Sets the mesh indices.
  16971. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  16972. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  16973. * This method creates a new index buffer each call.
  16974. * Returns the Mesh.
  16975. */
  16976. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  16977. /**
  16978. * Boolean : True if the mesh owns the requested kind of data.
  16979. */
  16980. isVerticesDataPresent(kind: string): boolean;
  16981. /**
  16982. * Returns an array of indices (IndicesArray).
  16983. */
  16984. getIndices(): Nullable<IndicesArray>;
  16985. readonly _positions: Nullable<Vector3[]>;
  16986. /**
  16987. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  16988. * This means the mesh underlying bounding box and sphere are recomputed.
  16989. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  16990. * @returns the current mesh
  16991. */
  16992. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  16993. /** @hidden */
  16994. _preActivate(): InstancedMesh;
  16995. /** @hidden */
  16996. _activate(renderId: number): InstancedMesh;
  16997. /**
  16998. * Returns the current associated LOD AbstractMesh.
  16999. */
  17000. getLOD(camera: Camera): AbstractMesh;
  17001. /** @hidden */
  17002. _syncSubMeshes(): InstancedMesh;
  17003. /** @hidden */
  17004. _generatePointsArray(): boolean;
  17005. /**
  17006. * Creates a new InstancedMesh from the current mesh.
  17007. * - name (string) : the cloned mesh name
  17008. * - newParent (optional Node) : the optional Node to parent the clone to.
  17009. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  17010. *
  17011. * Returns the clone.
  17012. */
  17013. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  17014. /**
  17015. * Disposes the InstancedMesh.
  17016. * Returns nothing.
  17017. */
  17018. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  17019. }
  17020. }
  17021. declare module "babylonjs/Materials/shaderMaterial" {
  17022. import { Scene } from "babylonjs/scene";
  17023. import { Matrix, Vector3, Vector2, Color3, Color4, Vector4 } from "babylonjs/Maths/math";
  17024. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17025. import { Mesh } from "babylonjs/Meshes/mesh";
  17026. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  17027. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  17028. import { Texture } from "babylonjs/Materials/Textures/texture";
  17029. import { Material } from "babylonjs/Materials/material";
  17030. /**
  17031. * Defines the options associated with the creation of a shader material.
  17032. */
  17033. export interface IShaderMaterialOptions {
  17034. /**
  17035. * Does the material work in alpha blend mode
  17036. */
  17037. needAlphaBlending: boolean;
  17038. /**
  17039. * Does the material work in alpha test mode
  17040. */
  17041. needAlphaTesting: boolean;
  17042. /**
  17043. * The list of attribute names used in the shader
  17044. */
  17045. attributes: string[];
  17046. /**
  17047. * The list of unifrom names used in the shader
  17048. */
  17049. uniforms: string[];
  17050. /**
  17051. * The list of UBO names used in the shader
  17052. */
  17053. uniformBuffers: string[];
  17054. /**
  17055. * The list of sampler names used in the shader
  17056. */
  17057. samplers: string[];
  17058. /**
  17059. * The list of defines used in the shader
  17060. */
  17061. defines: string[];
  17062. }
  17063. /**
  17064. * 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.
  17065. *
  17066. * This returned material effects how the mesh will look based on the code in the shaders.
  17067. *
  17068. * @see http://doc.babylonjs.com/how_to/shader_material
  17069. */
  17070. export class ShaderMaterial extends Material {
  17071. private _shaderPath;
  17072. private _options;
  17073. private _textures;
  17074. private _textureArrays;
  17075. private _floats;
  17076. private _ints;
  17077. private _floatsArrays;
  17078. private _colors3;
  17079. private _colors3Arrays;
  17080. private _colors4;
  17081. private _vectors2;
  17082. private _vectors3;
  17083. private _vectors4;
  17084. private _matrices;
  17085. private _matrices3x3;
  17086. private _matrices2x2;
  17087. private _vectors2Arrays;
  17088. private _vectors3Arrays;
  17089. private _cachedWorldViewMatrix;
  17090. private _renderId;
  17091. /**
  17092. * Instantiate a new shader material.
  17093. * 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.
  17094. * This returned material effects how the mesh will look based on the code in the shaders.
  17095. * @see http://doc.babylonjs.com/how_to/shader_material
  17096. * @param name Define the name of the material in the scene
  17097. * @param scene Define the scene the material belongs to
  17098. * @param shaderPath Defines the route to the shader code in one of three ways:
  17099. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  17100. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  17101. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  17102. * @param options Define the options used to create the shader
  17103. */
  17104. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  17105. /**
  17106. * Gets the options used to compile the shader.
  17107. * They can be modified to trigger a new compilation
  17108. */
  17109. readonly options: IShaderMaterialOptions;
  17110. /**
  17111. * Gets the current class name of the material e.g. "ShaderMaterial"
  17112. * Mainly use in serialization.
  17113. * @returns the class name
  17114. */
  17115. getClassName(): string;
  17116. /**
  17117. * Specifies if the material will require alpha blending
  17118. * @returns a boolean specifying if alpha blending is needed
  17119. */
  17120. needAlphaBlending(): boolean;
  17121. /**
  17122. * Specifies if this material should be rendered in alpha test mode
  17123. * @returns a boolean specifying if an alpha test is needed.
  17124. */
  17125. needAlphaTesting(): boolean;
  17126. private _checkUniform;
  17127. /**
  17128. * Set a texture in the shader.
  17129. * @param name Define the name of the uniform samplers as defined in the shader
  17130. * @param texture Define the texture to bind to this sampler
  17131. * @return the material itself allowing "fluent" like uniform updates
  17132. */
  17133. setTexture(name: string, texture: Texture): ShaderMaterial;
  17134. /**
  17135. * Set a texture array in the shader.
  17136. * @param name Define the name of the uniform sampler array as defined in the shader
  17137. * @param textures Define the list of textures to bind to this sampler
  17138. * @return the material itself allowing "fluent" like uniform updates
  17139. */
  17140. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  17141. /**
  17142. * Set a float in the shader.
  17143. * @param name Define the name of the uniform as defined in the shader
  17144. * @param value Define the value to give to the uniform
  17145. * @return the material itself allowing "fluent" like uniform updates
  17146. */
  17147. setFloat(name: string, value: number): ShaderMaterial;
  17148. /**
  17149. * Set a int in the shader.
  17150. * @param name Define the name of the uniform as defined in the shader
  17151. * @param value Define the value to give to the uniform
  17152. * @return the material itself allowing "fluent" like uniform updates
  17153. */
  17154. setInt(name: string, value: number): ShaderMaterial;
  17155. /**
  17156. * Set an array of floats in the shader.
  17157. * @param name Define the name of the uniform as defined in the shader
  17158. * @param value Define the value to give to the uniform
  17159. * @return the material itself allowing "fluent" like uniform updates
  17160. */
  17161. setFloats(name: string, value: number[]): ShaderMaterial;
  17162. /**
  17163. * Set a vec3 in the shader from a Color3.
  17164. * @param name Define the name of the uniform as defined in the shader
  17165. * @param value Define the value to give to the uniform
  17166. * @return the material itself allowing "fluent" like uniform updates
  17167. */
  17168. setColor3(name: string, value: Color3): ShaderMaterial;
  17169. /**
  17170. * Set a vec3 array in the shader from a Color3 array.
  17171. * @param name Define the name of the uniform as defined in the shader
  17172. * @param value Define the value to give to the uniform
  17173. * @return the material itself allowing "fluent" like uniform updates
  17174. */
  17175. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  17176. /**
  17177. * Set a vec4 in the shader from a Color4.
  17178. * @param name Define the name of the uniform as defined in the shader
  17179. * @param value Define the value to give to the uniform
  17180. * @return the material itself allowing "fluent" like uniform updates
  17181. */
  17182. setColor4(name: string, value: Color4): ShaderMaterial;
  17183. /**
  17184. * Set a vec2 in the shader from a Vector2.
  17185. * @param name Define the name of the uniform as defined in the shader
  17186. * @param value Define the value to give to the uniform
  17187. * @return the material itself allowing "fluent" like uniform updates
  17188. */
  17189. setVector2(name: string, value: Vector2): ShaderMaterial;
  17190. /**
  17191. * Set a vec3 in the shader from a Vector3.
  17192. * @param name Define the name of the uniform as defined in the shader
  17193. * @param value Define the value to give to the uniform
  17194. * @return the material itself allowing "fluent" like uniform updates
  17195. */
  17196. setVector3(name: string, value: Vector3): ShaderMaterial;
  17197. /**
  17198. * Set a vec4 in the shader from a Vector4.
  17199. * @param name Define the name of the uniform as defined in the shader
  17200. * @param value Define the value to give to the uniform
  17201. * @return the material itself allowing "fluent" like uniform updates
  17202. */
  17203. setVector4(name: string, value: Vector4): ShaderMaterial;
  17204. /**
  17205. * Set a mat4 in the shader from a Matrix.
  17206. * @param name Define the name of the uniform as defined in the shader
  17207. * @param value Define the value to give to the uniform
  17208. * @return the material itself allowing "fluent" like uniform updates
  17209. */
  17210. setMatrix(name: string, value: Matrix): ShaderMaterial;
  17211. /**
  17212. * Set a mat3 in the shader from a Float32Array.
  17213. * @param name Define the name of the uniform as defined in the shader
  17214. * @param value Define the value to give to the uniform
  17215. * @return the material itself allowing "fluent" like uniform updates
  17216. */
  17217. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  17218. /**
  17219. * Set a mat2 in the shader from a Float32Array.
  17220. * @param name Define the name of the uniform as defined in the shader
  17221. * @param value Define the value to give to the uniform
  17222. * @return the material itself allowing "fluent" like uniform updates
  17223. */
  17224. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  17225. /**
  17226. * Set a vec2 array in the shader from a number array.
  17227. * @param name Define the name of the uniform as defined in the shader
  17228. * @param value Define the value to give to the uniform
  17229. * @return the material itself allowing "fluent" like uniform updates
  17230. */
  17231. setArray2(name: string, value: number[]): ShaderMaterial;
  17232. /**
  17233. * Set a vec3 array in the shader from a number array.
  17234. * @param name Define the name of the uniform as defined in the shader
  17235. * @param value Define the value to give to the uniform
  17236. * @return the material itself allowing "fluent" like uniform updates
  17237. */
  17238. setArray3(name: string, value: number[]): ShaderMaterial;
  17239. private _checkCache;
  17240. /**
  17241. * Specifies that the submesh is ready to be used
  17242. * @param mesh defines the mesh to check
  17243. * @param subMesh defines which submesh to check
  17244. * @param useInstances specifies that instances should be used
  17245. * @returns a boolean indicating that the submesh is ready or not
  17246. */
  17247. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  17248. /**
  17249. * Checks if the material is ready to render the requested mesh
  17250. * @param mesh Define the mesh to render
  17251. * @param useInstances Define whether or not the material is used with instances
  17252. * @returns true if ready, otherwise false
  17253. */
  17254. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  17255. /**
  17256. * Binds the world matrix to the material
  17257. * @param world defines the world transformation matrix
  17258. */
  17259. bindOnlyWorldMatrix(world: Matrix): void;
  17260. /**
  17261. * Binds the material to the mesh
  17262. * @param world defines the world transformation matrix
  17263. * @param mesh defines the mesh to bind the material to
  17264. */
  17265. bind(world: Matrix, mesh?: Mesh): void;
  17266. /**
  17267. * Gets the active textures from the material
  17268. * @returns an array of textures
  17269. */
  17270. getActiveTextures(): BaseTexture[];
  17271. /**
  17272. * Specifies if the material uses a texture
  17273. * @param texture defines the texture to check against the material
  17274. * @returns a boolean specifying if the material uses the texture
  17275. */
  17276. hasTexture(texture: BaseTexture): boolean;
  17277. /**
  17278. * Makes a duplicate of the material, and gives it a new name
  17279. * @param name defines the new name for the duplicated material
  17280. * @returns the cloned material
  17281. */
  17282. clone(name: string): ShaderMaterial;
  17283. /**
  17284. * Disposes the material
  17285. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  17286. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  17287. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  17288. */
  17289. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  17290. /**
  17291. * Serializes this material in a JSON representation
  17292. * @returns the serialized material object
  17293. */
  17294. serialize(): any;
  17295. /**
  17296. * Creates a shader material from parsed shader material data
  17297. * @param source defines the JSON represnetation of the material
  17298. * @param scene defines the hosting scene
  17299. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  17300. * @returns a new material
  17301. */
  17302. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  17303. }
  17304. }
  17305. declare module "babylonjs/Shaders/color.fragment" {
  17306. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  17307. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  17308. /** @hidden */
  17309. export var colorPixelShader: {
  17310. name: string;
  17311. shader: string;
  17312. };
  17313. }
  17314. declare module "babylonjs/Shaders/color.vertex" {
  17315. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  17316. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  17317. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  17318. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  17319. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  17320. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  17321. /** @hidden */
  17322. export var colorVertexShader: {
  17323. name: string;
  17324. shader: string;
  17325. };
  17326. }
  17327. declare module "babylonjs/Meshes/linesMesh" {
  17328. import { Nullable } from "babylonjs/types";
  17329. import { Scene } from "babylonjs/scene";
  17330. import { Color3 } from "babylonjs/Maths/math";
  17331. import { Node } from "babylonjs/node";
  17332. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17333. import { Mesh } from "babylonjs/Meshes/mesh";
  17334. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  17335. import { Effect } from "babylonjs/Materials/effect";
  17336. import { Material } from "babylonjs/Materials/material";
  17337. import "babylonjs/Shaders/color.fragment";
  17338. import "babylonjs/Shaders/color.vertex";
  17339. /**
  17340. * Line mesh
  17341. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  17342. */
  17343. export class LinesMesh extends Mesh {
  17344. /**
  17345. * If vertex color should be applied to the mesh
  17346. */
  17347. useVertexColor?: boolean | undefined;
  17348. /**
  17349. * If vertex alpha should be applied to the mesh
  17350. */
  17351. useVertexAlpha?: boolean | undefined;
  17352. /**
  17353. * Color of the line (Default: White)
  17354. */
  17355. color: Color3;
  17356. /**
  17357. * Alpha of the line (Default: 1)
  17358. */
  17359. alpha: number;
  17360. /**
  17361. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17362. * This margin is expressed in world space coordinates, so its value may vary.
  17363. * Default value is 0.1
  17364. */
  17365. intersectionThreshold: number;
  17366. private _colorShader;
  17367. /**
  17368. * Creates a new LinesMesh
  17369. * @param name defines the name
  17370. * @param scene defines the hosting scene
  17371. * @param parent defines the parent mesh if any
  17372. * @param source defines the optional source LinesMesh used to clone data from
  17373. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  17374. * When false, achieved by calling a clone(), also passing False.
  17375. * This will make creation of children, recursive.
  17376. * @param useVertexColor defines if this LinesMesh supports vertex color
  17377. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  17378. */
  17379. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  17380. /**
  17381. * If vertex color should be applied to the mesh
  17382. */
  17383. useVertexColor?: boolean | undefined,
  17384. /**
  17385. * If vertex alpha should be applied to the mesh
  17386. */
  17387. useVertexAlpha?: boolean | undefined);
  17388. private _addClipPlaneDefine;
  17389. private _removeClipPlaneDefine;
  17390. isReady(): boolean;
  17391. /**
  17392. * Returns the string "LineMesh"
  17393. */
  17394. getClassName(): string;
  17395. /**
  17396. * @hidden
  17397. */
  17398. /**
  17399. * @hidden
  17400. */
  17401. material: Material;
  17402. /**
  17403. * @hidden
  17404. */
  17405. readonly checkCollisions: boolean;
  17406. /** @hidden */
  17407. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  17408. /** @hidden */
  17409. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  17410. /**
  17411. * Disposes of the line mesh
  17412. * @param doNotRecurse If children should be disposed
  17413. */
  17414. dispose(doNotRecurse?: boolean): void;
  17415. /**
  17416. * Returns a new LineMesh object cloned from the current one.
  17417. */
  17418. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  17419. /**
  17420. * Creates a new InstancedLinesMesh object from the mesh model.
  17421. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  17422. * @param name defines the name of the new instance
  17423. * @returns a new InstancedLinesMesh
  17424. */
  17425. createInstance(name: string): InstancedLinesMesh;
  17426. }
  17427. /**
  17428. * Creates an instance based on a source LinesMesh
  17429. */
  17430. export class InstancedLinesMesh extends InstancedMesh {
  17431. /**
  17432. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17433. * This margin is expressed in world space coordinates, so its value may vary.
  17434. * Initilized with the intersectionThreshold value of the source LinesMesh
  17435. */
  17436. intersectionThreshold: number;
  17437. constructor(name: string, source: LinesMesh);
  17438. /**
  17439. * Returns the string "InstancedLinesMesh".
  17440. */
  17441. getClassName(): string;
  17442. }
  17443. }
  17444. declare module "babylonjs/Shaders/line.fragment" {
  17445. /** @hidden */
  17446. export var linePixelShader: {
  17447. name: string;
  17448. shader: string;
  17449. };
  17450. }
  17451. declare module "babylonjs/Shaders/line.vertex" {
  17452. /** @hidden */
  17453. export var lineVertexShader: {
  17454. name: string;
  17455. shader: string;
  17456. };
  17457. }
  17458. declare module "babylonjs/Rendering/edgesRenderer" {
  17459. import { Nullable } from "babylonjs/types";
  17460. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  17461. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17462. import { Vector3 } from "babylonjs/Maths/math";
  17463. import { IDisposable } from "babylonjs/scene";
  17464. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  17465. import "babylonjs/Shaders/line.fragment";
  17466. import "babylonjs/Shaders/line.vertex";
  17467. module "babylonjs/Meshes/abstractMesh" {
  17468. interface AbstractMesh {
  17469. /**
  17470. * Disables the mesh edge rendering mode
  17471. * @returns the currentAbstractMesh
  17472. */
  17473. disableEdgesRendering(): AbstractMesh;
  17474. /**
  17475. * Enables the edge rendering mode on the mesh.
  17476. * This mode makes the mesh edges visible
  17477. * @param epsilon defines the maximal distance between two angles to detect a face
  17478. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17479. * @returns the currentAbstractMesh
  17480. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17481. */
  17482. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  17483. /**
  17484. * Gets the edgesRenderer associated with the mesh
  17485. */
  17486. edgesRenderer: Nullable<EdgesRenderer>;
  17487. }
  17488. }
  17489. module "babylonjs/Meshes/linesMesh" {
  17490. interface LinesMesh {
  17491. /**
  17492. * Enables the edge rendering mode on the mesh.
  17493. * This mode makes the mesh edges visible
  17494. * @param epsilon defines the maximal distance between two angles to detect a face
  17495. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17496. * @returns the currentAbstractMesh
  17497. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17498. */
  17499. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  17500. }
  17501. }
  17502. module "babylonjs/Meshes/linesMesh" {
  17503. interface InstancedLinesMesh {
  17504. /**
  17505. * Enables the edge rendering mode on the mesh.
  17506. * This mode makes the mesh edges visible
  17507. * @param epsilon defines the maximal distance between two angles to detect a face
  17508. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17509. * @returns the current InstancedLinesMesh
  17510. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17511. */
  17512. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  17513. }
  17514. }
  17515. /**
  17516. * Defines the minimum contract an Edges renderer should follow.
  17517. */
  17518. export interface IEdgesRenderer extends IDisposable {
  17519. /**
  17520. * Gets or sets a boolean indicating if the edgesRenderer is active
  17521. */
  17522. isEnabled: boolean;
  17523. /**
  17524. * Renders the edges of the attached mesh,
  17525. */
  17526. render(): void;
  17527. /**
  17528. * Checks wether or not the edges renderer is ready to render.
  17529. * @return true if ready, otherwise false.
  17530. */
  17531. isReady(): boolean;
  17532. }
  17533. /**
  17534. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  17535. */
  17536. export class EdgesRenderer implements IEdgesRenderer {
  17537. /**
  17538. * Define the size of the edges with an orthographic camera
  17539. */
  17540. edgesWidthScalerForOrthographic: number;
  17541. /**
  17542. * Define the size of the edges with a perspective camera
  17543. */
  17544. edgesWidthScalerForPerspective: number;
  17545. protected _source: AbstractMesh;
  17546. protected _linesPositions: number[];
  17547. protected _linesNormals: number[];
  17548. protected _linesIndices: number[];
  17549. protected _epsilon: number;
  17550. protected _indicesCount: number;
  17551. protected _lineShader: ShaderMaterial;
  17552. protected _ib: WebGLBuffer;
  17553. protected _buffers: {
  17554. [key: string]: Nullable<VertexBuffer>;
  17555. };
  17556. protected _checkVerticesInsteadOfIndices: boolean;
  17557. private _meshRebuildObserver;
  17558. private _meshDisposeObserver;
  17559. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  17560. isEnabled: boolean;
  17561. /**
  17562. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  17563. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  17564. * @param source Mesh used to create edges
  17565. * @param epsilon sum of angles in adjacency to check for edge
  17566. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  17567. * @param generateEdgesLines - should generate Lines or only prepare resources.
  17568. */
  17569. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  17570. protected _prepareRessources(): void;
  17571. /** @hidden */
  17572. _rebuild(): void;
  17573. /**
  17574. * Releases the required resources for the edges renderer
  17575. */
  17576. dispose(): void;
  17577. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  17578. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  17579. /**
  17580. * Checks if the pair of p0 and p1 is en edge
  17581. * @param faceIndex
  17582. * @param edge
  17583. * @param faceNormals
  17584. * @param p0
  17585. * @param p1
  17586. * @private
  17587. */
  17588. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  17589. /**
  17590. * push line into the position, normal and index buffer
  17591. * @protected
  17592. */
  17593. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  17594. /**
  17595. * Generates lines edges from adjacencjes
  17596. * @private
  17597. */
  17598. _generateEdgesLines(): void;
  17599. /**
  17600. * Checks wether or not the edges renderer is ready to render.
  17601. * @return true if ready, otherwise false.
  17602. */
  17603. isReady(): boolean;
  17604. /**
  17605. * Renders the edges of the attached mesh,
  17606. */
  17607. render(): void;
  17608. }
  17609. /**
  17610. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  17611. */
  17612. export class LineEdgesRenderer extends EdgesRenderer {
  17613. /**
  17614. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  17615. * @param source LineMesh used to generate edges
  17616. * @param epsilon not important (specified angle for edge detection)
  17617. * @param checkVerticesInsteadOfIndices not important for LineMesh
  17618. */
  17619. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  17620. /**
  17621. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  17622. */
  17623. _generateEdgesLines(): void;
  17624. }
  17625. }
  17626. declare module "babylonjs/Rendering/renderingGroup" {
  17627. import { SmartArray } from "babylonjs/Misc/smartArray";
  17628. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17629. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17630. import { Nullable } from "babylonjs/types";
  17631. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17632. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  17633. import { Material } from "babylonjs/Materials/material";
  17634. import { Scene } from "babylonjs/scene";
  17635. /**
  17636. * This represents the object necessary to create a rendering group.
  17637. * This is exclusively used and created by the rendering manager.
  17638. * To modify the behavior, you use the available helpers in your scene or meshes.
  17639. * @hidden
  17640. */
  17641. export class RenderingGroup {
  17642. index: number;
  17643. private _scene;
  17644. private _opaqueSubMeshes;
  17645. private _transparentSubMeshes;
  17646. private _alphaTestSubMeshes;
  17647. private _depthOnlySubMeshes;
  17648. private _particleSystems;
  17649. private _spriteManagers;
  17650. private _opaqueSortCompareFn;
  17651. private _alphaTestSortCompareFn;
  17652. private _transparentSortCompareFn;
  17653. private _renderOpaque;
  17654. private _renderAlphaTest;
  17655. private _renderTransparent;
  17656. private _edgesRenderers;
  17657. onBeforeTransparentRendering: () => void;
  17658. /**
  17659. * Set the opaque sort comparison function.
  17660. * If null the sub meshes will be render in the order they were created
  17661. */
  17662. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17663. /**
  17664. * Set the alpha test sort comparison function.
  17665. * If null the sub meshes will be render in the order they were created
  17666. */
  17667. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17668. /**
  17669. * Set the transparent sort comparison function.
  17670. * If null the sub meshes will be render in the order they were created
  17671. */
  17672. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17673. /**
  17674. * Creates a new rendering group.
  17675. * @param index The rendering group index
  17676. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  17677. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  17678. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  17679. */
  17680. 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>);
  17681. /**
  17682. * Render all the sub meshes contained in the group.
  17683. * @param customRenderFunction Used to override the default render behaviour of the group.
  17684. * @returns true if rendered some submeshes.
  17685. */
  17686. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  17687. /**
  17688. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  17689. * @param subMeshes The submeshes to render
  17690. */
  17691. private renderOpaqueSorted;
  17692. /**
  17693. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  17694. * @param subMeshes The submeshes to render
  17695. */
  17696. private renderAlphaTestSorted;
  17697. /**
  17698. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  17699. * @param subMeshes The submeshes to render
  17700. */
  17701. private renderTransparentSorted;
  17702. /**
  17703. * Renders the submeshes in a specified order.
  17704. * @param subMeshes The submeshes to sort before render
  17705. * @param sortCompareFn The comparison function use to sort
  17706. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  17707. * @param transparent Specifies to activate blending if true
  17708. */
  17709. private static renderSorted;
  17710. /**
  17711. * Renders the submeshes in the order they were dispatched (no sort applied).
  17712. * @param subMeshes The submeshes to render
  17713. */
  17714. private static renderUnsorted;
  17715. /**
  17716. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17717. * are rendered back to front if in the same alpha index.
  17718. *
  17719. * @param a The first submesh
  17720. * @param b The second submesh
  17721. * @returns The result of the comparison
  17722. */
  17723. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  17724. /**
  17725. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17726. * are rendered back to front.
  17727. *
  17728. * @param a The first submesh
  17729. * @param b The second submesh
  17730. * @returns The result of the comparison
  17731. */
  17732. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  17733. /**
  17734. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17735. * are rendered front to back (prevent overdraw).
  17736. *
  17737. * @param a The first submesh
  17738. * @param b The second submesh
  17739. * @returns The result of the comparison
  17740. */
  17741. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  17742. /**
  17743. * Resets the different lists of submeshes to prepare a new frame.
  17744. */
  17745. prepare(): void;
  17746. dispose(): void;
  17747. /**
  17748. * Inserts the submesh in its correct queue depending on its material.
  17749. * @param subMesh The submesh to dispatch
  17750. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17751. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17752. */
  17753. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17754. dispatchSprites(spriteManager: ISpriteManager): void;
  17755. dispatchParticles(particleSystem: IParticleSystem): void;
  17756. private _renderParticles;
  17757. private _renderSprites;
  17758. }
  17759. }
  17760. declare module "babylonjs/Rendering/renderingManager" {
  17761. import { Nullable } from "babylonjs/types";
  17762. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17763. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17764. import { SmartArray } from "babylonjs/Misc/smartArray";
  17765. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  17766. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17767. import { Material } from "babylonjs/Materials/material";
  17768. import { Scene } from "babylonjs/scene";
  17769. import { Camera } from "babylonjs/Cameras/camera";
  17770. /**
  17771. * Interface describing the different options available in the rendering manager
  17772. * regarding Auto Clear between groups.
  17773. */
  17774. export interface IRenderingManagerAutoClearSetup {
  17775. /**
  17776. * Defines whether or not autoclear is enable.
  17777. */
  17778. autoClear: boolean;
  17779. /**
  17780. * Defines whether or not to autoclear the depth buffer.
  17781. */
  17782. depth: boolean;
  17783. /**
  17784. * Defines whether or not to autoclear the stencil buffer.
  17785. */
  17786. stencil: boolean;
  17787. }
  17788. /**
  17789. * This class is used by the onRenderingGroupObservable
  17790. */
  17791. export class RenderingGroupInfo {
  17792. /**
  17793. * The Scene that being rendered
  17794. */
  17795. scene: Scene;
  17796. /**
  17797. * The camera currently used for the rendering pass
  17798. */
  17799. camera: Nullable<Camera>;
  17800. /**
  17801. * The ID of the renderingGroup being processed
  17802. */
  17803. renderingGroupId: number;
  17804. }
  17805. /**
  17806. * This is the manager responsible of all the rendering for meshes sprites and particles.
  17807. * It is enable to manage the different groups as well as the different necessary sort functions.
  17808. * This should not be used directly aside of the few static configurations
  17809. */
  17810. export class RenderingManager {
  17811. /**
  17812. * The max id used for rendering groups (not included)
  17813. */
  17814. static MAX_RENDERINGGROUPS: number;
  17815. /**
  17816. * The min id used for rendering groups (included)
  17817. */
  17818. static MIN_RENDERINGGROUPS: number;
  17819. /**
  17820. * Used to globally prevent autoclearing scenes.
  17821. */
  17822. static AUTOCLEAR: boolean;
  17823. /**
  17824. * @hidden
  17825. */
  17826. _useSceneAutoClearSetup: boolean;
  17827. private _scene;
  17828. private _renderingGroups;
  17829. private _depthStencilBufferAlreadyCleaned;
  17830. private _autoClearDepthStencil;
  17831. private _customOpaqueSortCompareFn;
  17832. private _customAlphaTestSortCompareFn;
  17833. private _customTransparentSortCompareFn;
  17834. private _renderingGroupInfo;
  17835. /**
  17836. * Instantiates a new rendering group for a particular scene
  17837. * @param scene Defines the scene the groups belongs to
  17838. */
  17839. constructor(scene: Scene);
  17840. private _clearDepthStencilBuffer;
  17841. /**
  17842. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  17843. * @hidden
  17844. */
  17845. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  17846. /**
  17847. * Resets the different information of the group to prepare a new frame
  17848. * @hidden
  17849. */
  17850. reset(): void;
  17851. /**
  17852. * Dispose and release the group and its associated resources.
  17853. * @hidden
  17854. */
  17855. dispose(): void;
  17856. /**
  17857. * Clear the info related to rendering groups preventing retention points during dispose.
  17858. */
  17859. freeRenderingGroups(): void;
  17860. private _prepareRenderingGroup;
  17861. /**
  17862. * Add a sprite manager to the rendering manager in order to render it this frame.
  17863. * @param spriteManager Define the sprite manager to render
  17864. */
  17865. dispatchSprites(spriteManager: ISpriteManager): void;
  17866. /**
  17867. * Add a particle system to the rendering manager in order to render it this frame.
  17868. * @param particleSystem Define the particle system to render
  17869. */
  17870. dispatchParticles(particleSystem: IParticleSystem): void;
  17871. /**
  17872. * Add a submesh to the manager in order to render it this frame
  17873. * @param subMesh The submesh to dispatch
  17874. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17875. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17876. */
  17877. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17878. /**
  17879. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  17880. * This allowed control for front to back rendering or reversly depending of the special needs.
  17881. *
  17882. * @param renderingGroupId The rendering group id corresponding to its index
  17883. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  17884. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  17885. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  17886. */
  17887. 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;
  17888. /**
  17889. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  17890. *
  17891. * @param renderingGroupId The rendering group id corresponding to its index
  17892. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  17893. * @param depth Automatically clears depth between groups if true and autoClear is true.
  17894. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  17895. */
  17896. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  17897. /**
  17898. * Gets the current auto clear configuration for one rendering group of the rendering
  17899. * manager.
  17900. * @param index the rendering group index to get the information for
  17901. * @returns The auto clear setup for the requested rendering group
  17902. */
  17903. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  17904. }
  17905. }
  17906. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  17907. import { Observable } from "babylonjs/Misc/observable";
  17908. import { SmartArray } from "babylonjs/Misc/smartArray";
  17909. import { Nullable } from "babylonjs/types";
  17910. import { Camera } from "babylonjs/Cameras/camera";
  17911. import { Scene } from "babylonjs/scene";
  17912. import { Matrix, Vector3, Color4 } from "babylonjs/Maths/math";
  17913. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  17914. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17915. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17916. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  17917. import { Texture } from "babylonjs/Materials/Textures/texture";
  17918. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  17919. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  17920. import { Engine } from "babylonjs/Engines/engine";
  17921. /**
  17922. * This Helps creating a texture that will be created from a camera in your scene.
  17923. * It is basically a dynamic texture that could be used to create special effects for instance.
  17924. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  17925. */
  17926. export class RenderTargetTexture extends Texture {
  17927. isCube: boolean;
  17928. /**
  17929. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  17930. */
  17931. static readonly REFRESHRATE_RENDER_ONCE: number;
  17932. /**
  17933. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  17934. */
  17935. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  17936. /**
  17937. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  17938. * the central point of your effect and can save a lot of performances.
  17939. */
  17940. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  17941. /**
  17942. * Use this predicate to dynamically define the list of mesh you want to render.
  17943. * If set, the renderList property will be overwritten.
  17944. */
  17945. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  17946. private _renderList;
  17947. /**
  17948. * Use this list to define the list of mesh you want to render.
  17949. */
  17950. renderList: Nullable<Array<AbstractMesh>>;
  17951. private _hookArray;
  17952. /**
  17953. * Define if particles should be rendered in your texture.
  17954. */
  17955. renderParticles: boolean;
  17956. /**
  17957. * Define if sprites should be rendered in your texture.
  17958. */
  17959. renderSprites: boolean;
  17960. /**
  17961. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  17962. */
  17963. coordinatesMode: number;
  17964. /**
  17965. * Define the camera used to render the texture.
  17966. */
  17967. activeCamera: Nullable<Camera>;
  17968. /**
  17969. * Override the render function of the texture with your own one.
  17970. */
  17971. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  17972. /**
  17973. * Define if camera post processes should be use while rendering the texture.
  17974. */
  17975. useCameraPostProcesses: boolean;
  17976. /**
  17977. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  17978. */
  17979. ignoreCameraViewport: boolean;
  17980. private _postProcessManager;
  17981. private _postProcesses;
  17982. private _resizeObserver;
  17983. /**
  17984. * An event triggered when the texture is unbind.
  17985. */
  17986. onBeforeBindObservable: Observable<RenderTargetTexture>;
  17987. /**
  17988. * An event triggered when the texture is unbind.
  17989. */
  17990. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  17991. private _onAfterUnbindObserver;
  17992. /**
  17993. * Set a after unbind callback in the texture.
  17994. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  17995. */
  17996. onAfterUnbind: () => void;
  17997. /**
  17998. * An event triggered before rendering the texture
  17999. */
  18000. onBeforeRenderObservable: Observable<number>;
  18001. private _onBeforeRenderObserver;
  18002. /**
  18003. * Set a before render callback in the texture.
  18004. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  18005. */
  18006. onBeforeRender: (faceIndex: number) => void;
  18007. /**
  18008. * An event triggered after rendering the texture
  18009. */
  18010. onAfterRenderObservable: Observable<number>;
  18011. private _onAfterRenderObserver;
  18012. /**
  18013. * Set a after render callback in the texture.
  18014. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  18015. */
  18016. onAfterRender: (faceIndex: number) => void;
  18017. /**
  18018. * An event triggered after the texture clear
  18019. */
  18020. onClearObservable: Observable<import("babylonjs/Engines/engine").Engine>;
  18021. private _onClearObserver;
  18022. /**
  18023. * Set a clear callback in the texture.
  18024. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  18025. */
  18026. onClear: (Engine: Engine) => void;
  18027. /**
  18028. * Define the clear color of the Render Target if it should be different from the scene.
  18029. */
  18030. clearColor: Color4;
  18031. protected _size: number | {
  18032. width: number;
  18033. height: number;
  18034. };
  18035. protected _initialSizeParameter: number | {
  18036. width: number;
  18037. height: number;
  18038. } | {
  18039. ratio: number;
  18040. };
  18041. protected _sizeRatio: Nullable<number>;
  18042. /** @hidden */
  18043. _generateMipMaps: boolean;
  18044. protected _renderingManager: RenderingManager;
  18045. /** @hidden */
  18046. _waitingRenderList: string[];
  18047. protected _doNotChangeAspectRatio: boolean;
  18048. protected _currentRefreshId: number;
  18049. protected _refreshRate: number;
  18050. protected _textureMatrix: Matrix;
  18051. protected _samples: number;
  18052. protected _renderTargetOptions: RenderTargetCreationOptions;
  18053. /**
  18054. * Gets render target creation options that were used.
  18055. */
  18056. readonly renderTargetOptions: RenderTargetCreationOptions;
  18057. protected _engine: Engine;
  18058. protected _onRatioRescale(): void;
  18059. /**
  18060. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  18061. * It must define where the camera used to render the texture is set
  18062. */
  18063. boundingBoxPosition: Vector3;
  18064. private _boundingBoxSize;
  18065. /**
  18066. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  18067. * When defined, the cubemap will switch to local mode
  18068. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  18069. * @example https://www.babylonjs-playground.com/#RNASML
  18070. */
  18071. boundingBoxSize: Vector3;
  18072. /**
  18073. * In case the RTT has been created with a depth texture, get the associated
  18074. * depth texture.
  18075. * Otherwise, return null.
  18076. */
  18077. depthStencilTexture: Nullable<InternalTexture>;
  18078. /**
  18079. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  18080. * or used a shadow, depth texture...
  18081. * @param name The friendly name of the texture
  18082. * @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)
  18083. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  18084. * @param generateMipMaps True if mip maps need to be generated after render.
  18085. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  18086. * @param type The type of the buffer in the RTT (int, half float, float...)
  18087. * @param isCube True if a cube texture needs to be created
  18088. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  18089. * @param generateDepthBuffer True to generate a depth buffer
  18090. * @param generateStencilBuffer True to generate a stencil buffer
  18091. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  18092. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  18093. * @param delayAllocation if the texture allocation should be delayed (default: false)
  18094. */
  18095. constructor(name: string, size: number | {
  18096. width: number;
  18097. height: number;
  18098. } | {
  18099. ratio: number;
  18100. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  18101. /**
  18102. * Creates a depth stencil texture.
  18103. * This is only available in WebGL 2 or with the depth texture extension available.
  18104. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  18105. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  18106. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  18107. */
  18108. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  18109. private _processSizeParameter;
  18110. /**
  18111. * Define the number of samples to use in case of MSAA.
  18112. * It defaults to one meaning no MSAA has been enabled.
  18113. */
  18114. samples: number;
  18115. /**
  18116. * Resets the refresh counter of the texture and start bak from scratch.
  18117. * Could be useful to regenerate the texture if it is setup to render only once.
  18118. */
  18119. resetRefreshCounter(): void;
  18120. /**
  18121. * Define the refresh rate of the texture or the rendering frequency.
  18122. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  18123. */
  18124. refreshRate: number;
  18125. /**
  18126. * Adds a post process to the render target rendering passes.
  18127. * @param postProcess define the post process to add
  18128. */
  18129. addPostProcess(postProcess: PostProcess): void;
  18130. /**
  18131. * Clear all the post processes attached to the render target
  18132. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  18133. */
  18134. clearPostProcesses(dispose?: boolean): void;
  18135. /**
  18136. * Remove one of the post process from the list of attached post processes to the texture
  18137. * @param postProcess define the post process to remove from the list
  18138. */
  18139. removePostProcess(postProcess: PostProcess): void;
  18140. /** @hidden */
  18141. _shouldRender(): boolean;
  18142. /**
  18143. * Gets the actual render size of the texture.
  18144. * @returns the width of the render size
  18145. */
  18146. getRenderSize(): number;
  18147. /**
  18148. * Gets the actual render width of the texture.
  18149. * @returns the width of the render size
  18150. */
  18151. getRenderWidth(): number;
  18152. /**
  18153. * Gets the actual render height of the texture.
  18154. * @returns the height of the render size
  18155. */
  18156. getRenderHeight(): number;
  18157. /**
  18158. * Get if the texture can be rescaled or not.
  18159. */
  18160. readonly canRescale: boolean;
  18161. /**
  18162. * Resize the texture using a ratio.
  18163. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  18164. */
  18165. scale(ratio: number): void;
  18166. /**
  18167. * Get the texture reflection matrix used to rotate/transform the reflection.
  18168. * @returns the reflection matrix
  18169. */
  18170. getReflectionTextureMatrix(): Matrix;
  18171. /**
  18172. * Resize the texture to a new desired size.
  18173. * Be carrefull as it will recreate all the data in the new texture.
  18174. * @param size Define the new size. It can be:
  18175. * - a number for squared texture,
  18176. * - an object containing { width: number, height: number }
  18177. * - or an object containing a ratio { ratio: number }
  18178. */
  18179. resize(size: number | {
  18180. width: number;
  18181. height: number;
  18182. } | {
  18183. ratio: number;
  18184. }): void;
  18185. /**
  18186. * Renders all the objects from the render list into the texture.
  18187. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  18188. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  18189. */
  18190. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  18191. private _bestReflectionRenderTargetDimension;
  18192. /**
  18193. * @hidden
  18194. * @param faceIndex face index to bind to if this is a cubetexture
  18195. */
  18196. _bindFrameBuffer(faceIndex?: number): void;
  18197. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  18198. private renderToTarget;
  18199. /**
  18200. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  18201. * This allowed control for front to back rendering or reversly depending of the special needs.
  18202. *
  18203. * @param renderingGroupId The rendering group id corresponding to its index
  18204. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  18205. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  18206. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  18207. */
  18208. 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;
  18209. /**
  18210. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  18211. *
  18212. * @param renderingGroupId The rendering group id corresponding to its index
  18213. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  18214. */
  18215. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  18216. /**
  18217. * Clones the texture.
  18218. * @returns the cloned texture
  18219. */
  18220. clone(): RenderTargetTexture;
  18221. /**
  18222. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  18223. * @returns The JSON representation of the texture
  18224. */
  18225. serialize(): any;
  18226. /**
  18227. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  18228. */
  18229. disposeFramebufferObjects(): void;
  18230. /**
  18231. * Dispose the texture and release its associated resources.
  18232. */
  18233. dispose(): void;
  18234. /** @hidden */
  18235. _rebuild(): void;
  18236. /**
  18237. * Clear the info related to rendering groups preventing retention point in material dispose.
  18238. */
  18239. freeRenderingGroups(): void;
  18240. /**
  18241. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  18242. * @returns the view count
  18243. */
  18244. getViewCount(): number;
  18245. }
  18246. }
  18247. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  18248. import { Scene } from "babylonjs/scene";
  18249. import { Plane } from "babylonjs/Maths/math";
  18250. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  18251. /**
  18252. * Mirror texture can be used to simulate the view from a mirror in a scene.
  18253. * It will dynamically be rendered every frame to adapt to the camera point of view.
  18254. * You can then easily use it as a reflectionTexture on a flat surface.
  18255. * In case the surface is not a plane, please consider relying on reflection probes.
  18256. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  18257. */
  18258. export class MirrorTexture extends RenderTargetTexture {
  18259. private scene;
  18260. /**
  18261. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  18262. * 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.
  18263. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  18264. */
  18265. mirrorPlane: Plane;
  18266. /**
  18267. * Define the blur ratio used to blur the reflection if needed.
  18268. */
  18269. blurRatio: number;
  18270. /**
  18271. * Define the adaptive blur kernel used to blur the reflection if needed.
  18272. * This will autocompute the closest best match for the `blurKernel`
  18273. */
  18274. adaptiveBlurKernel: number;
  18275. /**
  18276. * Define the blur kernel used to blur the reflection if needed.
  18277. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  18278. */
  18279. blurKernel: number;
  18280. /**
  18281. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  18282. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  18283. */
  18284. blurKernelX: number;
  18285. /**
  18286. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  18287. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  18288. */
  18289. blurKernelY: number;
  18290. private _autoComputeBlurKernel;
  18291. protected _onRatioRescale(): void;
  18292. private _updateGammaSpace;
  18293. private _imageProcessingConfigChangeObserver;
  18294. private _transformMatrix;
  18295. private _mirrorMatrix;
  18296. private _savedViewMatrix;
  18297. private _blurX;
  18298. private _blurY;
  18299. private _adaptiveBlurKernel;
  18300. private _blurKernelX;
  18301. private _blurKernelY;
  18302. private _blurRatio;
  18303. /**
  18304. * Instantiates a Mirror Texture.
  18305. * Mirror texture can be used to simulate the view from a mirror in a scene.
  18306. * It will dynamically be rendered every frame to adapt to the camera point of view.
  18307. * You can then easily use it as a reflectionTexture on a flat surface.
  18308. * In case the surface is not a plane, please consider relying on reflection probes.
  18309. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  18310. * @param name
  18311. * @param size
  18312. * @param scene
  18313. * @param generateMipMaps
  18314. * @param type
  18315. * @param samplingMode
  18316. * @param generateDepthBuffer
  18317. */
  18318. constructor(name: string, size: number | {
  18319. width: number;
  18320. height: number;
  18321. } | {
  18322. ratio: number;
  18323. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  18324. private _preparePostProcesses;
  18325. /**
  18326. * Clone the mirror texture.
  18327. * @returns the cloned texture
  18328. */
  18329. clone(): MirrorTexture;
  18330. /**
  18331. * Serialize the texture to a JSON representation you could use in Parse later on
  18332. * @returns the serialized JSON representation
  18333. */
  18334. serialize(): any;
  18335. /**
  18336. * Dispose the texture and release its associated resources.
  18337. */
  18338. dispose(): void;
  18339. }
  18340. }
  18341. declare module "babylonjs/Materials/Textures/texture" {
  18342. import { Observable } from "babylonjs/Misc/observable";
  18343. import { Nullable } from "babylonjs/types";
  18344. import { Scene } from "babylonjs/scene";
  18345. import { Matrix } from "babylonjs/Maths/math";
  18346. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  18347. import { IInspectable } from "babylonjs/Misc/iInspectable";
  18348. /**
  18349. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  18350. * @see http://doc.babylonjs.com/babylon101/materials#texture
  18351. */
  18352. export class Texture extends BaseTexture {
  18353. /** @hidden */
  18354. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => import("babylonjs/Materials/Textures/cubeTexture").CubeTexture;
  18355. /** @hidden */
  18356. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/mirrorTexture").MirrorTexture;
  18357. /** @hidden */
  18358. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture;
  18359. /** nearest is mag = nearest and min = nearest and mip = linear */
  18360. static readonly NEAREST_SAMPLINGMODE: number;
  18361. /** nearest is mag = nearest and min = nearest and mip = linear */
  18362. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  18363. /** Bilinear is mag = linear and min = linear and mip = nearest */
  18364. static readonly BILINEAR_SAMPLINGMODE: number;
  18365. /** Bilinear is mag = linear and min = linear and mip = nearest */
  18366. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  18367. /** Trilinear is mag = linear and min = linear and mip = linear */
  18368. static readonly TRILINEAR_SAMPLINGMODE: number;
  18369. /** Trilinear is mag = linear and min = linear and mip = linear */
  18370. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  18371. /** mag = nearest and min = nearest and mip = nearest */
  18372. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  18373. /** mag = nearest and min = linear and mip = nearest */
  18374. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  18375. /** mag = nearest and min = linear and mip = linear */
  18376. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  18377. /** mag = nearest and min = linear and mip = none */
  18378. static readonly NEAREST_LINEAR: number;
  18379. /** mag = nearest and min = nearest and mip = none */
  18380. static readonly NEAREST_NEAREST: number;
  18381. /** mag = linear and min = nearest and mip = nearest */
  18382. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  18383. /** mag = linear and min = nearest and mip = linear */
  18384. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  18385. /** mag = linear and min = linear and mip = none */
  18386. static readonly LINEAR_LINEAR: number;
  18387. /** mag = linear and min = nearest and mip = none */
  18388. static readonly LINEAR_NEAREST: number;
  18389. /** Explicit coordinates mode */
  18390. static readonly EXPLICIT_MODE: number;
  18391. /** Spherical coordinates mode */
  18392. static readonly SPHERICAL_MODE: number;
  18393. /** Planar coordinates mode */
  18394. static readonly PLANAR_MODE: number;
  18395. /** Cubic coordinates mode */
  18396. static readonly CUBIC_MODE: number;
  18397. /** Projection coordinates mode */
  18398. static readonly PROJECTION_MODE: number;
  18399. /** Inverse Cubic coordinates mode */
  18400. static readonly SKYBOX_MODE: number;
  18401. /** Inverse Cubic coordinates mode */
  18402. static readonly INVCUBIC_MODE: number;
  18403. /** Equirectangular coordinates mode */
  18404. static readonly EQUIRECTANGULAR_MODE: number;
  18405. /** Equirectangular Fixed coordinates mode */
  18406. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  18407. /** Equirectangular Fixed Mirrored coordinates mode */
  18408. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  18409. /** Texture is not repeating outside of 0..1 UVs */
  18410. static readonly CLAMP_ADDRESSMODE: number;
  18411. /** Texture is repeating outside of 0..1 UVs */
  18412. static readonly WRAP_ADDRESSMODE: number;
  18413. /** Texture is repeating and mirrored */
  18414. static readonly MIRROR_ADDRESSMODE: number;
  18415. /**
  18416. * 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
  18417. */
  18418. static UseSerializedUrlIfAny: boolean;
  18419. /**
  18420. * Define the url of the texture.
  18421. */
  18422. url: Nullable<string>;
  18423. /**
  18424. * Define an offset on the texture to offset the u coordinates of the UVs
  18425. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  18426. */
  18427. uOffset: number;
  18428. /**
  18429. * Define an offset on the texture to offset the v coordinates of the UVs
  18430. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  18431. */
  18432. vOffset: number;
  18433. /**
  18434. * Define an offset on the texture to scale the u coordinates of the UVs
  18435. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  18436. */
  18437. uScale: number;
  18438. /**
  18439. * Define an offset on the texture to scale the v coordinates of the UVs
  18440. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  18441. */
  18442. vScale: number;
  18443. /**
  18444. * Define an offset on the texture to rotate around the u coordinates of the UVs
  18445. * @see http://doc.babylonjs.com/how_to/more_materials
  18446. */
  18447. uAng: number;
  18448. /**
  18449. * Define an offset on the texture to rotate around the v coordinates of the UVs
  18450. * @see http://doc.babylonjs.com/how_to/more_materials
  18451. */
  18452. vAng: number;
  18453. /**
  18454. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  18455. * @see http://doc.babylonjs.com/how_to/more_materials
  18456. */
  18457. wAng: number;
  18458. /**
  18459. * Defines the center of rotation (U)
  18460. */
  18461. uRotationCenter: number;
  18462. /**
  18463. * Defines the center of rotation (V)
  18464. */
  18465. vRotationCenter: number;
  18466. /**
  18467. * Defines the center of rotation (W)
  18468. */
  18469. wRotationCenter: number;
  18470. /**
  18471. * Are mip maps generated for this texture or not.
  18472. */
  18473. readonly noMipmap: boolean;
  18474. /**
  18475. * List of inspectable custom properties (used by the Inspector)
  18476. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  18477. */
  18478. inspectableCustomProperties: IInspectable[];
  18479. private _noMipmap;
  18480. /** @hidden */
  18481. _invertY: boolean;
  18482. private _rowGenerationMatrix;
  18483. private _cachedTextureMatrix;
  18484. private _projectionModeMatrix;
  18485. private _t0;
  18486. private _t1;
  18487. private _t2;
  18488. private _cachedUOffset;
  18489. private _cachedVOffset;
  18490. private _cachedUScale;
  18491. private _cachedVScale;
  18492. private _cachedUAng;
  18493. private _cachedVAng;
  18494. private _cachedWAng;
  18495. private _cachedProjectionMatrixId;
  18496. private _cachedCoordinatesMode;
  18497. /** @hidden */
  18498. protected _initialSamplingMode: number;
  18499. /** @hidden */
  18500. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  18501. private _deleteBuffer;
  18502. protected _format: Nullable<number>;
  18503. private _delayedOnLoad;
  18504. private _delayedOnError;
  18505. /**
  18506. * Observable triggered once the texture has been loaded.
  18507. */
  18508. onLoadObservable: Observable<Texture>;
  18509. protected _isBlocking: boolean;
  18510. /**
  18511. * Is the texture preventing material to render while loading.
  18512. * If false, a default texture will be used instead of the loading one during the preparation step.
  18513. */
  18514. isBlocking: boolean;
  18515. /**
  18516. * Get the current sampling mode associated with the texture.
  18517. */
  18518. readonly samplingMode: number;
  18519. /**
  18520. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  18521. */
  18522. readonly invertY: boolean;
  18523. /**
  18524. * Instantiates a new texture.
  18525. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  18526. * @see http://doc.babylonjs.com/babylon101/materials#texture
  18527. * @param url define the url of the picture to load as a texture
  18528. * @param scene define the scene the texture will belong to
  18529. * @param noMipmap define if the texture will require mip maps or not
  18530. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18531. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18532. * @param onLoad define a callback triggered when the texture has been loaded
  18533. * @param onError define a callback triggered when an error occurred during the loading session
  18534. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  18535. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  18536. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18537. */
  18538. 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);
  18539. /**
  18540. * Update the url (and optional buffer) of this texture if url was null during construction.
  18541. * @param url the url of the texture
  18542. * @param buffer the buffer of the texture (defaults to null)
  18543. * @param onLoad callback called when the texture is loaded (defaults to null)
  18544. */
  18545. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  18546. /**
  18547. * Finish the loading sequence of a texture flagged as delayed load.
  18548. * @hidden
  18549. */
  18550. delayLoad(): void;
  18551. private _prepareRowForTextureGeneration;
  18552. /**
  18553. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  18554. * @returns the transform matrix of the texture.
  18555. */
  18556. getTextureMatrix(): Matrix;
  18557. /**
  18558. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  18559. * @returns The reflection texture transform
  18560. */
  18561. getReflectionTextureMatrix(): Matrix;
  18562. /**
  18563. * Clones the texture.
  18564. * @returns the cloned texture
  18565. */
  18566. clone(): Texture;
  18567. /**
  18568. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  18569. * @returns The JSON representation of the texture
  18570. */
  18571. serialize(): any;
  18572. /**
  18573. * Get the current class name of the texture useful for serialization or dynamic coding.
  18574. * @returns "Texture"
  18575. */
  18576. getClassName(): string;
  18577. /**
  18578. * Dispose the texture and release its associated resources.
  18579. */
  18580. dispose(): void;
  18581. /**
  18582. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  18583. * @param parsedTexture Define the JSON representation of the texture
  18584. * @param scene Define the scene the parsed texture should be instantiated in
  18585. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  18586. * @returns The parsed texture if successful
  18587. */
  18588. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  18589. /**
  18590. * Creates a texture from its base 64 representation.
  18591. * @param data Define the base64 payload without the data: prefix
  18592. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  18593. * @param scene Define the scene the texture should belong to
  18594. * @param noMipmap Forces the texture to not create mip map information if true
  18595. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18596. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18597. * @param onLoad define a callback triggered when the texture has been loaded
  18598. * @param onError define a callback triggered when an error occurred during the loading session
  18599. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18600. * @returns the created texture
  18601. */
  18602. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  18603. /**
  18604. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  18605. * @param data Define the base64 payload without the data: prefix
  18606. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  18607. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  18608. * @param scene Define the scene the texture should belong to
  18609. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  18610. * @param noMipmap Forces the texture to not create mip map information if true
  18611. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18612. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18613. * @param onLoad define a callback triggered when the texture has been loaded
  18614. * @param onError define a callback triggered when an error occurred during the loading session
  18615. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18616. * @returns the created texture
  18617. */
  18618. 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;
  18619. }
  18620. }
  18621. declare module "babylonjs/Materials/Textures/rawTexture" {
  18622. import { Scene } from "babylonjs/scene";
  18623. import { Texture } from "babylonjs/Materials/Textures/texture";
  18624. /**
  18625. * Raw texture can help creating a texture directly from an array of data.
  18626. * This can be super useful if you either get the data from an uncompressed source or
  18627. * if you wish to create your texture pixel by pixel.
  18628. */
  18629. export class RawTexture extends Texture {
  18630. /**
  18631. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  18632. */
  18633. format: number;
  18634. private _engine;
  18635. /**
  18636. * Instantiates a new RawTexture.
  18637. * Raw texture can help creating a texture directly from an array of data.
  18638. * This can be super useful if you either get the data from an uncompressed source or
  18639. * if you wish to create your texture pixel by pixel.
  18640. * @param data define the array of data to use to create the texture
  18641. * @param width define the width of the texture
  18642. * @param height define the height of the texture
  18643. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  18644. * @param scene define the scene the texture belongs to
  18645. * @param generateMipMaps define whether mip maps should be generated or not
  18646. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18647. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18648. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  18649. */
  18650. constructor(data: ArrayBufferView, width: number, height: number,
  18651. /**
  18652. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  18653. */
  18654. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  18655. /**
  18656. * Updates the texture underlying data.
  18657. * @param data Define the new data of the texture
  18658. */
  18659. update(data: ArrayBufferView): void;
  18660. /**
  18661. * Creates a luminance texture from some data.
  18662. * @param data Define the texture data
  18663. * @param width Define the width of the texture
  18664. * @param height Define the height of the texture
  18665. * @param scene Define the scene the texture belongs to
  18666. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18667. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18668. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18669. * @returns the luminance texture
  18670. */
  18671. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  18672. /**
  18673. * Creates a luminance alpha texture from some data.
  18674. * @param data Define the texture data
  18675. * @param width Define the width of the texture
  18676. * @param height Define the height of the texture
  18677. * @param scene Define the scene the texture belongs to
  18678. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18679. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18680. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18681. * @returns the luminance alpha texture
  18682. */
  18683. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  18684. /**
  18685. * Creates an alpha texture from some data.
  18686. * @param data Define the texture data
  18687. * @param width Define the width of the texture
  18688. * @param height Define the height of the texture
  18689. * @param scene Define the scene the texture belongs to
  18690. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18691. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18692. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18693. * @returns the alpha texture
  18694. */
  18695. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  18696. /**
  18697. * Creates a RGB texture from some data.
  18698. * @param data Define the texture data
  18699. * @param width Define the width of the texture
  18700. * @param height Define the height of the texture
  18701. * @param scene Define the scene the texture belongs to
  18702. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18703. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18704. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18705. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  18706. * @returns the RGB alpha texture
  18707. */
  18708. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  18709. /**
  18710. * Creates a RGBA texture from some data.
  18711. * @param data Define the texture data
  18712. * @param width Define the width of the texture
  18713. * @param height Define the height of the texture
  18714. * @param scene Define the scene the texture belongs to
  18715. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18716. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18717. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18718. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  18719. * @returns the RGBA texture
  18720. */
  18721. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  18722. /**
  18723. * Creates a R texture from some data.
  18724. * @param data Define the texture data
  18725. * @param width Define the width of the texture
  18726. * @param height Define the height of the texture
  18727. * @param scene Define the scene the texture belongs to
  18728. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18729. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18730. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18731. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  18732. * @returns the R texture
  18733. */
  18734. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  18735. }
  18736. }
  18737. declare module "babylonjs/Animations/runtimeAnimation" {
  18738. import { Animation } from "babylonjs/Animations/animation";
  18739. import { Animatable } from "babylonjs/Animations/animatable";
  18740. import { Scene } from "babylonjs/scene";
  18741. /**
  18742. * Defines a runtime animation
  18743. */
  18744. export class RuntimeAnimation {
  18745. private _events;
  18746. /**
  18747. * The current frame of the runtime animation
  18748. */
  18749. private _currentFrame;
  18750. /**
  18751. * The animation used by the runtime animation
  18752. */
  18753. private _animation;
  18754. /**
  18755. * The target of the runtime animation
  18756. */
  18757. private _target;
  18758. /**
  18759. * The initiating animatable
  18760. */
  18761. private _host;
  18762. /**
  18763. * The original value of the runtime animation
  18764. */
  18765. private _originalValue;
  18766. /**
  18767. * The original blend value of the runtime animation
  18768. */
  18769. private _originalBlendValue;
  18770. /**
  18771. * The offsets cache of the runtime animation
  18772. */
  18773. private _offsetsCache;
  18774. /**
  18775. * The high limits cache of the runtime animation
  18776. */
  18777. private _highLimitsCache;
  18778. /**
  18779. * Specifies if the runtime animation has been stopped
  18780. */
  18781. private _stopped;
  18782. /**
  18783. * The blending factor of the runtime animation
  18784. */
  18785. private _blendingFactor;
  18786. /**
  18787. * The BabylonJS scene
  18788. */
  18789. private _scene;
  18790. /**
  18791. * The current value of the runtime animation
  18792. */
  18793. private _currentValue;
  18794. /** @hidden */
  18795. _workValue: any;
  18796. /**
  18797. * The active target of the runtime animation
  18798. */
  18799. private _activeTarget;
  18800. /**
  18801. * The target path of the runtime animation
  18802. */
  18803. private _targetPath;
  18804. /**
  18805. * The weight of the runtime animation
  18806. */
  18807. private _weight;
  18808. /**
  18809. * The ratio offset of the runtime animation
  18810. */
  18811. private _ratioOffset;
  18812. /**
  18813. * The previous delay of the runtime animation
  18814. */
  18815. private _previousDelay;
  18816. /**
  18817. * The previous ratio of the runtime animation
  18818. */
  18819. private _previousRatio;
  18820. private _enableBlending;
  18821. private _correctLoopMode;
  18822. /**
  18823. * Gets the current frame of the runtime animation
  18824. */
  18825. readonly currentFrame: number;
  18826. /**
  18827. * Gets the weight of the runtime animation
  18828. */
  18829. readonly weight: number;
  18830. /**
  18831. * Gets the current value of the runtime animation
  18832. */
  18833. readonly currentValue: any;
  18834. /**
  18835. * Gets the target path of the runtime animation
  18836. */
  18837. readonly targetPath: string;
  18838. /**
  18839. * Gets the actual target of the runtime animation
  18840. */
  18841. readonly target: any;
  18842. /**
  18843. * Create a new RuntimeAnimation object
  18844. * @param target defines the target of the animation
  18845. * @param animation defines the source animation object
  18846. * @param scene defines the hosting scene
  18847. * @param host defines the initiating Animatable
  18848. */
  18849. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  18850. /**
  18851. * Gets the animation from the runtime animation
  18852. */
  18853. readonly animation: Animation;
  18854. /**
  18855. * Resets the runtime animation to the beginning
  18856. * @param restoreOriginal defines whether to restore the target property to the original value
  18857. */
  18858. reset(restoreOriginal?: boolean): void;
  18859. /**
  18860. * Specifies if the runtime animation is stopped
  18861. * @returns Boolean specifying if the runtime animation is stopped
  18862. */
  18863. isStopped(): boolean;
  18864. /**
  18865. * Disposes of the runtime animation
  18866. */
  18867. dispose(): void;
  18868. /**
  18869. * Interpolates the animation from the current frame
  18870. * @param currentFrame The frame to interpolate the animation to
  18871. * @param repeatCount The number of times that the animation should loop
  18872. * @param loopMode The type of looping mode to use
  18873. * @param offsetValue Animation offset value
  18874. * @param highLimitValue The high limit value
  18875. * @returns The interpolated value
  18876. */
  18877. private _interpolate;
  18878. /**
  18879. * Apply the interpolated value to the target
  18880. * @param currentValue defines the value computed by the animation
  18881. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  18882. */
  18883. setValue(currentValue: any, weight?: number): void;
  18884. private _setValue;
  18885. /**
  18886. * Gets the loop pmode of the runtime animation
  18887. * @returns Loop Mode
  18888. */
  18889. private _getCorrectLoopMode;
  18890. /**
  18891. * Move the current animation to a given frame
  18892. * @param frame defines the frame to move to
  18893. */
  18894. goToFrame(frame: number): void;
  18895. /**
  18896. * @hidden Internal use only
  18897. */
  18898. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  18899. /**
  18900. * Execute the current animation
  18901. * @param delay defines the delay to add to the current frame
  18902. * @param from defines the lower bound of the animation range
  18903. * @param to defines the upper bound of the animation range
  18904. * @param loop defines if the current animation must loop
  18905. * @param speedRatio defines the current speed ratio
  18906. * @param weight defines the weight of the animation (default is -1 so no weight)
  18907. * @param onLoop optional callback called when animation loops
  18908. * @returns a boolean indicating if the animation is running
  18909. */
  18910. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number, onLoop?: () => void): boolean;
  18911. }
  18912. }
  18913. declare module "babylonjs/Animations/animatable" {
  18914. import { Animation } from "babylonjs/Animations/animation";
  18915. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  18916. import { Nullable } from "babylonjs/types";
  18917. import { Observable } from "babylonjs/Misc/observable";
  18918. import { Scene } from "babylonjs/scene";
  18919. import { Matrix, Quaternion, Vector3 } from "babylonjs/Maths/math";
  18920. import { Node } from "babylonjs/node";
  18921. /**
  18922. * Class used to store an actual running animation
  18923. */
  18924. export class Animatable {
  18925. /** defines the target object */
  18926. target: any;
  18927. /** defines the starting frame number (default is 0) */
  18928. fromFrame: number;
  18929. /** defines the ending frame number (default is 100) */
  18930. toFrame: number;
  18931. /** defines if the animation must loop (default is false) */
  18932. loopAnimation: boolean;
  18933. /** defines a callback to call when animation ends if it is not looping */
  18934. onAnimationEnd?: (() => void) | null | undefined;
  18935. /** defines a callback to call when animation loops */
  18936. onAnimationLoop?: (() => void) | null | undefined;
  18937. private _localDelayOffset;
  18938. private _pausedDelay;
  18939. private _runtimeAnimations;
  18940. private _paused;
  18941. private _scene;
  18942. private _speedRatio;
  18943. private _weight;
  18944. private _syncRoot;
  18945. /**
  18946. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  18947. * This will only apply for non looping animation (default is true)
  18948. */
  18949. disposeOnEnd: boolean;
  18950. /**
  18951. * Gets a boolean indicating if the animation has started
  18952. */
  18953. animationStarted: boolean;
  18954. /**
  18955. * Observer raised when the animation ends
  18956. */
  18957. onAnimationEndObservable: Observable<Animatable>;
  18958. /**
  18959. * Observer raised when the animation loops
  18960. */
  18961. onAnimationLoopObservable: Observable<Animatable>;
  18962. /**
  18963. * Gets the root Animatable used to synchronize and normalize animations
  18964. */
  18965. readonly syncRoot: Animatable;
  18966. /**
  18967. * Gets the current frame of the first RuntimeAnimation
  18968. * Used to synchronize Animatables
  18969. */
  18970. readonly masterFrame: number;
  18971. /**
  18972. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  18973. */
  18974. weight: number;
  18975. /**
  18976. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  18977. */
  18978. speedRatio: number;
  18979. /**
  18980. * Creates a new Animatable
  18981. * @param scene defines the hosting scene
  18982. * @param target defines the target object
  18983. * @param fromFrame defines the starting frame number (default is 0)
  18984. * @param toFrame defines the ending frame number (default is 100)
  18985. * @param loopAnimation defines if the animation must loop (default is false)
  18986. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  18987. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  18988. * @param animations defines a group of animation to add to the new Animatable
  18989. * @param onAnimationLoop defines a callback to call when animation loops
  18990. */
  18991. constructor(scene: Scene,
  18992. /** defines the target object */
  18993. target: any,
  18994. /** defines the starting frame number (default is 0) */
  18995. fromFrame?: number,
  18996. /** defines the ending frame number (default is 100) */
  18997. toFrame?: number,
  18998. /** defines if the animation must loop (default is false) */
  18999. loopAnimation?: boolean, speedRatio?: number,
  19000. /** defines a callback to call when animation ends if it is not looping */
  19001. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  19002. /** defines a callback to call when animation loops */
  19003. onAnimationLoop?: (() => void) | null | undefined);
  19004. /**
  19005. * Synchronize and normalize current Animatable with a source Animatable
  19006. * This is useful when using animation weights and when animations are not of the same length
  19007. * @param root defines the root Animatable to synchronize with
  19008. * @returns the current Animatable
  19009. */
  19010. syncWith(root: Animatable): Animatable;
  19011. /**
  19012. * Gets the list of runtime animations
  19013. * @returns an array of RuntimeAnimation
  19014. */
  19015. getAnimations(): RuntimeAnimation[];
  19016. /**
  19017. * Adds more animations to the current animatable
  19018. * @param target defines the target of the animations
  19019. * @param animations defines the new animations to add
  19020. */
  19021. appendAnimations(target: any, animations: Animation[]): void;
  19022. /**
  19023. * Gets the source animation for a specific property
  19024. * @param property defines the propertyu to look for
  19025. * @returns null or the source animation for the given property
  19026. */
  19027. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  19028. /**
  19029. * Gets the runtime animation for a specific property
  19030. * @param property defines the propertyu to look for
  19031. * @returns null or the runtime animation for the given property
  19032. */
  19033. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  19034. /**
  19035. * Resets the animatable to its original state
  19036. */
  19037. reset(): void;
  19038. /**
  19039. * Allows the animatable to blend with current running animations
  19040. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  19041. * @param blendingSpeed defines the blending speed to use
  19042. */
  19043. enableBlending(blendingSpeed: number): void;
  19044. /**
  19045. * Disable animation blending
  19046. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  19047. */
  19048. disableBlending(): void;
  19049. /**
  19050. * Jump directly to a given frame
  19051. * @param frame defines the frame to jump to
  19052. */
  19053. goToFrame(frame: number): void;
  19054. /**
  19055. * Pause the animation
  19056. */
  19057. pause(): void;
  19058. /**
  19059. * Restart the animation
  19060. */
  19061. restart(): void;
  19062. private _raiseOnAnimationEnd;
  19063. /**
  19064. * Stop and delete the current animation
  19065. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  19066. * @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)
  19067. */
  19068. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  19069. /**
  19070. * Wait asynchronously for the animation to end
  19071. * @returns a promise which will be fullfilled when the animation ends
  19072. */
  19073. waitAsync(): Promise<Animatable>;
  19074. /** @hidden */
  19075. _animate(delay: number): boolean;
  19076. }
  19077. module "babylonjs/scene" {
  19078. interface Scene {
  19079. /** @hidden */
  19080. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  19081. /** @hidden */
  19082. _processLateAnimationBindingsForMatrices(holder: {
  19083. totalWeight: number;
  19084. animations: RuntimeAnimation[];
  19085. originalValue: Matrix;
  19086. }): any;
  19087. /** @hidden */
  19088. _processLateAnimationBindingsForQuaternions(holder: {
  19089. totalWeight: number;
  19090. animations: RuntimeAnimation[];
  19091. originalValue: Quaternion;
  19092. }, refQuaternion: Quaternion): Quaternion;
  19093. /** @hidden */
  19094. _processLateAnimationBindings(): void;
  19095. /**
  19096. * Will start the animation sequence of a given target
  19097. * @param target defines the target
  19098. * @param from defines from which frame should animation start
  19099. * @param to defines until which frame should animation run.
  19100. * @param weight defines the weight to apply to the animation (1.0 by default)
  19101. * @param loop defines if the animation loops
  19102. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  19103. * @param onAnimationEnd defines the function to be executed when the animation ends
  19104. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  19105. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  19106. * @param onAnimationLoop defines the callback to call when an animation loops
  19107. * @returns the animatable object created for this animation
  19108. */
  19109. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  19110. /**
  19111. * Will start the animation sequence of a given target
  19112. * @param target defines the target
  19113. * @param from defines from which frame should animation start
  19114. * @param to defines until which frame should animation run.
  19115. * @param loop defines if the animation loops
  19116. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  19117. * @param onAnimationEnd defines the function to be executed when the animation ends
  19118. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  19119. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  19120. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  19121. * @param onAnimationLoop defines the callback to call when an animation loops
  19122. * @returns the animatable object created for this animation
  19123. */
  19124. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  19125. /**
  19126. * Will start the animation sequence of a given target and its hierarchy
  19127. * @param target defines the target
  19128. * @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.
  19129. * @param from defines from which frame should animation start
  19130. * @param to defines until which frame should animation run.
  19131. * @param loop defines if the animation loops
  19132. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  19133. * @param onAnimationEnd defines the function to be executed when the animation ends
  19134. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  19135. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  19136. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  19137. * @param onAnimationLoop defines the callback to call when an animation loops
  19138. * @returns the list of created animatables
  19139. */
  19140. 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[];
  19141. /**
  19142. * Begin a new animation on a given node
  19143. * @param target defines the target where the animation will take place
  19144. * @param animations defines the list of animations to start
  19145. * @param from defines the initial value
  19146. * @param to defines the final value
  19147. * @param loop defines if you want animation to loop (off by default)
  19148. * @param speedRatio defines the speed ratio to apply to all animations
  19149. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  19150. * @param onAnimationLoop defines the callback to call when an animation loops
  19151. * @returns the list of created animatables
  19152. */
  19153. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  19154. /**
  19155. * Begin a new animation on a given node and its hierarchy
  19156. * @param target defines the root node where the animation will take place
  19157. * @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.
  19158. * @param animations defines the list of animations to start
  19159. * @param from defines the initial value
  19160. * @param to defines the final value
  19161. * @param loop defines if you want animation to loop (off by default)
  19162. * @param speedRatio defines the speed ratio to apply to all animations
  19163. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  19164. * @param onAnimationLoop defines the callback to call when an animation loops
  19165. * @returns the list of animatables created for all nodes
  19166. */
  19167. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  19168. /**
  19169. * Gets the animatable associated with a specific target
  19170. * @param target defines the target of the animatable
  19171. * @returns the required animatable if found
  19172. */
  19173. getAnimatableByTarget(target: any): Nullable<Animatable>;
  19174. /**
  19175. * Gets all animatables associated with a given target
  19176. * @param target defines the target to look animatables for
  19177. * @returns an array of Animatables
  19178. */
  19179. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  19180. /**
  19181. * Will stop the animation of the given target
  19182. * @param target - the target
  19183. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  19184. * @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)
  19185. */
  19186. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  19187. /**
  19188. * Stops and removes all animations that have been applied to the scene
  19189. */
  19190. stopAllAnimations(): void;
  19191. }
  19192. }
  19193. module "babylonjs/Bones/bone" {
  19194. interface Bone {
  19195. /**
  19196. * Copy an animation range from another bone
  19197. * @param source defines the source bone
  19198. * @param rangeName defines the range name to copy
  19199. * @param frameOffset defines the frame offset
  19200. * @param rescaleAsRequired defines if rescaling must be applied if required
  19201. * @param skelDimensionsRatio defines the scaling ratio
  19202. * @returns true if operation was successful
  19203. */
  19204. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  19205. }
  19206. }
  19207. }
  19208. declare module "babylonjs/Bones/skeleton" {
  19209. import { Bone } from "babylonjs/Bones/bone";
  19210. import { IAnimatable } from "babylonjs/Misc/tools";
  19211. import { Observable } from "babylonjs/Misc/observable";
  19212. import { Vector3, Matrix } from "babylonjs/Maths/math";
  19213. import { Scene } from "babylonjs/scene";
  19214. import { Nullable } from "babylonjs/types";
  19215. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19216. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  19217. import { Animatable } from "babylonjs/Animations/animatable";
  19218. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  19219. import { Animation } from "babylonjs/Animations/animation";
  19220. import { AnimationRange } from "babylonjs/Animations/animationRange";
  19221. import { IInspectable } from "babylonjs/Misc/iInspectable";
  19222. /**
  19223. * Class used to handle skinning animations
  19224. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  19225. */
  19226. export class Skeleton implements IAnimatable {
  19227. /** defines the skeleton name */
  19228. name: string;
  19229. /** defines the skeleton Id */
  19230. id: string;
  19231. /**
  19232. * Defines the list of child bones
  19233. */
  19234. bones: Bone[];
  19235. /**
  19236. * Defines an estimate of the dimension of the skeleton at rest
  19237. */
  19238. dimensionsAtRest: Vector3;
  19239. /**
  19240. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  19241. */
  19242. needInitialSkinMatrix: boolean;
  19243. /**
  19244. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  19245. */
  19246. overrideMesh: Nullable<AbstractMesh>;
  19247. /**
  19248. * Gets the list of animations attached to this skeleton
  19249. */
  19250. animations: Array<Animation>;
  19251. private _scene;
  19252. private _isDirty;
  19253. private _transformMatrices;
  19254. private _transformMatrixTexture;
  19255. private _meshesWithPoseMatrix;
  19256. private _animatables;
  19257. private _identity;
  19258. private _synchronizedWithMesh;
  19259. private _ranges;
  19260. private _lastAbsoluteTransformsUpdateId;
  19261. private _canUseTextureForBones;
  19262. private _uniqueId;
  19263. /** @hidden */
  19264. _numBonesWithLinkedTransformNode: number;
  19265. /**
  19266. * Specifies if the skeleton should be serialized
  19267. */
  19268. doNotSerialize: boolean;
  19269. private _useTextureToStoreBoneMatrices;
  19270. /**
  19271. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  19272. * Please note that this option is not available when needInitialSkinMatrix === true or if the hardware does not support it
  19273. */
  19274. useTextureToStoreBoneMatrices: boolean;
  19275. private _animationPropertiesOverride;
  19276. /**
  19277. * Gets or sets the animation properties override
  19278. */
  19279. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  19280. /**
  19281. * List of inspectable custom properties (used by the Inspector)
  19282. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  19283. */
  19284. inspectableCustomProperties: IInspectable[];
  19285. /**
  19286. * An observable triggered before computing the skeleton's matrices
  19287. */
  19288. onBeforeComputeObservable: Observable<Skeleton>;
  19289. /**
  19290. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  19291. */
  19292. readonly isUsingTextureForMatrices: boolean;
  19293. /**
  19294. * Gets the unique ID of this skeleton
  19295. */
  19296. readonly uniqueId: number;
  19297. /**
  19298. * Creates a new skeleton
  19299. * @param name defines the skeleton name
  19300. * @param id defines the skeleton Id
  19301. * @param scene defines the hosting scene
  19302. */
  19303. constructor(
  19304. /** defines the skeleton name */
  19305. name: string,
  19306. /** defines the skeleton Id */
  19307. id: string, scene: Scene);
  19308. /**
  19309. * Gets the current object class name.
  19310. * @return the class name
  19311. */
  19312. getClassName(): string;
  19313. /**
  19314. * Returns an array containing the root bones
  19315. * @returns an array containing the root bones
  19316. */
  19317. getChildren(): Array<Bone>;
  19318. /**
  19319. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  19320. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  19321. * @returns a Float32Array containing matrices data
  19322. */
  19323. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  19324. /**
  19325. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  19326. * @returns a raw texture containing the data
  19327. */
  19328. getTransformMatrixTexture(): Nullable<RawTexture>;
  19329. /**
  19330. * Gets the current hosting scene
  19331. * @returns a scene object
  19332. */
  19333. getScene(): Scene;
  19334. /**
  19335. * Gets a string representing the current skeleton data
  19336. * @param fullDetails defines a boolean indicating if we want a verbose version
  19337. * @returns a string representing the current skeleton data
  19338. */
  19339. toString(fullDetails?: boolean): string;
  19340. /**
  19341. * Get bone's index searching by name
  19342. * @param name defines bone's name to search for
  19343. * @return the indice of the bone. Returns -1 if not found
  19344. */
  19345. getBoneIndexByName(name: string): number;
  19346. /**
  19347. * Creater a new animation range
  19348. * @param name defines the name of the range
  19349. * @param from defines the start key
  19350. * @param to defines the end key
  19351. */
  19352. createAnimationRange(name: string, from: number, to: number): void;
  19353. /**
  19354. * Delete a specific animation range
  19355. * @param name defines the name of the range
  19356. * @param deleteFrames defines if frames must be removed as well
  19357. */
  19358. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  19359. /**
  19360. * Gets a specific animation range
  19361. * @param name defines the name of the range to look for
  19362. * @returns the requested animation range or null if not found
  19363. */
  19364. getAnimationRange(name: string): Nullable<AnimationRange>;
  19365. /**
  19366. * Gets the list of all animation ranges defined on this skeleton
  19367. * @returns an array
  19368. */
  19369. getAnimationRanges(): Nullable<AnimationRange>[];
  19370. /**
  19371. * Copy animation range from a source skeleton.
  19372. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  19373. * @param source defines the source skeleton
  19374. * @param name defines the name of the range to copy
  19375. * @param rescaleAsRequired defines if rescaling must be applied if required
  19376. * @returns true if operation was successful
  19377. */
  19378. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  19379. /**
  19380. * Forces the skeleton to go to rest pose
  19381. */
  19382. returnToRest(): void;
  19383. private _getHighestAnimationFrame;
  19384. /**
  19385. * Begin a specific animation range
  19386. * @param name defines the name of the range to start
  19387. * @param loop defines if looping must be turned on (false by default)
  19388. * @param speedRatio defines the speed ratio to apply (1 by default)
  19389. * @param onAnimationEnd defines a callback which will be called when animation will end
  19390. * @returns a new animatable
  19391. */
  19392. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  19393. /** @hidden */
  19394. _markAsDirty(): void;
  19395. /** @hidden */
  19396. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  19397. /** @hidden */
  19398. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  19399. private _computeTransformMatrices;
  19400. /**
  19401. * Build all resources required to render a skeleton
  19402. */
  19403. prepare(): void;
  19404. /**
  19405. * Gets the list of animatables currently running for this skeleton
  19406. * @returns an array of animatables
  19407. */
  19408. getAnimatables(): IAnimatable[];
  19409. /**
  19410. * Clone the current skeleton
  19411. * @param name defines the name of the new skeleton
  19412. * @param id defines the id of the enw skeleton
  19413. * @returns the new skeleton
  19414. */
  19415. clone(name: string, id: string): Skeleton;
  19416. /**
  19417. * Enable animation blending for this skeleton
  19418. * @param blendingSpeed defines the blending speed to apply
  19419. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  19420. */
  19421. enableBlending(blendingSpeed?: number): void;
  19422. /**
  19423. * Releases all resources associated with the current skeleton
  19424. */
  19425. dispose(): void;
  19426. /**
  19427. * Serialize the skeleton in a JSON object
  19428. * @returns a JSON object
  19429. */
  19430. serialize(): any;
  19431. /**
  19432. * Creates a new skeleton from serialized data
  19433. * @param parsedSkeleton defines the serialized data
  19434. * @param scene defines the hosting scene
  19435. * @returns a new skeleton
  19436. */
  19437. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  19438. /**
  19439. * Compute all node absolute transforms
  19440. * @param forceUpdate defines if computation must be done even if cache is up to date
  19441. */
  19442. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  19443. /**
  19444. * Gets the root pose matrix
  19445. * @returns a matrix
  19446. */
  19447. getPoseMatrix(): Nullable<Matrix>;
  19448. /**
  19449. * Sorts bones per internal index
  19450. */
  19451. sortBones(): void;
  19452. private _sortBones;
  19453. }
  19454. }
  19455. declare module "babylonjs/Morph/morphTarget" {
  19456. import { IAnimatable } from "babylonjs/Misc/tools";
  19457. import { Observable } from "babylonjs/Misc/observable";
  19458. import { Nullable, FloatArray } from "babylonjs/types";
  19459. import { Scene } from "babylonjs/scene";
  19460. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19461. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  19462. /**
  19463. * Defines a target to use with MorphTargetManager
  19464. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  19465. */
  19466. export class MorphTarget implements IAnimatable {
  19467. /** defines the name of the target */
  19468. name: string;
  19469. /**
  19470. * Gets or sets the list of animations
  19471. */
  19472. animations: import("babylonjs/Animations/animation").Animation[];
  19473. private _scene;
  19474. private _positions;
  19475. private _normals;
  19476. private _tangents;
  19477. private _influence;
  19478. /**
  19479. * Observable raised when the influence changes
  19480. */
  19481. onInfluenceChanged: Observable<boolean>;
  19482. /** @hidden */
  19483. _onDataLayoutChanged: Observable<void>;
  19484. /**
  19485. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  19486. */
  19487. influence: number;
  19488. /**
  19489. * Gets or sets the id of the morph Target
  19490. */
  19491. id: string;
  19492. private _animationPropertiesOverride;
  19493. /**
  19494. * Gets or sets the animation properties override
  19495. */
  19496. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  19497. /**
  19498. * Creates a new MorphTarget
  19499. * @param name defines the name of the target
  19500. * @param influence defines the influence to use
  19501. * @param scene defines the scene the morphtarget belongs to
  19502. */
  19503. constructor(
  19504. /** defines the name of the target */
  19505. name: string, influence?: number, scene?: Nullable<Scene>);
  19506. /**
  19507. * Gets a boolean defining if the target contains position data
  19508. */
  19509. readonly hasPositions: boolean;
  19510. /**
  19511. * Gets a boolean defining if the target contains normal data
  19512. */
  19513. readonly hasNormals: boolean;
  19514. /**
  19515. * Gets a boolean defining if the target contains tangent data
  19516. */
  19517. readonly hasTangents: boolean;
  19518. /**
  19519. * Affects position data to this target
  19520. * @param data defines the position data to use
  19521. */
  19522. setPositions(data: Nullable<FloatArray>): void;
  19523. /**
  19524. * Gets the position data stored in this target
  19525. * @returns a FloatArray containing the position data (or null if not present)
  19526. */
  19527. getPositions(): Nullable<FloatArray>;
  19528. /**
  19529. * Affects normal data to this target
  19530. * @param data defines the normal data to use
  19531. */
  19532. setNormals(data: Nullable<FloatArray>): void;
  19533. /**
  19534. * Gets the normal data stored in this target
  19535. * @returns a FloatArray containing the normal data (or null if not present)
  19536. */
  19537. getNormals(): Nullable<FloatArray>;
  19538. /**
  19539. * Affects tangent data to this target
  19540. * @param data defines the tangent data to use
  19541. */
  19542. setTangents(data: Nullable<FloatArray>): void;
  19543. /**
  19544. * Gets the tangent data stored in this target
  19545. * @returns a FloatArray containing the tangent data (or null if not present)
  19546. */
  19547. getTangents(): Nullable<FloatArray>;
  19548. /**
  19549. * Serializes the current target into a Serialization object
  19550. * @returns the serialized object
  19551. */
  19552. serialize(): any;
  19553. /**
  19554. * Returns the string "MorphTarget"
  19555. * @returns "MorphTarget"
  19556. */
  19557. getClassName(): string;
  19558. /**
  19559. * Creates a new target from serialized data
  19560. * @param serializationObject defines the serialized data to use
  19561. * @returns a new MorphTarget
  19562. */
  19563. static Parse(serializationObject: any): MorphTarget;
  19564. /**
  19565. * Creates a MorphTarget from mesh data
  19566. * @param mesh defines the source mesh
  19567. * @param name defines the name to use for the new target
  19568. * @param influence defines the influence to attach to the target
  19569. * @returns a new MorphTarget
  19570. */
  19571. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  19572. }
  19573. }
  19574. declare module "babylonjs/Morph/morphTargetManager" {
  19575. import { Nullable } from "babylonjs/types";
  19576. import { Scene } from "babylonjs/scene";
  19577. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  19578. /**
  19579. * This class is used to deform meshes using morphing between different targets
  19580. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  19581. */
  19582. export class MorphTargetManager {
  19583. private _targets;
  19584. private _targetInfluenceChangedObservers;
  19585. private _targetDataLayoutChangedObservers;
  19586. private _activeTargets;
  19587. private _scene;
  19588. private _influences;
  19589. private _supportsNormals;
  19590. private _supportsTangents;
  19591. private _vertexCount;
  19592. private _uniqueId;
  19593. private _tempInfluences;
  19594. /**
  19595. * Creates a new MorphTargetManager
  19596. * @param scene defines the current scene
  19597. */
  19598. constructor(scene?: Nullable<Scene>);
  19599. /**
  19600. * Gets the unique ID of this manager
  19601. */
  19602. readonly uniqueId: number;
  19603. /**
  19604. * Gets the number of vertices handled by this manager
  19605. */
  19606. readonly vertexCount: number;
  19607. /**
  19608. * Gets a boolean indicating if this manager supports morphing of normals
  19609. */
  19610. readonly supportsNormals: boolean;
  19611. /**
  19612. * Gets a boolean indicating if this manager supports morphing of tangents
  19613. */
  19614. readonly supportsTangents: boolean;
  19615. /**
  19616. * Gets the number of targets stored in this manager
  19617. */
  19618. readonly numTargets: number;
  19619. /**
  19620. * Gets the number of influencers (ie. the number of targets with influences > 0)
  19621. */
  19622. readonly numInfluencers: number;
  19623. /**
  19624. * Gets the list of influences (one per target)
  19625. */
  19626. readonly influences: Float32Array;
  19627. /**
  19628. * Gets the active target at specified index. An active target is a target with an influence > 0
  19629. * @param index defines the index to check
  19630. * @returns the requested target
  19631. */
  19632. getActiveTarget(index: number): MorphTarget;
  19633. /**
  19634. * Gets the target at specified index
  19635. * @param index defines the index to check
  19636. * @returns the requested target
  19637. */
  19638. getTarget(index: number): MorphTarget;
  19639. /**
  19640. * Add a new target to this manager
  19641. * @param target defines the target to add
  19642. */
  19643. addTarget(target: MorphTarget): void;
  19644. /**
  19645. * Removes a target from the manager
  19646. * @param target defines the target to remove
  19647. */
  19648. removeTarget(target: MorphTarget): void;
  19649. /**
  19650. * Serializes the current manager into a Serialization object
  19651. * @returns the serialized object
  19652. */
  19653. serialize(): any;
  19654. private _syncActiveTargets;
  19655. /**
  19656. * Syncrhonize the targets with all the meshes using this morph target manager
  19657. */
  19658. synchronize(): void;
  19659. /**
  19660. * Creates a new MorphTargetManager from serialized data
  19661. * @param serializationObject defines the serialized data
  19662. * @param scene defines the hosting scene
  19663. * @returns the new MorphTargetManager
  19664. */
  19665. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  19666. }
  19667. }
  19668. declare module "babylonjs/Meshes/groundMesh" {
  19669. import { Scene } from "babylonjs/scene";
  19670. import { Vector3 } from "babylonjs/Maths/math";
  19671. import { Mesh } from "babylonjs/Meshes/mesh";
  19672. /**
  19673. * Mesh representing the gorund
  19674. */
  19675. export class GroundMesh extends Mesh {
  19676. /** If octree should be generated */
  19677. generateOctree: boolean;
  19678. private _heightQuads;
  19679. /** @hidden */
  19680. _subdivisionsX: number;
  19681. /** @hidden */
  19682. _subdivisionsY: number;
  19683. /** @hidden */
  19684. _width: number;
  19685. /** @hidden */
  19686. _height: number;
  19687. /** @hidden */
  19688. _minX: number;
  19689. /** @hidden */
  19690. _maxX: number;
  19691. /** @hidden */
  19692. _minZ: number;
  19693. /** @hidden */
  19694. _maxZ: number;
  19695. constructor(name: string, scene: Scene);
  19696. /**
  19697. * "GroundMesh"
  19698. * @returns "GroundMesh"
  19699. */
  19700. getClassName(): string;
  19701. /**
  19702. * The minimum of x and y subdivisions
  19703. */
  19704. readonly subdivisions: number;
  19705. /**
  19706. * X subdivisions
  19707. */
  19708. readonly subdivisionsX: number;
  19709. /**
  19710. * Y subdivisions
  19711. */
  19712. readonly subdivisionsY: number;
  19713. /**
  19714. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  19715. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  19716. * @param chunksCount the number of subdivisions for x and y
  19717. * @param octreeBlocksSize (Default: 32)
  19718. */
  19719. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  19720. /**
  19721. * Returns a height (y) value in the Worl system :
  19722. * the ground altitude at the coordinates (x, z) expressed in the World system.
  19723. * @param x x coordinate
  19724. * @param z z coordinate
  19725. * @returns the ground y position if (x, z) are outside the ground surface.
  19726. */
  19727. getHeightAtCoordinates(x: number, z: number): number;
  19728. /**
  19729. * Returns a normalized vector (Vector3) orthogonal to the ground
  19730. * at the ground coordinates (x, z) expressed in the World system.
  19731. * @param x x coordinate
  19732. * @param z z coordinate
  19733. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  19734. */
  19735. getNormalAtCoordinates(x: number, z: number): Vector3;
  19736. /**
  19737. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  19738. * at the ground coordinates (x, z) expressed in the World system.
  19739. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  19740. * @param x x coordinate
  19741. * @param z z coordinate
  19742. * @param ref vector to store the result
  19743. * @returns the GroundMesh.
  19744. */
  19745. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  19746. /**
  19747. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  19748. * if the ground has been updated.
  19749. * This can be used in the render loop.
  19750. * @returns the GroundMesh.
  19751. */
  19752. updateCoordinateHeights(): GroundMesh;
  19753. private _getFacetAt;
  19754. private _initHeightQuads;
  19755. private _computeHeightQuads;
  19756. /**
  19757. * Serializes this ground mesh
  19758. * @param serializationObject object to write serialization to
  19759. */
  19760. serialize(serializationObject: any): void;
  19761. /**
  19762. * Parses a serialized ground mesh
  19763. * @param parsedMesh the serialized mesh
  19764. * @param scene the scene to create the ground mesh in
  19765. * @returns the created ground mesh
  19766. */
  19767. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  19768. }
  19769. }
  19770. declare module "babylonjs/Physics/physicsJoint" {
  19771. import { Vector3 } from "babylonjs/Maths/math";
  19772. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  19773. /**
  19774. * Interface for Physics-Joint data
  19775. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19776. */
  19777. export interface PhysicsJointData {
  19778. /**
  19779. * The main pivot of the joint
  19780. */
  19781. mainPivot?: Vector3;
  19782. /**
  19783. * The connected pivot of the joint
  19784. */
  19785. connectedPivot?: Vector3;
  19786. /**
  19787. * The main axis of the joint
  19788. */
  19789. mainAxis?: Vector3;
  19790. /**
  19791. * The connected axis of the joint
  19792. */
  19793. connectedAxis?: Vector3;
  19794. /**
  19795. * The collision of the joint
  19796. */
  19797. collision?: boolean;
  19798. /**
  19799. * Native Oimo/Cannon/Energy data
  19800. */
  19801. nativeParams?: any;
  19802. }
  19803. /**
  19804. * This is a holder class for the physics joint created by the physics plugin
  19805. * It holds a set of functions to control the underlying joint
  19806. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19807. */
  19808. export class PhysicsJoint {
  19809. /**
  19810. * The type of the physics joint
  19811. */
  19812. type: number;
  19813. /**
  19814. * The data for the physics joint
  19815. */
  19816. jointData: PhysicsJointData;
  19817. private _physicsJoint;
  19818. protected _physicsPlugin: IPhysicsEnginePlugin;
  19819. /**
  19820. * Initializes the physics joint
  19821. * @param type The type of the physics joint
  19822. * @param jointData The data for the physics joint
  19823. */
  19824. constructor(
  19825. /**
  19826. * The type of the physics joint
  19827. */
  19828. type: number,
  19829. /**
  19830. * The data for the physics joint
  19831. */
  19832. jointData: PhysicsJointData);
  19833. /**
  19834. * Gets the physics joint
  19835. */
  19836. /**
  19837. * Sets the physics joint
  19838. */
  19839. physicsJoint: any;
  19840. /**
  19841. * Sets the physics plugin
  19842. */
  19843. physicsPlugin: IPhysicsEnginePlugin;
  19844. /**
  19845. * Execute a function that is physics-plugin specific.
  19846. * @param {Function} func the function that will be executed.
  19847. * It accepts two parameters: the physics world and the physics joint
  19848. */
  19849. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  19850. /**
  19851. * Distance-Joint type
  19852. */
  19853. static DistanceJoint: number;
  19854. /**
  19855. * Hinge-Joint type
  19856. */
  19857. static HingeJoint: number;
  19858. /**
  19859. * Ball-and-Socket joint type
  19860. */
  19861. static BallAndSocketJoint: number;
  19862. /**
  19863. * Wheel-Joint type
  19864. */
  19865. static WheelJoint: number;
  19866. /**
  19867. * Slider-Joint type
  19868. */
  19869. static SliderJoint: number;
  19870. /**
  19871. * Prismatic-Joint type
  19872. */
  19873. static PrismaticJoint: number;
  19874. /**
  19875. * Universal-Joint type
  19876. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  19877. */
  19878. static UniversalJoint: number;
  19879. /**
  19880. * Hinge-Joint 2 type
  19881. */
  19882. static Hinge2Joint: number;
  19883. /**
  19884. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  19885. */
  19886. static PointToPointJoint: number;
  19887. /**
  19888. * Spring-Joint type
  19889. */
  19890. static SpringJoint: number;
  19891. /**
  19892. * Lock-Joint type
  19893. */
  19894. static LockJoint: number;
  19895. }
  19896. /**
  19897. * A class representing a physics distance joint
  19898. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19899. */
  19900. export class DistanceJoint extends PhysicsJoint {
  19901. /**
  19902. *
  19903. * @param jointData The data for the Distance-Joint
  19904. */
  19905. constructor(jointData: DistanceJointData);
  19906. /**
  19907. * Update the predefined distance.
  19908. * @param maxDistance The maximum preferred distance
  19909. * @param minDistance The minimum preferred distance
  19910. */
  19911. updateDistance(maxDistance: number, minDistance?: number): void;
  19912. }
  19913. /**
  19914. * Represents a Motor-Enabled Joint
  19915. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19916. */
  19917. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  19918. /**
  19919. * Initializes the Motor-Enabled Joint
  19920. * @param type The type of the joint
  19921. * @param jointData The physica joint data for the joint
  19922. */
  19923. constructor(type: number, jointData: PhysicsJointData);
  19924. /**
  19925. * Set the motor values.
  19926. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19927. * @param force the force to apply
  19928. * @param maxForce max force for this motor.
  19929. */
  19930. setMotor(force?: number, maxForce?: number): void;
  19931. /**
  19932. * Set the motor's limits.
  19933. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19934. * @param upperLimit The upper limit of the motor
  19935. * @param lowerLimit The lower limit of the motor
  19936. */
  19937. setLimit(upperLimit: number, lowerLimit?: number): void;
  19938. }
  19939. /**
  19940. * This class represents a single physics Hinge-Joint
  19941. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19942. */
  19943. export class HingeJoint extends MotorEnabledJoint {
  19944. /**
  19945. * Initializes the Hinge-Joint
  19946. * @param jointData The joint data for the Hinge-Joint
  19947. */
  19948. constructor(jointData: PhysicsJointData);
  19949. /**
  19950. * Set the motor values.
  19951. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19952. * @param {number} force the force to apply
  19953. * @param {number} maxForce max force for this motor.
  19954. */
  19955. setMotor(force?: number, maxForce?: number): void;
  19956. /**
  19957. * Set the motor's limits.
  19958. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19959. * @param upperLimit The upper limit of the motor
  19960. * @param lowerLimit The lower limit of the motor
  19961. */
  19962. setLimit(upperLimit: number, lowerLimit?: number): void;
  19963. }
  19964. /**
  19965. * This class represents a dual hinge physics joint (same as wheel joint)
  19966. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19967. */
  19968. export class Hinge2Joint extends MotorEnabledJoint {
  19969. /**
  19970. * Initializes the Hinge2-Joint
  19971. * @param jointData The joint data for the Hinge2-Joint
  19972. */
  19973. constructor(jointData: PhysicsJointData);
  19974. /**
  19975. * Set the motor values.
  19976. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19977. * @param {number} targetSpeed the speed the motor is to reach
  19978. * @param {number} maxForce max force for this motor.
  19979. * @param {motorIndex} the motor's index, 0 or 1.
  19980. */
  19981. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  19982. /**
  19983. * Set the motor limits.
  19984. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19985. * @param {number} upperLimit the upper limit
  19986. * @param {number} lowerLimit lower limit
  19987. * @param {motorIndex} the motor's index, 0 or 1.
  19988. */
  19989. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  19990. }
  19991. /**
  19992. * Interface for a motor enabled joint
  19993. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19994. */
  19995. export interface IMotorEnabledJoint {
  19996. /**
  19997. * Physics joint
  19998. */
  19999. physicsJoint: any;
  20000. /**
  20001. * Sets the motor of the motor-enabled joint
  20002. * @param force The force of the motor
  20003. * @param maxForce The maximum force of the motor
  20004. * @param motorIndex The index of the motor
  20005. */
  20006. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  20007. /**
  20008. * Sets the limit of the motor
  20009. * @param upperLimit The upper limit of the motor
  20010. * @param lowerLimit The lower limit of the motor
  20011. * @param motorIndex The index of the motor
  20012. */
  20013. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  20014. }
  20015. /**
  20016. * Joint data for a Distance-Joint
  20017. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20018. */
  20019. export interface DistanceJointData extends PhysicsJointData {
  20020. /**
  20021. * Max distance the 2 joint objects can be apart
  20022. */
  20023. maxDistance: number;
  20024. }
  20025. /**
  20026. * Joint data from a spring joint
  20027. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20028. */
  20029. export interface SpringJointData extends PhysicsJointData {
  20030. /**
  20031. * Length of the spring
  20032. */
  20033. length: number;
  20034. /**
  20035. * Stiffness of the spring
  20036. */
  20037. stiffness: number;
  20038. /**
  20039. * Damping of the spring
  20040. */
  20041. damping: number;
  20042. /** this callback will be called when applying the force to the impostors. */
  20043. forceApplicationCallback: () => void;
  20044. }
  20045. }
  20046. declare module "babylonjs/Physics/physicsRaycastResult" {
  20047. import { Vector3 } from "babylonjs/Maths/math";
  20048. /**
  20049. * Holds the data for the raycast result
  20050. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20051. */
  20052. export class PhysicsRaycastResult {
  20053. private _hasHit;
  20054. private _hitDistance;
  20055. private _hitNormalWorld;
  20056. private _hitPointWorld;
  20057. private _rayFromWorld;
  20058. private _rayToWorld;
  20059. /**
  20060. * Gets if there was a hit
  20061. */
  20062. readonly hasHit: boolean;
  20063. /**
  20064. * Gets the distance from the hit
  20065. */
  20066. readonly hitDistance: number;
  20067. /**
  20068. * Gets the hit normal/direction in the world
  20069. */
  20070. readonly hitNormalWorld: Vector3;
  20071. /**
  20072. * Gets the hit point in the world
  20073. */
  20074. readonly hitPointWorld: Vector3;
  20075. /**
  20076. * Gets the ray "start point" of the ray in the world
  20077. */
  20078. readonly rayFromWorld: Vector3;
  20079. /**
  20080. * Gets the ray "end point" of the ray in the world
  20081. */
  20082. readonly rayToWorld: Vector3;
  20083. /**
  20084. * Sets the hit data (normal & point in world space)
  20085. * @param hitNormalWorld defines the normal in world space
  20086. * @param hitPointWorld defines the point in world space
  20087. */
  20088. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  20089. /**
  20090. * Sets the distance from the start point to the hit point
  20091. * @param distance
  20092. */
  20093. setHitDistance(distance: number): void;
  20094. /**
  20095. * Calculates the distance manually
  20096. */
  20097. calculateHitDistance(): void;
  20098. /**
  20099. * Resets all the values to default
  20100. * @param from The from point on world space
  20101. * @param to The to point on world space
  20102. */
  20103. reset(from?: Vector3, to?: Vector3): void;
  20104. }
  20105. /**
  20106. * Interface for the size containing width and height
  20107. */
  20108. interface IXYZ {
  20109. /**
  20110. * X
  20111. */
  20112. x: number;
  20113. /**
  20114. * Y
  20115. */
  20116. y: number;
  20117. /**
  20118. * Z
  20119. */
  20120. z: number;
  20121. }
  20122. }
  20123. declare module "babylonjs/Physics/IPhysicsEngine" {
  20124. import { Nullable } from "babylonjs/types";
  20125. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  20126. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20127. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  20128. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  20129. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  20130. /**
  20131. * Interface used to describe a physics joint
  20132. */
  20133. export interface PhysicsImpostorJoint {
  20134. /** Defines the main impostor to which the joint is linked */
  20135. mainImpostor: PhysicsImpostor;
  20136. /** Defines the impostor that is connected to the main impostor using this joint */
  20137. connectedImpostor: PhysicsImpostor;
  20138. /** Defines the joint itself */
  20139. joint: PhysicsJoint;
  20140. }
  20141. /** @hidden */
  20142. export interface IPhysicsEnginePlugin {
  20143. world: any;
  20144. name: string;
  20145. setGravity(gravity: Vector3): void;
  20146. setTimeStep(timeStep: number): void;
  20147. getTimeStep(): number;
  20148. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  20149. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  20150. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  20151. generatePhysicsBody(impostor: PhysicsImpostor): void;
  20152. removePhysicsBody(impostor: PhysicsImpostor): void;
  20153. generateJoint(joint: PhysicsImpostorJoint): void;
  20154. removeJoint(joint: PhysicsImpostorJoint): void;
  20155. isSupported(): boolean;
  20156. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  20157. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  20158. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  20159. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  20160. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  20161. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  20162. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  20163. getBodyMass(impostor: PhysicsImpostor): number;
  20164. getBodyFriction(impostor: PhysicsImpostor): number;
  20165. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  20166. getBodyRestitution(impostor: PhysicsImpostor): number;
  20167. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  20168. getBodyPressure?(impostor: PhysicsImpostor): number;
  20169. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  20170. getBodyStiffness?(impostor: PhysicsImpostor): number;
  20171. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  20172. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  20173. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  20174. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  20175. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  20176. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  20177. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  20178. sleepBody(impostor: PhysicsImpostor): void;
  20179. wakeUpBody(impostor: PhysicsImpostor): void;
  20180. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  20181. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  20182. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  20183. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  20184. getRadius(impostor: PhysicsImpostor): number;
  20185. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  20186. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  20187. dispose(): void;
  20188. }
  20189. /**
  20190. * Interface used to define a physics engine
  20191. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  20192. */
  20193. export interface IPhysicsEngine {
  20194. /**
  20195. * Gets the gravity vector used by the simulation
  20196. */
  20197. gravity: Vector3;
  20198. /**
  20199. * Sets the gravity vector used by the simulation
  20200. * @param gravity defines the gravity vector to use
  20201. */
  20202. setGravity(gravity: Vector3): void;
  20203. /**
  20204. * Set the time step of the physics engine.
  20205. * Default is 1/60.
  20206. * To slow it down, enter 1/600 for example.
  20207. * To speed it up, 1/30
  20208. * @param newTimeStep the new timestep to apply to this world.
  20209. */
  20210. setTimeStep(newTimeStep: number): void;
  20211. /**
  20212. * Get the time step of the physics engine.
  20213. * @returns the current time step
  20214. */
  20215. getTimeStep(): number;
  20216. /**
  20217. * Release all resources
  20218. */
  20219. dispose(): void;
  20220. /**
  20221. * Gets the name of the current physics plugin
  20222. * @returns the name of the plugin
  20223. */
  20224. getPhysicsPluginName(): string;
  20225. /**
  20226. * Adding a new impostor for the impostor tracking.
  20227. * This will be done by the impostor itself.
  20228. * @param impostor the impostor to add
  20229. */
  20230. addImpostor(impostor: PhysicsImpostor): void;
  20231. /**
  20232. * Remove an impostor from the engine.
  20233. * This impostor and its mesh will not longer be updated by the physics engine.
  20234. * @param impostor the impostor to remove
  20235. */
  20236. removeImpostor(impostor: PhysicsImpostor): void;
  20237. /**
  20238. * Add a joint to the physics engine
  20239. * @param mainImpostor defines the main impostor to which the joint is added.
  20240. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  20241. * @param joint defines the joint that will connect both impostors.
  20242. */
  20243. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  20244. /**
  20245. * Removes a joint from the simulation
  20246. * @param mainImpostor defines the impostor used with the joint
  20247. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  20248. * @param joint defines the joint to remove
  20249. */
  20250. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  20251. /**
  20252. * Gets the current plugin used to run the simulation
  20253. * @returns current plugin
  20254. */
  20255. getPhysicsPlugin(): IPhysicsEnginePlugin;
  20256. /**
  20257. * Gets the list of physic impostors
  20258. * @returns an array of PhysicsImpostor
  20259. */
  20260. getImpostors(): Array<PhysicsImpostor>;
  20261. /**
  20262. * Gets the impostor for a physics enabled object
  20263. * @param object defines the object impersonated by the impostor
  20264. * @returns the PhysicsImpostor or null if not found
  20265. */
  20266. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  20267. /**
  20268. * Gets the impostor for a physics body object
  20269. * @param body defines physics body used by the impostor
  20270. * @returns the PhysicsImpostor or null if not found
  20271. */
  20272. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  20273. /**
  20274. * Does a raycast in the physics world
  20275. * @param from when should the ray start?
  20276. * @param to when should the ray end?
  20277. * @returns PhysicsRaycastResult
  20278. */
  20279. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  20280. /**
  20281. * Called by the scene. No need to call it.
  20282. * @param delta defines the timespam between frames
  20283. */
  20284. _step(delta: number): void;
  20285. }
  20286. }
  20287. declare module "babylonjs/Physics/physicsImpostor" {
  20288. import { Nullable, IndicesArray } from "babylonjs/types";
  20289. import { Vector3, Matrix, Quaternion, Space } from "babylonjs/Maths/math";
  20290. import { TransformNode } from "babylonjs/Meshes/transformNode";
  20291. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20292. import { Scene } from "babylonjs/scene";
  20293. import { Bone } from "babylonjs/Bones/bone";
  20294. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  20295. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  20296. /**
  20297. * The interface for the physics imposter parameters
  20298. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20299. */
  20300. export interface PhysicsImpostorParameters {
  20301. /**
  20302. * The mass of the physics imposter
  20303. */
  20304. mass: number;
  20305. /**
  20306. * The friction of the physics imposter
  20307. */
  20308. friction?: number;
  20309. /**
  20310. * The coefficient of restitution of the physics imposter
  20311. */
  20312. restitution?: number;
  20313. /**
  20314. * The native options of the physics imposter
  20315. */
  20316. nativeOptions?: any;
  20317. /**
  20318. * Specifies if the parent should be ignored
  20319. */
  20320. ignoreParent?: boolean;
  20321. /**
  20322. * Specifies if bi-directional transformations should be disabled
  20323. */
  20324. disableBidirectionalTransformation?: boolean;
  20325. /**
  20326. * The pressure inside the physics imposter, soft object only
  20327. */
  20328. pressure?: number;
  20329. /**
  20330. * The stiffness the physics imposter, soft object only
  20331. */
  20332. stiffness?: number;
  20333. /**
  20334. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  20335. */
  20336. velocityIterations?: number;
  20337. /**
  20338. * The number of iterations used in maintaining consistent vertex positions, soft object only
  20339. */
  20340. positionIterations?: number;
  20341. /**
  20342. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  20343. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  20344. * Add to fix multiple points
  20345. */
  20346. fixedPoints?: number;
  20347. /**
  20348. * The collision margin around a soft object
  20349. */
  20350. margin?: number;
  20351. /**
  20352. * The collision margin around a soft object
  20353. */
  20354. damping?: number;
  20355. /**
  20356. * The path for a rope based on an extrusion
  20357. */
  20358. path?: any;
  20359. /**
  20360. * The shape of an extrusion used for a rope based on an extrusion
  20361. */
  20362. shape?: any;
  20363. }
  20364. /**
  20365. * Interface for a physics-enabled object
  20366. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20367. */
  20368. export interface IPhysicsEnabledObject {
  20369. /**
  20370. * The position of the physics-enabled object
  20371. */
  20372. position: Vector3;
  20373. /**
  20374. * The rotation of the physics-enabled object
  20375. */
  20376. rotationQuaternion: Nullable<Quaternion>;
  20377. /**
  20378. * The scale of the physics-enabled object
  20379. */
  20380. scaling: Vector3;
  20381. /**
  20382. * The rotation of the physics-enabled object
  20383. */
  20384. rotation?: Vector3;
  20385. /**
  20386. * The parent of the physics-enabled object
  20387. */
  20388. parent?: any;
  20389. /**
  20390. * The bounding info of the physics-enabled object
  20391. * @returns The bounding info of the physics-enabled object
  20392. */
  20393. getBoundingInfo(): BoundingInfo;
  20394. /**
  20395. * Computes the world matrix
  20396. * @param force Specifies if the world matrix should be computed by force
  20397. * @returns A world matrix
  20398. */
  20399. computeWorldMatrix(force: boolean): Matrix;
  20400. /**
  20401. * Gets the world matrix
  20402. * @returns A world matrix
  20403. */
  20404. getWorldMatrix?(): Matrix;
  20405. /**
  20406. * Gets the child meshes
  20407. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  20408. * @returns An array of abstract meshes
  20409. */
  20410. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  20411. /**
  20412. * Gets the vertex data
  20413. * @param kind The type of vertex data
  20414. * @returns A nullable array of numbers, or a float32 array
  20415. */
  20416. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  20417. /**
  20418. * Gets the indices from the mesh
  20419. * @returns A nullable array of index arrays
  20420. */
  20421. getIndices?(): Nullable<IndicesArray>;
  20422. /**
  20423. * Gets the scene from the mesh
  20424. * @returns the indices array or null
  20425. */
  20426. getScene?(): Scene;
  20427. /**
  20428. * Gets the absolute position from the mesh
  20429. * @returns the absolute position
  20430. */
  20431. getAbsolutePosition(): Vector3;
  20432. /**
  20433. * Gets the absolute pivot point from the mesh
  20434. * @returns the absolute pivot point
  20435. */
  20436. getAbsolutePivotPoint(): Vector3;
  20437. /**
  20438. * Rotates the mesh
  20439. * @param axis The axis of rotation
  20440. * @param amount The amount of rotation
  20441. * @param space The space of the rotation
  20442. * @returns The rotation transform node
  20443. */
  20444. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  20445. /**
  20446. * Translates the mesh
  20447. * @param axis The axis of translation
  20448. * @param distance The distance of translation
  20449. * @param space The space of the translation
  20450. * @returns The transform node
  20451. */
  20452. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  20453. /**
  20454. * Sets the absolute position of the mesh
  20455. * @param absolutePosition The absolute position of the mesh
  20456. * @returns The transform node
  20457. */
  20458. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  20459. /**
  20460. * Gets the class name of the mesh
  20461. * @returns The class name
  20462. */
  20463. getClassName(): string;
  20464. }
  20465. /**
  20466. * Represents a physics imposter
  20467. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20468. */
  20469. export class PhysicsImpostor {
  20470. /**
  20471. * The physics-enabled object used as the physics imposter
  20472. */
  20473. object: IPhysicsEnabledObject;
  20474. /**
  20475. * The type of the physics imposter
  20476. */
  20477. type: number;
  20478. private _options;
  20479. private _scene?;
  20480. /**
  20481. * The default object size of the imposter
  20482. */
  20483. static DEFAULT_OBJECT_SIZE: Vector3;
  20484. /**
  20485. * The identity quaternion of the imposter
  20486. */
  20487. static IDENTITY_QUATERNION: Quaternion;
  20488. /** @hidden */
  20489. _pluginData: any;
  20490. private _physicsEngine;
  20491. private _physicsBody;
  20492. private _bodyUpdateRequired;
  20493. private _onBeforePhysicsStepCallbacks;
  20494. private _onAfterPhysicsStepCallbacks;
  20495. /** @hidden */
  20496. _onPhysicsCollideCallbacks: Array<{
  20497. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  20498. otherImpostors: Array<PhysicsImpostor>;
  20499. }>;
  20500. private _deltaPosition;
  20501. private _deltaRotation;
  20502. private _deltaRotationConjugated;
  20503. /** hidden */
  20504. _isFromLine: boolean;
  20505. private _parent;
  20506. private _isDisposed;
  20507. private static _tmpVecs;
  20508. private static _tmpQuat;
  20509. /**
  20510. * Specifies if the physics imposter is disposed
  20511. */
  20512. readonly isDisposed: boolean;
  20513. /**
  20514. * Gets the mass of the physics imposter
  20515. */
  20516. mass: number;
  20517. /**
  20518. * Gets the coefficient of friction
  20519. */
  20520. /**
  20521. * Sets the coefficient of friction
  20522. */
  20523. friction: number;
  20524. /**
  20525. * Gets the coefficient of restitution
  20526. */
  20527. /**
  20528. * Sets the coefficient of restitution
  20529. */
  20530. restitution: number;
  20531. /**
  20532. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  20533. */
  20534. /**
  20535. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  20536. */
  20537. pressure: number;
  20538. /**
  20539. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  20540. */
  20541. /**
  20542. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  20543. */
  20544. stiffness: number;
  20545. /**
  20546. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  20547. */
  20548. /**
  20549. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  20550. */
  20551. velocityIterations: number;
  20552. /**
  20553. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  20554. */
  20555. /**
  20556. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  20557. */
  20558. positionIterations: number;
  20559. /**
  20560. * The unique id of the physics imposter
  20561. * set by the physics engine when adding this impostor to the array
  20562. */
  20563. uniqueId: number;
  20564. /**
  20565. * @hidden
  20566. */
  20567. soft: boolean;
  20568. /**
  20569. * @hidden
  20570. */
  20571. segments: number;
  20572. private _joints;
  20573. /**
  20574. * Initializes the physics imposter
  20575. * @param object The physics-enabled object used as the physics imposter
  20576. * @param type The type of the physics imposter
  20577. * @param _options The options for the physics imposter
  20578. * @param _scene The Babylon scene
  20579. */
  20580. constructor(
  20581. /**
  20582. * The physics-enabled object used as the physics imposter
  20583. */
  20584. object: IPhysicsEnabledObject,
  20585. /**
  20586. * The type of the physics imposter
  20587. */
  20588. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  20589. /**
  20590. * This function will completly initialize this impostor.
  20591. * It will create a new body - but only if this mesh has no parent.
  20592. * If it has, this impostor will not be used other than to define the impostor
  20593. * of the child mesh.
  20594. * @hidden
  20595. */
  20596. _init(): void;
  20597. private _getPhysicsParent;
  20598. /**
  20599. * Should a new body be generated.
  20600. * @returns boolean specifying if body initialization is required
  20601. */
  20602. isBodyInitRequired(): boolean;
  20603. /**
  20604. * Sets the updated scaling
  20605. * @param updated Specifies if the scaling is updated
  20606. */
  20607. setScalingUpdated(): void;
  20608. /**
  20609. * Force a regeneration of this or the parent's impostor's body.
  20610. * Use under cautious - This will remove all joints already implemented.
  20611. */
  20612. forceUpdate(): void;
  20613. /**
  20614. * Gets the body that holds this impostor. Either its own, or its parent.
  20615. */
  20616. /**
  20617. * Set the physics body. Used mainly by the physics engine/plugin
  20618. */
  20619. physicsBody: any;
  20620. /**
  20621. * Get the parent of the physics imposter
  20622. * @returns Physics imposter or null
  20623. */
  20624. /**
  20625. * Sets the parent of the physics imposter
  20626. */
  20627. parent: Nullable<PhysicsImpostor>;
  20628. /**
  20629. * Resets the update flags
  20630. */
  20631. resetUpdateFlags(): void;
  20632. /**
  20633. * Gets the object extend size
  20634. * @returns the object extend size
  20635. */
  20636. getObjectExtendSize(): Vector3;
  20637. /**
  20638. * Gets the object center
  20639. * @returns The object center
  20640. */
  20641. getObjectCenter(): Vector3;
  20642. /**
  20643. * Get a specific parametes from the options parameter
  20644. * @param paramName The object parameter name
  20645. * @returns The object parameter
  20646. */
  20647. getParam(paramName: string): any;
  20648. /**
  20649. * Sets a specific parameter in the options given to the physics plugin
  20650. * @param paramName The parameter name
  20651. * @param value The value of the parameter
  20652. */
  20653. setParam(paramName: string, value: number): void;
  20654. /**
  20655. * Specifically change the body's mass option. Won't recreate the physics body object
  20656. * @param mass The mass of the physics imposter
  20657. */
  20658. setMass(mass: number): void;
  20659. /**
  20660. * Gets the linear velocity
  20661. * @returns linear velocity or null
  20662. */
  20663. getLinearVelocity(): Nullable<Vector3>;
  20664. /**
  20665. * Sets the linear velocity
  20666. * @param velocity linear velocity or null
  20667. */
  20668. setLinearVelocity(velocity: Nullable<Vector3>): void;
  20669. /**
  20670. * Gets the angular velocity
  20671. * @returns angular velocity or null
  20672. */
  20673. getAngularVelocity(): Nullable<Vector3>;
  20674. /**
  20675. * Sets the angular velocity
  20676. * @param velocity The velocity or null
  20677. */
  20678. setAngularVelocity(velocity: Nullable<Vector3>): void;
  20679. /**
  20680. * Execute a function with the physics plugin native code
  20681. * Provide a function the will have two variables - the world object and the physics body object
  20682. * @param func The function to execute with the physics plugin native code
  20683. */
  20684. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  20685. /**
  20686. * Register a function that will be executed before the physics world is stepping forward
  20687. * @param func The function to execute before the physics world is stepped forward
  20688. */
  20689. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20690. /**
  20691. * Unregister a function that will be executed before the physics world is stepping forward
  20692. * @param func The function to execute before the physics world is stepped forward
  20693. */
  20694. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20695. /**
  20696. * Register a function that will be executed after the physics step
  20697. * @param func The function to execute after physics step
  20698. */
  20699. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20700. /**
  20701. * Unregisters a function that will be executed after the physics step
  20702. * @param func The function to execute after physics step
  20703. */
  20704. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20705. /**
  20706. * register a function that will be executed when this impostor collides against a different body
  20707. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  20708. * @param func Callback that is executed on collision
  20709. */
  20710. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  20711. /**
  20712. * Unregisters the physics imposter on contact
  20713. * @param collideAgainst The physics object to collide against
  20714. * @param func Callback to execute on collision
  20715. */
  20716. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  20717. private _tmpQuat;
  20718. private _tmpQuat2;
  20719. /**
  20720. * Get the parent rotation
  20721. * @returns The parent rotation
  20722. */
  20723. getParentsRotation(): Quaternion;
  20724. /**
  20725. * this function is executed by the physics engine.
  20726. */
  20727. beforeStep: () => void;
  20728. /**
  20729. * this function is executed by the physics engine
  20730. */
  20731. afterStep: () => void;
  20732. /**
  20733. * Legacy collision detection event support
  20734. */
  20735. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  20736. /**
  20737. * event and body object due to cannon's event-based architecture.
  20738. */
  20739. onCollide: (e: {
  20740. body: any;
  20741. }) => void;
  20742. /**
  20743. * Apply a force
  20744. * @param force The force to apply
  20745. * @param contactPoint The contact point for the force
  20746. * @returns The physics imposter
  20747. */
  20748. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  20749. /**
  20750. * Apply an impulse
  20751. * @param force The impulse force
  20752. * @param contactPoint The contact point for the impulse force
  20753. * @returns The physics imposter
  20754. */
  20755. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  20756. /**
  20757. * A help function to create a joint
  20758. * @param otherImpostor A physics imposter used to create a joint
  20759. * @param jointType The type of joint
  20760. * @param jointData The data for the joint
  20761. * @returns The physics imposter
  20762. */
  20763. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  20764. /**
  20765. * Add a joint to this impostor with a different impostor
  20766. * @param otherImpostor A physics imposter used to add a joint
  20767. * @param joint The joint to add
  20768. * @returns The physics imposter
  20769. */
  20770. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  20771. /**
  20772. * Add an anchor to a cloth impostor
  20773. * @param otherImpostor rigid impostor to anchor to
  20774. * @param width ratio across width from 0 to 1
  20775. * @param height ratio up height from 0 to 1
  20776. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  20777. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  20778. * @returns impostor the soft imposter
  20779. */
  20780. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  20781. /**
  20782. * Add a hook to a rope impostor
  20783. * @param otherImpostor rigid impostor to anchor to
  20784. * @param length ratio across rope from 0 to 1
  20785. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  20786. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  20787. * @returns impostor the rope imposter
  20788. */
  20789. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  20790. /**
  20791. * Will keep this body still, in a sleep mode.
  20792. * @returns the physics imposter
  20793. */
  20794. sleep(): PhysicsImpostor;
  20795. /**
  20796. * Wake the body up.
  20797. * @returns The physics imposter
  20798. */
  20799. wakeUp(): PhysicsImpostor;
  20800. /**
  20801. * Clones the physics imposter
  20802. * @param newObject The physics imposter clones to this physics-enabled object
  20803. * @returns A nullable physics imposter
  20804. */
  20805. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  20806. /**
  20807. * Disposes the physics imposter
  20808. */
  20809. dispose(): void;
  20810. /**
  20811. * Sets the delta position
  20812. * @param position The delta position amount
  20813. */
  20814. setDeltaPosition(position: Vector3): void;
  20815. /**
  20816. * Sets the delta rotation
  20817. * @param rotation The delta rotation amount
  20818. */
  20819. setDeltaRotation(rotation: Quaternion): void;
  20820. /**
  20821. * Gets the box size of the physics imposter and stores the result in the input parameter
  20822. * @param result Stores the box size
  20823. * @returns The physics imposter
  20824. */
  20825. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  20826. /**
  20827. * Gets the radius of the physics imposter
  20828. * @returns Radius of the physics imposter
  20829. */
  20830. getRadius(): number;
  20831. /**
  20832. * Sync a bone with this impostor
  20833. * @param bone The bone to sync to the impostor.
  20834. * @param boneMesh The mesh that the bone is influencing.
  20835. * @param jointPivot The pivot of the joint / bone in local space.
  20836. * @param distToJoint Optional distance from the impostor to the joint.
  20837. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  20838. */
  20839. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  20840. /**
  20841. * Sync impostor to a bone
  20842. * @param bone The bone that the impostor will be synced to.
  20843. * @param boneMesh The mesh that the bone is influencing.
  20844. * @param jointPivot The pivot of the joint / bone in local space.
  20845. * @param distToJoint Optional distance from the impostor to the joint.
  20846. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  20847. * @param boneAxis Optional vector3 axis the bone is aligned with
  20848. */
  20849. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  20850. /**
  20851. * No-Imposter type
  20852. */
  20853. static NoImpostor: number;
  20854. /**
  20855. * Sphere-Imposter type
  20856. */
  20857. static SphereImpostor: number;
  20858. /**
  20859. * Box-Imposter type
  20860. */
  20861. static BoxImpostor: number;
  20862. /**
  20863. * Plane-Imposter type
  20864. */
  20865. static PlaneImpostor: number;
  20866. /**
  20867. * Mesh-imposter type
  20868. */
  20869. static MeshImpostor: number;
  20870. /**
  20871. * Cylinder-Imposter type
  20872. */
  20873. static CylinderImpostor: number;
  20874. /**
  20875. * Particle-Imposter type
  20876. */
  20877. static ParticleImpostor: number;
  20878. /**
  20879. * Heightmap-Imposter type
  20880. */
  20881. static HeightmapImpostor: number;
  20882. /**
  20883. * ConvexHull-Impostor type (Ammo.js plugin only)
  20884. */
  20885. static ConvexHullImpostor: number;
  20886. /**
  20887. * Rope-Imposter type
  20888. */
  20889. static RopeImpostor: number;
  20890. /**
  20891. * Cloth-Imposter type
  20892. */
  20893. static ClothImpostor: number;
  20894. /**
  20895. * Softbody-Imposter type
  20896. */
  20897. static SoftbodyImpostor: number;
  20898. }
  20899. }
  20900. declare module "babylonjs/Meshes/mesh" {
  20901. import { Observable } from "babylonjs/Misc/observable";
  20902. import { IAnimatable } from "babylonjs/Misc/tools";
  20903. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  20904. import { Camera } from "babylonjs/Cameras/camera";
  20905. import { Scene } from "babylonjs/scene";
  20906. import { Matrix, Vector3, Vector2, Color4, Plane, Vector4, Path3D } from "babylonjs/Maths/math";
  20907. import { Engine } from "babylonjs/Engines/engine";
  20908. import { Node } from "babylonjs/node";
  20909. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  20910. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  20911. import { Buffer } from "babylonjs/Meshes/buffer";
  20912. import { Geometry } from "babylonjs/Meshes/geometry";
  20913. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20914. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20915. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  20916. import { Effect } from "babylonjs/Materials/effect";
  20917. import { Material } from "babylonjs/Materials/material";
  20918. import { Skeleton } from "babylonjs/Bones/skeleton";
  20919. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  20920. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  20921. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  20922. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  20923. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  20924. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  20925. /**
  20926. * Class used to represent a specific level of detail of a mesh
  20927. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  20928. */
  20929. export class MeshLODLevel {
  20930. /** Defines the distance where this level should star being displayed */
  20931. distance: number;
  20932. /** Defines the mesh to use to render this level */
  20933. mesh: Nullable<Mesh>;
  20934. /**
  20935. * Creates a new LOD level
  20936. * @param distance defines the distance where this level should star being displayed
  20937. * @param mesh defines the mesh to use to render this level
  20938. */
  20939. constructor(
  20940. /** Defines the distance where this level should star being displayed */
  20941. distance: number,
  20942. /** Defines the mesh to use to render this level */
  20943. mesh: Nullable<Mesh>);
  20944. }
  20945. /**
  20946. * @hidden
  20947. **/
  20948. export class _CreationDataStorage {
  20949. closePath?: boolean;
  20950. closeArray?: boolean;
  20951. idx: number[];
  20952. dashSize: number;
  20953. gapSize: number;
  20954. path3D: Path3D;
  20955. pathArray: Vector3[][];
  20956. arc: number;
  20957. radius: number;
  20958. cap: number;
  20959. tessellation: number;
  20960. }
  20961. /**
  20962. * @hidden
  20963. **/
  20964. class _InstanceDataStorage {
  20965. visibleInstances: any;
  20966. renderIdForInstances: number[];
  20967. batchCache: _InstancesBatch;
  20968. instancesBufferSize: number;
  20969. instancesBuffer: Nullable<Buffer>;
  20970. instancesData: Float32Array;
  20971. overridenInstanceCount: number;
  20972. }
  20973. /**
  20974. * @hidden
  20975. **/
  20976. export class _InstancesBatch {
  20977. mustReturn: boolean;
  20978. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  20979. renderSelf: boolean[];
  20980. }
  20981. /**
  20982. * Class used to represent renderable models
  20983. */
  20984. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  20985. /**
  20986. * Mesh side orientation : usually the external or front surface
  20987. */
  20988. static readonly FRONTSIDE: number;
  20989. /**
  20990. * Mesh side orientation : usually the internal or back surface
  20991. */
  20992. static readonly BACKSIDE: number;
  20993. /**
  20994. * Mesh side orientation : both internal and external or front and back surfaces
  20995. */
  20996. static readonly DOUBLESIDE: number;
  20997. /**
  20998. * Mesh side orientation : by default, `FRONTSIDE`
  20999. */
  21000. static readonly DEFAULTSIDE: number;
  21001. /**
  21002. * Mesh cap setting : no cap
  21003. */
  21004. static readonly NO_CAP: number;
  21005. /**
  21006. * Mesh cap setting : one cap at the beginning of the mesh
  21007. */
  21008. static readonly CAP_START: number;
  21009. /**
  21010. * Mesh cap setting : one cap at the end of the mesh
  21011. */
  21012. static readonly CAP_END: number;
  21013. /**
  21014. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  21015. */
  21016. static readonly CAP_ALL: number;
  21017. /**
  21018. * Gets the default side orientation.
  21019. * @param orientation the orientation to value to attempt to get
  21020. * @returns the default orientation
  21021. * @hidden
  21022. */
  21023. static _GetDefaultSideOrientation(orientation?: number): number;
  21024. private _onBeforeRenderObservable;
  21025. private _onBeforeBindObservable;
  21026. private _onAfterRenderObservable;
  21027. private _onBeforeDrawObservable;
  21028. /**
  21029. * An event triggered before rendering the mesh
  21030. */
  21031. readonly onBeforeRenderObservable: Observable<Mesh>;
  21032. /**
  21033. * An event triggered before binding the mesh
  21034. */
  21035. readonly onBeforeBindObservable: Observable<Mesh>;
  21036. /**
  21037. * An event triggered after rendering the mesh
  21038. */
  21039. readonly onAfterRenderObservable: Observable<Mesh>;
  21040. /**
  21041. * An event triggered before drawing the mesh
  21042. */
  21043. readonly onBeforeDrawObservable: Observable<Mesh>;
  21044. private _onBeforeDrawObserver;
  21045. /**
  21046. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  21047. */
  21048. onBeforeDraw: () => void;
  21049. /**
  21050. * Gets the delay loading state of the mesh (when delay loading is turned on)
  21051. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  21052. */
  21053. delayLoadState: number;
  21054. /**
  21055. * Gets the list of instances created from this mesh
  21056. * it is not supposed to be modified manually.
  21057. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  21058. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  21059. */
  21060. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  21061. /**
  21062. * Gets the file containing delay loading data for this mesh
  21063. */
  21064. delayLoadingFile: string;
  21065. /** @hidden */
  21066. _binaryInfo: any;
  21067. private _LODLevels;
  21068. /**
  21069. * User defined function used to change how LOD level selection is done
  21070. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  21071. */
  21072. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  21073. private _morphTargetManager;
  21074. /**
  21075. * Gets or sets the morph target manager
  21076. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  21077. */
  21078. morphTargetManager: Nullable<MorphTargetManager>;
  21079. /** @hidden */
  21080. _creationDataStorage: Nullable<_CreationDataStorage>;
  21081. /** @hidden */
  21082. _geometry: Nullable<Geometry>;
  21083. /** @hidden */
  21084. _delayInfo: Array<string>;
  21085. /** @hidden */
  21086. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  21087. /** @hidden */
  21088. _instanceDataStorage: _InstanceDataStorage;
  21089. private _effectiveMaterial;
  21090. /** @hidden */
  21091. _shouldGenerateFlatShading: boolean;
  21092. private _preActivateId;
  21093. /** @hidden */
  21094. _originalBuilderSideOrientation: number;
  21095. /**
  21096. * Use this property to change the original side orientation defined at construction time
  21097. */
  21098. overrideMaterialSideOrientation: Nullable<number>;
  21099. private _areNormalsFrozen;
  21100. private _sourcePositions;
  21101. private _sourceNormals;
  21102. private _source;
  21103. private meshMap;
  21104. /**
  21105. * Gets the source mesh (the one used to clone this one from)
  21106. */
  21107. readonly source: Nullable<Mesh>;
  21108. /**
  21109. * Gets or sets a boolean indicating that this mesh does not use index buffer
  21110. */
  21111. isUnIndexed: boolean;
  21112. /**
  21113. * @constructor
  21114. * @param name The value used by scene.getMeshByName() to do a lookup.
  21115. * @param scene The scene to add this mesh to.
  21116. * @param parent The parent of this mesh, if it has one
  21117. * @param source An optional Mesh from which geometry is shared, cloned.
  21118. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  21119. * When false, achieved by calling a clone(), also passing False.
  21120. * This will make creation of children, recursive.
  21121. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  21122. */
  21123. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  21124. /**
  21125. * Gets the class name
  21126. * @returns the string "Mesh".
  21127. */
  21128. getClassName(): string;
  21129. /** @hidden */
  21130. readonly _isMesh: boolean;
  21131. /**
  21132. * Returns a description of this mesh
  21133. * @param fullDetails define if full details about this mesh must be used
  21134. * @returns a descriptive string representing this mesh
  21135. */
  21136. toString(fullDetails?: boolean): string;
  21137. /** @hidden */
  21138. _unBindEffect(): void;
  21139. /**
  21140. * Gets a boolean indicating if this mesh has LOD
  21141. */
  21142. readonly hasLODLevels: boolean;
  21143. /**
  21144. * Gets the list of MeshLODLevel associated with the current mesh
  21145. * @returns an array of MeshLODLevel
  21146. */
  21147. getLODLevels(): MeshLODLevel[];
  21148. private _sortLODLevels;
  21149. /**
  21150. * Add a mesh as LOD level triggered at the given distance.
  21151. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  21152. * @param distance The distance from the center of the object to show this level
  21153. * @param mesh The mesh to be added as LOD level (can be null)
  21154. * @return This mesh (for chaining)
  21155. */
  21156. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  21157. /**
  21158. * Returns the LOD level mesh at the passed distance or null if not found.
  21159. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  21160. * @param distance The distance from the center of the object to show this level
  21161. * @returns a Mesh or `null`
  21162. */
  21163. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  21164. /**
  21165. * Remove a mesh from the LOD array
  21166. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  21167. * @param mesh defines the mesh to be removed
  21168. * @return This mesh (for chaining)
  21169. */
  21170. removeLODLevel(mesh: Mesh): Mesh;
  21171. /**
  21172. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  21173. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  21174. * @param camera defines the camera to use to compute distance
  21175. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  21176. * @return This mesh (for chaining)
  21177. */
  21178. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  21179. /**
  21180. * Gets the mesh internal Geometry object
  21181. */
  21182. readonly geometry: Nullable<Geometry>;
  21183. /**
  21184. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  21185. * @returns the total number of vertices
  21186. */
  21187. getTotalVertices(): number;
  21188. /**
  21189. * Returns the content of an associated vertex buffer
  21190. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  21191. * - VertexBuffer.PositionKind
  21192. * - VertexBuffer.UVKind
  21193. * - VertexBuffer.UV2Kind
  21194. * - VertexBuffer.UV3Kind
  21195. * - VertexBuffer.UV4Kind
  21196. * - VertexBuffer.UV5Kind
  21197. * - VertexBuffer.UV6Kind
  21198. * - VertexBuffer.ColorKind
  21199. * - VertexBuffer.MatricesIndicesKind
  21200. * - VertexBuffer.MatricesIndicesExtraKind
  21201. * - VertexBuffer.MatricesWeightsKind
  21202. * - VertexBuffer.MatricesWeightsExtraKind
  21203. * @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
  21204. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  21205. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  21206. */
  21207. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21208. /**
  21209. * Returns the mesh VertexBuffer object from the requested `kind`
  21210. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  21211. * - VertexBuffer.PositionKind
  21212. * - VertexBuffer.UVKind
  21213. * - VertexBuffer.UV2Kind
  21214. * - VertexBuffer.UV3Kind
  21215. * - VertexBuffer.UV4Kind
  21216. * - VertexBuffer.UV5Kind
  21217. * - VertexBuffer.UV6Kind
  21218. * - VertexBuffer.ColorKind
  21219. * - VertexBuffer.MatricesIndicesKind
  21220. * - VertexBuffer.MatricesIndicesExtraKind
  21221. * - VertexBuffer.MatricesWeightsKind
  21222. * - VertexBuffer.MatricesWeightsExtraKind
  21223. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  21224. */
  21225. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  21226. /**
  21227. * Tests if a specific vertex buffer is associated with this mesh
  21228. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  21229. * - VertexBuffer.PositionKind
  21230. * - VertexBuffer.UVKind
  21231. * - VertexBuffer.UV2Kind
  21232. * - VertexBuffer.UV3Kind
  21233. * - VertexBuffer.UV4Kind
  21234. * - VertexBuffer.UV5Kind
  21235. * - VertexBuffer.UV6Kind
  21236. * - VertexBuffer.ColorKind
  21237. * - VertexBuffer.MatricesIndicesKind
  21238. * - VertexBuffer.MatricesIndicesExtraKind
  21239. * - VertexBuffer.MatricesWeightsKind
  21240. * - VertexBuffer.MatricesWeightsExtraKind
  21241. * @returns a boolean
  21242. */
  21243. isVerticesDataPresent(kind: string): boolean;
  21244. /**
  21245. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  21246. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  21247. * - VertexBuffer.PositionKind
  21248. * - VertexBuffer.UVKind
  21249. * - VertexBuffer.UV2Kind
  21250. * - VertexBuffer.UV3Kind
  21251. * - VertexBuffer.UV4Kind
  21252. * - VertexBuffer.UV5Kind
  21253. * - VertexBuffer.UV6Kind
  21254. * - VertexBuffer.ColorKind
  21255. * - VertexBuffer.MatricesIndicesKind
  21256. * - VertexBuffer.MatricesIndicesExtraKind
  21257. * - VertexBuffer.MatricesWeightsKind
  21258. * - VertexBuffer.MatricesWeightsExtraKind
  21259. * @returns a boolean
  21260. */
  21261. isVertexBufferUpdatable(kind: string): boolean;
  21262. /**
  21263. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  21264. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  21265. * - VertexBuffer.PositionKind
  21266. * - VertexBuffer.UVKind
  21267. * - VertexBuffer.UV2Kind
  21268. * - VertexBuffer.UV3Kind
  21269. * - VertexBuffer.UV4Kind
  21270. * - VertexBuffer.UV5Kind
  21271. * - VertexBuffer.UV6Kind
  21272. * - VertexBuffer.ColorKind
  21273. * - VertexBuffer.MatricesIndicesKind
  21274. * - VertexBuffer.MatricesIndicesExtraKind
  21275. * - VertexBuffer.MatricesWeightsKind
  21276. * - VertexBuffer.MatricesWeightsExtraKind
  21277. * @returns an array of strings
  21278. */
  21279. getVerticesDataKinds(): string[];
  21280. /**
  21281. * Returns a positive integer : the total number of indices in this mesh geometry.
  21282. * @returns the numner of indices or zero if the mesh has no geometry.
  21283. */
  21284. getTotalIndices(): number;
  21285. /**
  21286. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  21287. * @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.
  21288. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21289. * @returns the indices array or an empty array if the mesh has no geometry
  21290. */
  21291. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21292. readonly isBlocked: boolean;
  21293. /**
  21294. * Determine if the current mesh is ready to be rendered
  21295. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  21296. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  21297. * @returns true if all associated assets are ready (material, textures, shaders)
  21298. */
  21299. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  21300. /**
  21301. * 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.
  21302. */
  21303. readonly areNormalsFrozen: boolean;
  21304. /**
  21305. * 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.
  21306. * @returns the current mesh
  21307. */
  21308. freezeNormals(): Mesh;
  21309. /**
  21310. * 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
  21311. * @returns the current mesh
  21312. */
  21313. unfreezeNormals(): Mesh;
  21314. /**
  21315. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  21316. */
  21317. overridenInstanceCount: number;
  21318. /** @hidden */
  21319. _preActivate(): Mesh;
  21320. /** @hidden */
  21321. _preActivateForIntermediateRendering(renderId: number): Mesh;
  21322. /** @hidden */
  21323. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  21324. /**
  21325. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  21326. * This means the mesh underlying bounding box and sphere are recomputed.
  21327. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  21328. * @returns the current mesh
  21329. */
  21330. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  21331. /** @hidden */
  21332. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  21333. /**
  21334. * This function will subdivide the mesh into multiple submeshes
  21335. * @param count defines the expected number of submeshes
  21336. */
  21337. subdivide(count: number): void;
  21338. /**
  21339. * Copy a FloatArray into a specific associated vertex buffer
  21340. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  21341. * - VertexBuffer.PositionKind
  21342. * - VertexBuffer.UVKind
  21343. * - VertexBuffer.UV2Kind
  21344. * - VertexBuffer.UV3Kind
  21345. * - VertexBuffer.UV4Kind
  21346. * - VertexBuffer.UV5Kind
  21347. * - VertexBuffer.UV6Kind
  21348. * - VertexBuffer.ColorKind
  21349. * - VertexBuffer.MatricesIndicesKind
  21350. * - VertexBuffer.MatricesIndicesExtraKind
  21351. * - VertexBuffer.MatricesWeightsKind
  21352. * - VertexBuffer.MatricesWeightsExtraKind
  21353. * @param data defines the data source
  21354. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  21355. * @param stride defines the data stride size (can be null)
  21356. * @returns the current mesh
  21357. */
  21358. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  21359. /**
  21360. * Flags an associated vertex buffer as updatable
  21361. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  21362. * - VertexBuffer.PositionKind
  21363. * - VertexBuffer.UVKind
  21364. * - VertexBuffer.UV2Kind
  21365. * - VertexBuffer.UV3Kind
  21366. * - VertexBuffer.UV4Kind
  21367. * - VertexBuffer.UV5Kind
  21368. * - VertexBuffer.UV6Kind
  21369. * - VertexBuffer.ColorKind
  21370. * - VertexBuffer.MatricesIndicesKind
  21371. * - VertexBuffer.MatricesIndicesExtraKind
  21372. * - VertexBuffer.MatricesWeightsKind
  21373. * - VertexBuffer.MatricesWeightsExtraKind
  21374. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  21375. */
  21376. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  21377. /**
  21378. * Sets the mesh global Vertex Buffer
  21379. * @param buffer defines the buffer to use
  21380. * @returns the current mesh
  21381. */
  21382. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  21383. /**
  21384. * Update a specific associated vertex buffer
  21385. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  21386. * - VertexBuffer.PositionKind
  21387. * - VertexBuffer.UVKind
  21388. * - VertexBuffer.UV2Kind
  21389. * - VertexBuffer.UV3Kind
  21390. * - VertexBuffer.UV4Kind
  21391. * - VertexBuffer.UV5Kind
  21392. * - VertexBuffer.UV6Kind
  21393. * - VertexBuffer.ColorKind
  21394. * - VertexBuffer.MatricesIndicesKind
  21395. * - VertexBuffer.MatricesIndicesExtraKind
  21396. * - VertexBuffer.MatricesWeightsKind
  21397. * - VertexBuffer.MatricesWeightsExtraKind
  21398. * @param data defines the data source
  21399. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  21400. * @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)
  21401. * @returns the current mesh
  21402. */
  21403. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  21404. /**
  21405. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  21406. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  21407. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  21408. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  21409. * @returns the current mesh
  21410. */
  21411. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  21412. /**
  21413. * Creates a un-shared specific occurence of the geometry for the mesh.
  21414. * @returns the current mesh
  21415. */
  21416. makeGeometryUnique(): Mesh;
  21417. /**
  21418. * Set the index buffer of this mesh
  21419. * @param indices defines the source data
  21420. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  21421. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  21422. * @returns the current mesh
  21423. */
  21424. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  21425. /**
  21426. * Update the current index buffer
  21427. * @param indices defines the source data
  21428. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  21429. * @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)
  21430. * @returns the current mesh
  21431. */
  21432. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): Mesh;
  21433. /**
  21434. * Invert the geometry to move from a right handed system to a left handed one.
  21435. * @returns the current mesh
  21436. */
  21437. toLeftHanded(): Mesh;
  21438. /** @hidden */
  21439. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  21440. /** @hidden */
  21441. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  21442. /**
  21443. * Registers for this mesh a javascript function called just before the rendering process
  21444. * @param func defines the function to call before rendering this mesh
  21445. * @returns the current mesh
  21446. */
  21447. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  21448. /**
  21449. * Disposes a previously registered javascript function called before the rendering
  21450. * @param func defines the function to remove
  21451. * @returns the current mesh
  21452. */
  21453. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  21454. /**
  21455. * Registers for this mesh a javascript function called just after the rendering is complete
  21456. * @param func defines the function to call after rendering this mesh
  21457. * @returns the current mesh
  21458. */
  21459. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  21460. /**
  21461. * Disposes a previously registered javascript function called after the rendering.
  21462. * @param func defines the function to remove
  21463. * @returns the current mesh
  21464. */
  21465. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  21466. /** @hidden */
  21467. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  21468. /** @hidden */
  21469. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  21470. /** @hidden */
  21471. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  21472. /**
  21473. * 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
  21474. * @param subMesh defines the subMesh to render
  21475. * @param enableAlphaMode defines if alpha mode can be changed
  21476. * @returns the current mesh
  21477. */
  21478. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  21479. private _onBeforeDraw;
  21480. /**
  21481. * Renormalize the mesh and patch it up if there are no weights
  21482. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  21483. * However in the case of zero weights then we set just a single influence to 1.
  21484. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  21485. */
  21486. cleanMatrixWeights(): void;
  21487. private normalizeSkinFourWeights;
  21488. private normalizeSkinWeightsAndExtra;
  21489. /**
  21490. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  21491. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  21492. * the user know there was an issue with importing the mesh
  21493. * @returns a validation object with skinned, valid and report string
  21494. */
  21495. validateSkinning(): {
  21496. skinned: boolean;
  21497. valid: boolean;
  21498. report: string;
  21499. };
  21500. /** @hidden */
  21501. _checkDelayState(): Mesh;
  21502. private _queueLoad;
  21503. /**
  21504. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  21505. * A mesh is in the frustum if its bounding box intersects the frustum
  21506. * @param frustumPlanes defines the frustum to test
  21507. * @returns true if the mesh is in the frustum planes
  21508. */
  21509. isInFrustum(frustumPlanes: Plane[]): boolean;
  21510. /**
  21511. * Sets the mesh material by the material or multiMaterial `id` property
  21512. * @param id is a string identifying the material or the multiMaterial
  21513. * @returns the current mesh
  21514. */
  21515. setMaterialByID(id: string): Mesh;
  21516. /**
  21517. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  21518. * @returns an array of IAnimatable
  21519. */
  21520. getAnimatables(): IAnimatable[];
  21521. /**
  21522. * Modifies the mesh geometry according to the passed transformation matrix.
  21523. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  21524. * The mesh normals are modified using the same transformation.
  21525. * Note that, under the hood, this method sets a new VertexBuffer each call.
  21526. * @param transform defines the transform matrix to use
  21527. * @see http://doc.babylonjs.com/resources/baking_transformations
  21528. * @returns the current mesh
  21529. */
  21530. bakeTransformIntoVertices(transform: Matrix): Mesh;
  21531. /**
  21532. * Modifies the mesh geometry according to its own current World Matrix.
  21533. * The mesh World Matrix is then reset.
  21534. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  21535. * Note that, under the hood, this method sets a new VertexBuffer each call.
  21536. * @see http://doc.babylonjs.com/resources/baking_transformations
  21537. * @returns the current mesh
  21538. */
  21539. bakeCurrentTransformIntoVertices(): Mesh;
  21540. /** @hidden */
  21541. readonly _positions: Nullable<Vector3[]>;
  21542. /** @hidden */
  21543. _resetPointsArrayCache(): Mesh;
  21544. /** @hidden */
  21545. _generatePointsArray(): boolean;
  21546. /**
  21547. * Returns a new Mesh object generated from the current mesh properties.
  21548. * This method must not get confused with createInstance()
  21549. * @param name is a string, the name given to the new mesh
  21550. * @param newParent can be any Node object (default `null`)
  21551. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  21552. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  21553. * @returns a new mesh
  21554. */
  21555. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  21556. /**
  21557. * Releases resources associated with this mesh.
  21558. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  21559. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  21560. */
  21561. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  21562. /**
  21563. * Modifies the mesh geometry according to a displacement map.
  21564. * 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.
  21565. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  21566. * @param url is a string, the URL from the image file is to be downloaded.
  21567. * @param minHeight is the lower limit of the displacement.
  21568. * @param maxHeight is the upper limit of the displacement.
  21569. * @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.
  21570. * @param uvOffset is an optional vector2 used to offset UV.
  21571. * @param uvScale is an optional vector2 used to scale UV.
  21572. * @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.
  21573. * @returns the Mesh.
  21574. */
  21575. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  21576. /**
  21577. * Modifies the mesh geometry according to a displacementMap buffer.
  21578. * 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.
  21579. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  21580. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  21581. * @param heightMapWidth is the width of the buffer image.
  21582. * @param heightMapHeight is the height of the buffer image.
  21583. * @param minHeight is the lower limit of the displacement.
  21584. * @param maxHeight is the upper limit of the displacement.
  21585. * @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.
  21586. * @param uvOffset is an optional vector2 used to offset UV.
  21587. * @param uvScale is an optional vector2 used to scale UV.
  21588. * @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.
  21589. * @returns the Mesh.
  21590. */
  21591. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  21592. /**
  21593. * Modify the mesh to get a flat shading rendering.
  21594. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  21595. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  21596. * @returns current mesh
  21597. */
  21598. convertToFlatShadedMesh(): Mesh;
  21599. /**
  21600. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  21601. * In other words, more vertices, no more indices and a single bigger VBO.
  21602. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  21603. * @returns current mesh
  21604. */
  21605. convertToUnIndexedMesh(): Mesh;
  21606. /**
  21607. * Inverses facet orientations.
  21608. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  21609. * @param flipNormals will also inverts the normals
  21610. * @returns current mesh
  21611. */
  21612. flipFaces(flipNormals?: boolean): Mesh;
  21613. /**
  21614. * Increase the number of facets and hence vertices in a mesh
  21615. * Vertex normals are interpolated from existing vertex normals
  21616. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  21617. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  21618. */
  21619. increaseVertices(numberPerEdge: number): void;
  21620. /**
  21621. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  21622. * This will undo any application of covertToFlatShadedMesh
  21623. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  21624. */
  21625. forceSharedVertices(): void;
  21626. /** @hidden */
  21627. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  21628. /** @hidden */
  21629. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  21630. /**
  21631. * Creates a new InstancedMesh object from the mesh model.
  21632. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  21633. * @param name defines the name of the new instance
  21634. * @returns a new InstancedMesh
  21635. */
  21636. createInstance(name: string): InstancedMesh;
  21637. /**
  21638. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  21639. * After this call, all the mesh instances have the same submeshes than the current mesh.
  21640. * @returns the current mesh
  21641. */
  21642. synchronizeInstances(): Mesh;
  21643. /**
  21644. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  21645. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  21646. * This should be used together with the simplification to avoid disappearing triangles.
  21647. * @param successCallback an optional success callback to be called after the optimization finished.
  21648. * @returns the current mesh
  21649. */
  21650. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  21651. /**
  21652. * Serialize current mesh
  21653. * @param serializationObject defines the object which will receive the serialization data
  21654. */
  21655. serialize(serializationObject: any): void;
  21656. /** @hidden */
  21657. _syncGeometryWithMorphTargetManager(): void;
  21658. /** @hidden */
  21659. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  21660. /**
  21661. * Returns a new Mesh object parsed from the source provided.
  21662. * @param parsedMesh is the source
  21663. * @param scene defines the hosting scene
  21664. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  21665. * @returns a new Mesh
  21666. */
  21667. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  21668. /**
  21669. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  21670. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  21671. * @param name defines the name of the mesh to create
  21672. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  21673. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  21674. * @param closePath creates a seam between the first and the last points of each path of the path array
  21675. * @param offset is taken in account only if the `pathArray` is containing a single path
  21676. * @param scene defines the hosting scene
  21677. * @param updatable defines if the mesh must be flagged as updatable
  21678. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21679. * @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)
  21680. * @returns a new Mesh
  21681. */
  21682. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  21683. /**
  21684. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  21685. * @param name defines the name of the mesh to create
  21686. * @param radius sets the radius size (float) of the polygon (default 0.5)
  21687. * @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
  21688. * @param scene defines the hosting scene
  21689. * @param updatable defines if the mesh must be flagged as updatable
  21690. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21691. * @returns a new Mesh
  21692. */
  21693. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  21694. /**
  21695. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  21696. * @param name defines the name of the mesh to create
  21697. * @param size sets the size (float) of each box side (default 1)
  21698. * @param scene defines the hosting scene
  21699. * @param updatable defines if the mesh must be flagged as updatable
  21700. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21701. * @returns a new Mesh
  21702. */
  21703. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  21704. /**
  21705. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  21706. * @param name defines the name of the mesh to create
  21707. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  21708. * @param diameter sets the diameter size (float) of the sphere (default 1)
  21709. * @param scene defines the hosting scene
  21710. * @param updatable defines if the mesh must be flagged as updatable
  21711. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21712. * @returns a new Mesh
  21713. */
  21714. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21715. /**
  21716. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  21717. * @param name defines the name of the mesh to create
  21718. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  21719. * @param diameter sets the diameter size (float) of the sphere (default 1)
  21720. * @param scene defines the hosting scene
  21721. * @returns a new Mesh
  21722. */
  21723. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  21724. /**
  21725. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  21726. * @param name defines the name of the mesh to create
  21727. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  21728. * @param diameterTop set the top cap diameter (floats, default 1)
  21729. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  21730. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  21731. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  21732. * @param scene defines the hosting scene
  21733. * @param updatable defines if the mesh must be flagged as updatable
  21734. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21735. * @returns a new Mesh
  21736. */
  21737. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  21738. /**
  21739. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  21740. * @param name defines the name of the mesh to create
  21741. * @param diameter sets the diameter size (float) of the torus (default 1)
  21742. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  21743. * @param tessellation sets the number of torus sides (postive integer, default 16)
  21744. * @param scene defines the hosting scene
  21745. * @param updatable defines if the mesh must be flagged as updatable
  21746. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21747. * @returns a new Mesh
  21748. */
  21749. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21750. /**
  21751. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  21752. * @param name defines the name of the mesh to create
  21753. * @param radius sets the global radius size (float) of the torus knot (default 2)
  21754. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  21755. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  21756. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  21757. * @param p the number of windings on X axis (positive integers, default 2)
  21758. * @param q the number of windings on Y axis (positive integers, default 3)
  21759. * @param scene defines the hosting scene
  21760. * @param updatable defines if the mesh must be flagged as updatable
  21761. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21762. * @returns a new Mesh
  21763. */
  21764. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21765. /**
  21766. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  21767. * @param name defines the name of the mesh to create
  21768. * @param points is an array successive Vector3
  21769. * @param scene defines the hosting scene
  21770. * @param updatable defines if the mesh must be flagged as updatable
  21771. * @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).
  21772. * @returns a new Mesh
  21773. */
  21774. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  21775. /**
  21776. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  21777. * @param name defines the name of the mesh to create
  21778. * @param points is an array successive Vector3
  21779. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  21780. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  21781. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  21782. * @param scene defines the hosting scene
  21783. * @param updatable defines if the mesh must be flagged as updatable
  21784. * @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)
  21785. * @returns a new Mesh
  21786. */
  21787. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  21788. /**
  21789. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  21790. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  21791. * 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.
  21792. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21793. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21794. * Remember you can only change the shape positions, not their number when updating a polygon.
  21795. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  21796. * @param name defines the name of the mesh to create
  21797. * @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
  21798. * @param scene defines the hosting scene
  21799. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  21800. * @param updatable defines if the mesh must be flagged as updatable
  21801. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21802. * @param earcutInjection can be used to inject your own earcut reference
  21803. * @returns a new Mesh
  21804. */
  21805. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  21806. /**
  21807. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  21808. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  21809. * @param name defines the name of the mesh to create
  21810. * @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
  21811. * @param depth defines the height of extrusion
  21812. * @param scene defines the hosting scene
  21813. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  21814. * @param updatable defines if the mesh must be flagged as updatable
  21815. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21816. * @param earcutInjection can be used to inject your own earcut reference
  21817. * @returns a new Mesh
  21818. */
  21819. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  21820. /**
  21821. * Creates an extruded shape mesh.
  21822. * 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
  21823. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  21824. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  21825. * @param name defines the name of the mesh to create
  21826. * @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
  21827. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  21828. * @param scale is the value to scale the shape
  21829. * @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
  21830. * @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
  21831. * @param scene defines the hosting scene
  21832. * @param updatable defines if the mesh must be flagged as updatable
  21833. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21834. * @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)
  21835. * @returns a new Mesh
  21836. */
  21837. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  21838. /**
  21839. * Creates an custom extruded shape mesh.
  21840. * The custom extrusion is a parametric shape.
  21841. * It has no predefined shape. Its final shape will depend on the input parameters.
  21842. * Please consider using the same method from the MeshBuilder class instead
  21843. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  21844. * @param name defines the name of the mesh to create
  21845. * @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
  21846. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  21847. * @param scaleFunction is a custom Javascript function called on each path point
  21848. * @param rotationFunction is a custom Javascript function called on each path point
  21849. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  21850. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  21851. * @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
  21852. * @param scene defines the hosting scene
  21853. * @param updatable defines if the mesh must be flagged as updatable
  21854. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21855. * @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)
  21856. * @returns a new Mesh
  21857. */
  21858. 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;
  21859. /**
  21860. * Creates lathe mesh.
  21861. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  21862. * Please consider using the same method from the MeshBuilder class instead
  21863. * @param name defines the name of the mesh to create
  21864. * @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
  21865. * @param radius is the radius value of the lathe
  21866. * @param tessellation is the side number of the lathe.
  21867. * @param scene defines the hosting scene
  21868. * @param updatable defines if the mesh must be flagged as updatable
  21869. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21870. * @returns a new Mesh
  21871. */
  21872. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21873. /**
  21874. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  21875. * @param name defines the name of the mesh to create
  21876. * @param size sets the size (float) of both sides of the plane at once (default 1)
  21877. * @param scene defines the hosting scene
  21878. * @param updatable defines if the mesh must be flagged as updatable
  21879. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21880. * @returns a new Mesh
  21881. */
  21882. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21883. /**
  21884. * Creates a ground mesh.
  21885. * Please consider using the same method from the MeshBuilder class instead
  21886. * @param name defines the name of the mesh to create
  21887. * @param width set the width of the ground
  21888. * @param height set the height of the ground
  21889. * @param subdivisions sets the number of subdivisions per side
  21890. * @param scene defines the hosting scene
  21891. * @param updatable defines if the mesh must be flagged as updatable
  21892. * @returns a new Mesh
  21893. */
  21894. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  21895. /**
  21896. * Creates a tiled ground mesh.
  21897. * Please consider using the same method from the MeshBuilder class instead
  21898. * @param name defines the name of the mesh to create
  21899. * @param xmin set the ground minimum X coordinate
  21900. * @param zmin set the ground minimum Y coordinate
  21901. * @param xmax set the ground maximum X coordinate
  21902. * @param zmax set the ground maximum Z coordinate
  21903. * @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
  21904. * @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
  21905. * @param scene defines the hosting scene
  21906. * @param updatable defines if the mesh must be flagged as updatable
  21907. * @returns a new Mesh
  21908. */
  21909. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  21910. w: number;
  21911. h: number;
  21912. }, precision: {
  21913. w: number;
  21914. h: number;
  21915. }, scene: Scene, updatable?: boolean): Mesh;
  21916. /**
  21917. * Creates a ground mesh from a height map.
  21918. * Please consider using the same method from the MeshBuilder class instead
  21919. * @see http://doc.babylonjs.com/babylon101/height_map
  21920. * @param name defines the name of the mesh to create
  21921. * @param url sets the URL of the height map image resource
  21922. * @param width set the ground width size
  21923. * @param height set the ground height size
  21924. * @param subdivisions sets the number of subdivision per side
  21925. * @param minHeight is the minimum altitude on the ground
  21926. * @param maxHeight is the maximum altitude on the ground
  21927. * @param scene defines the hosting scene
  21928. * @param updatable defines if the mesh must be flagged as updatable
  21929. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  21930. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  21931. * @returns a new Mesh
  21932. */
  21933. 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;
  21934. /**
  21935. * Creates a tube mesh.
  21936. * The tube is a parametric shape.
  21937. * It has no predefined shape. Its final shape will depend on the input parameters.
  21938. * Please consider using the same method from the MeshBuilder class instead
  21939. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  21940. * @param name defines the name of the mesh to create
  21941. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  21942. * @param radius sets the tube radius size
  21943. * @param tessellation is the number of sides on the tubular surface
  21944. * @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
  21945. * @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
  21946. * @param scene defines the hosting scene
  21947. * @param updatable defines if the mesh must be flagged as updatable
  21948. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21949. * @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)
  21950. * @returns a new Mesh
  21951. */
  21952. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  21953. (i: number, distance: number): number;
  21954. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  21955. /**
  21956. * Creates a polyhedron mesh.
  21957. * Please consider using the same method from the MeshBuilder class instead.
  21958. * * 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
  21959. * * The parameter `size` (positive float, default 1) sets the polygon size
  21960. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  21961. * * 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`
  21962. * * 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
  21963. * * 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)`)
  21964. * * 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
  21965. * * 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
  21966. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21967. * * If you create a double-sided mesh, you can choose what parts of 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
  21968. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  21969. * @param name defines the name of the mesh to create
  21970. * @param options defines the options used to create the mesh
  21971. * @param scene defines the hosting scene
  21972. * @returns a new Mesh
  21973. */
  21974. static CreatePolyhedron(name: string, options: {
  21975. type?: number;
  21976. size?: number;
  21977. sizeX?: number;
  21978. sizeY?: number;
  21979. sizeZ?: number;
  21980. custom?: any;
  21981. faceUV?: Vector4[];
  21982. faceColors?: Color4[];
  21983. updatable?: boolean;
  21984. sideOrientation?: number;
  21985. }, scene: Scene): Mesh;
  21986. /**
  21987. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  21988. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  21989. * * 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`)
  21990. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  21991. * * 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
  21992. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21993. * * If you create a double-sided mesh, you can choose what parts of 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
  21994. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  21995. * @param name defines the name of the mesh
  21996. * @param options defines the options used to create the mesh
  21997. * @param scene defines the hosting scene
  21998. * @returns a new Mesh
  21999. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  22000. */
  22001. static CreateIcoSphere(name: string, options: {
  22002. radius?: number;
  22003. flat?: boolean;
  22004. subdivisions?: number;
  22005. sideOrientation?: number;
  22006. updatable?: boolean;
  22007. }, scene: Scene): Mesh;
  22008. /**
  22009. * Creates a decal mesh.
  22010. * Please consider using the same method from the MeshBuilder class instead.
  22011. * A decal is a mesh usually applied as a model onto the surface of another mesh
  22012. * @param name defines the name of the mesh
  22013. * @param sourceMesh defines the mesh receiving the decal
  22014. * @param position sets the position of the decal in world coordinates
  22015. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  22016. * @param size sets the decal scaling
  22017. * @param angle sets the angle to rotate the decal
  22018. * @returns a new Mesh
  22019. */
  22020. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  22021. /**
  22022. * Prepare internal position array for software CPU skinning
  22023. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  22024. */
  22025. setPositionsForCPUSkinning(): Float32Array;
  22026. /**
  22027. * Prepare internal normal array for software CPU skinning
  22028. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  22029. */
  22030. setNormalsForCPUSkinning(): Float32Array;
  22031. /**
  22032. * Updates the vertex buffer by applying transformation from the bones
  22033. * @param skeleton defines the skeleton to apply to current mesh
  22034. * @returns the current mesh
  22035. */
  22036. applySkeleton(skeleton: Skeleton): Mesh;
  22037. /**
  22038. * 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
  22039. * @param meshes defines the list of meshes to scan
  22040. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  22041. */
  22042. static MinMax(meshes: AbstractMesh[]): {
  22043. min: Vector3;
  22044. max: Vector3;
  22045. };
  22046. /**
  22047. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  22048. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  22049. * @returns a vector3
  22050. */
  22051. static Center(meshesOrMinMaxVector: {
  22052. min: Vector3;
  22053. max: Vector3;
  22054. } | AbstractMesh[]): Vector3;
  22055. /**
  22056. * Merge the array of meshes into a single mesh for performance reasons.
  22057. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  22058. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  22059. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  22060. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  22061. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  22062. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  22063. * @returns a new mesh
  22064. */
  22065. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  22066. /** @hidden */
  22067. addInstance(instance: InstancedMesh): void;
  22068. /** @hidden */
  22069. removeInstance(instance: InstancedMesh): void;
  22070. }
  22071. }
  22072. declare module "babylonjs/Materials/material" {
  22073. import { IAnimatable } from "babylonjs/Misc/tools";
  22074. import { SmartArray } from "babylonjs/Misc/smartArray";
  22075. import { Observable } from "babylonjs/Misc/observable";
  22076. import { Nullable } from "babylonjs/types";
  22077. import { Scene } from "babylonjs/scene";
  22078. import { Matrix } from "babylonjs/Maths/math";
  22079. import { BaseSubMesh, SubMesh } from "babylonjs/Meshes/subMesh";
  22080. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22081. import { Mesh } from "babylonjs/Meshes/mesh";
  22082. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  22083. import { Effect } from "babylonjs/Materials/effect";
  22084. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  22085. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  22086. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  22087. import { IInspectable } from "babylonjs/Misc/iInspectable";
  22088. import { Animation } from "babylonjs/Animations/animation";
  22089. /**
  22090. * Base class for the main features of a material in Babylon.js
  22091. */
  22092. export class Material implements IAnimatable {
  22093. /**
  22094. * Returns the triangle fill mode
  22095. */
  22096. static readonly TriangleFillMode: number;
  22097. /**
  22098. * Returns the wireframe mode
  22099. */
  22100. static readonly WireFrameFillMode: number;
  22101. /**
  22102. * Returns the point fill mode
  22103. */
  22104. static readonly PointFillMode: number;
  22105. /**
  22106. * Returns the point list draw mode
  22107. */
  22108. static readonly PointListDrawMode: number;
  22109. /**
  22110. * Returns the line list draw mode
  22111. */
  22112. static readonly LineListDrawMode: number;
  22113. /**
  22114. * Returns the line loop draw mode
  22115. */
  22116. static readonly LineLoopDrawMode: number;
  22117. /**
  22118. * Returns the line strip draw mode
  22119. */
  22120. static readonly LineStripDrawMode: number;
  22121. /**
  22122. * Returns the triangle strip draw mode
  22123. */
  22124. static readonly TriangleStripDrawMode: number;
  22125. /**
  22126. * Returns the triangle fan draw mode
  22127. */
  22128. static readonly TriangleFanDrawMode: number;
  22129. /**
  22130. * Stores the clock-wise side orientation
  22131. */
  22132. static readonly ClockWiseSideOrientation: number;
  22133. /**
  22134. * Stores the counter clock-wise side orientation
  22135. */
  22136. static readonly CounterClockWiseSideOrientation: number;
  22137. /**
  22138. * The dirty texture flag value
  22139. */
  22140. static readonly TextureDirtyFlag: number;
  22141. /**
  22142. * The dirty light flag value
  22143. */
  22144. static readonly LightDirtyFlag: number;
  22145. /**
  22146. * The dirty fresnel flag value
  22147. */
  22148. static readonly FresnelDirtyFlag: number;
  22149. /**
  22150. * The dirty attribute flag value
  22151. */
  22152. static readonly AttributesDirtyFlag: number;
  22153. /**
  22154. * The dirty misc flag value
  22155. */
  22156. static readonly MiscDirtyFlag: number;
  22157. /**
  22158. * The all dirty flag value
  22159. */
  22160. static readonly AllDirtyFlag: number;
  22161. /**
  22162. * The ID of the material
  22163. */
  22164. id: string;
  22165. /**
  22166. * Gets or sets the unique id of the material
  22167. */
  22168. uniqueId: number;
  22169. /**
  22170. * The name of the material
  22171. */
  22172. name: string;
  22173. /**
  22174. * Gets or sets user defined metadata
  22175. */
  22176. metadata: any;
  22177. /**
  22178. * For internal use only. Please do not use.
  22179. */
  22180. reservedDataStore: any;
  22181. /**
  22182. * Specifies if the ready state should be checked on each call
  22183. */
  22184. checkReadyOnEveryCall: boolean;
  22185. /**
  22186. * Specifies if the ready state should be checked once
  22187. */
  22188. checkReadyOnlyOnce: boolean;
  22189. /**
  22190. * The state of the material
  22191. */
  22192. state: string;
  22193. /**
  22194. * The alpha value of the material
  22195. */
  22196. protected _alpha: number;
  22197. /**
  22198. * List of inspectable custom properties (used by the Inspector)
  22199. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  22200. */
  22201. inspectableCustomProperties: IInspectable[];
  22202. /**
  22203. * Sets the alpha value of the material
  22204. */
  22205. /**
  22206. * Gets the alpha value of the material
  22207. */
  22208. alpha: number;
  22209. /**
  22210. * Specifies if back face culling is enabled
  22211. */
  22212. protected _backFaceCulling: boolean;
  22213. /**
  22214. * Sets the back-face culling state
  22215. */
  22216. /**
  22217. * Gets the back-face culling state
  22218. */
  22219. backFaceCulling: boolean;
  22220. /**
  22221. * Stores the value for side orientation
  22222. */
  22223. sideOrientation: number;
  22224. /**
  22225. * Callback triggered when the material is compiled
  22226. */
  22227. onCompiled: (effect: Effect) => void;
  22228. /**
  22229. * Callback triggered when an error occurs
  22230. */
  22231. onError: (effect: Effect, errors: string) => void;
  22232. /**
  22233. * Callback triggered to get the render target textures
  22234. */
  22235. getRenderTargetTextures: () => SmartArray<RenderTargetTexture>;
  22236. /**
  22237. * Gets a boolean indicating that current material needs to register RTT
  22238. */
  22239. readonly hasRenderTargetTextures: boolean;
  22240. /**
  22241. * Specifies if the material should be serialized
  22242. */
  22243. doNotSerialize: boolean;
  22244. /**
  22245. * @hidden
  22246. */
  22247. _storeEffectOnSubMeshes: boolean;
  22248. /**
  22249. * Stores the animations for the material
  22250. */
  22251. animations: Array<Animation>;
  22252. /**
  22253. * An event triggered when the material is disposed
  22254. */
  22255. onDisposeObservable: Observable<Material>;
  22256. /**
  22257. * An observer which watches for dispose events
  22258. */
  22259. private _onDisposeObserver;
  22260. private _onUnBindObservable;
  22261. /**
  22262. * Called during a dispose event
  22263. */
  22264. onDispose: () => void;
  22265. private _onBindObservable;
  22266. /**
  22267. * An event triggered when the material is bound
  22268. */
  22269. readonly onBindObservable: Observable<AbstractMesh>;
  22270. /**
  22271. * An observer which watches for bind events
  22272. */
  22273. private _onBindObserver;
  22274. /**
  22275. * Called during a bind event
  22276. */
  22277. onBind: (Mesh: AbstractMesh) => void;
  22278. /**
  22279. * An event triggered when the material is unbound
  22280. */
  22281. readonly onUnBindObservable: Observable<Material>;
  22282. /**
  22283. * Stores the value of the alpha mode
  22284. */
  22285. private _alphaMode;
  22286. /**
  22287. * Sets the value of the alpha mode.
  22288. *
  22289. * | Value | Type | Description |
  22290. * | --- | --- | --- |
  22291. * | 0 | ALPHA_DISABLE | |
  22292. * | 1 | ALPHA_ADD | |
  22293. * | 2 | ALPHA_COMBINE | |
  22294. * | 3 | ALPHA_SUBTRACT | |
  22295. * | 4 | ALPHA_MULTIPLY | |
  22296. * | 5 | ALPHA_MAXIMIZED | |
  22297. * | 6 | ALPHA_ONEONE | |
  22298. * | 7 | ALPHA_PREMULTIPLIED | |
  22299. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  22300. * | 9 | ALPHA_INTERPOLATE | |
  22301. * | 10 | ALPHA_SCREENMODE | |
  22302. *
  22303. */
  22304. /**
  22305. * Gets the value of the alpha mode
  22306. */
  22307. alphaMode: number;
  22308. /**
  22309. * Stores the state of the need depth pre-pass value
  22310. */
  22311. private _needDepthPrePass;
  22312. /**
  22313. * Sets the need depth pre-pass value
  22314. */
  22315. /**
  22316. * Gets the depth pre-pass value
  22317. */
  22318. needDepthPrePass: boolean;
  22319. /**
  22320. * Specifies if depth writing should be disabled
  22321. */
  22322. disableDepthWrite: boolean;
  22323. /**
  22324. * Specifies if depth writing should be forced
  22325. */
  22326. forceDepthWrite: boolean;
  22327. /**
  22328. * Specifies if there should be a separate pass for culling
  22329. */
  22330. separateCullingPass: boolean;
  22331. /**
  22332. * Stores the state specifing if fog should be enabled
  22333. */
  22334. private _fogEnabled;
  22335. /**
  22336. * Sets the state for enabling fog
  22337. */
  22338. /**
  22339. * Gets the value of the fog enabled state
  22340. */
  22341. fogEnabled: boolean;
  22342. /**
  22343. * Stores the size of points
  22344. */
  22345. pointSize: number;
  22346. /**
  22347. * Stores the z offset value
  22348. */
  22349. zOffset: number;
  22350. /**
  22351. * Gets a value specifying if wireframe mode is enabled
  22352. */
  22353. /**
  22354. * Sets the state of wireframe mode
  22355. */
  22356. wireframe: boolean;
  22357. /**
  22358. * Gets the value specifying if point clouds are enabled
  22359. */
  22360. /**
  22361. * Sets the state of point cloud mode
  22362. */
  22363. pointsCloud: boolean;
  22364. /**
  22365. * Gets the material fill mode
  22366. */
  22367. /**
  22368. * Sets the material fill mode
  22369. */
  22370. fillMode: number;
  22371. /**
  22372. * @hidden
  22373. * Stores the effects for the material
  22374. */
  22375. _effect: Nullable<Effect>;
  22376. /**
  22377. * @hidden
  22378. * Specifies if the material was previously ready
  22379. */
  22380. _wasPreviouslyReady: boolean;
  22381. /**
  22382. * Specifies if uniform buffers should be used
  22383. */
  22384. private _useUBO;
  22385. /**
  22386. * Stores a reference to the scene
  22387. */
  22388. private _scene;
  22389. /**
  22390. * Stores the fill mode state
  22391. */
  22392. private _fillMode;
  22393. /**
  22394. * Specifies if the depth write state should be cached
  22395. */
  22396. private _cachedDepthWriteState;
  22397. /**
  22398. * Stores the uniform buffer
  22399. */
  22400. protected _uniformBuffer: UniformBuffer;
  22401. /** @hidden */
  22402. _indexInSceneMaterialArray: number;
  22403. /** @hidden */
  22404. meshMap: Nullable<{
  22405. [id: string]: AbstractMesh | undefined;
  22406. }>;
  22407. /**
  22408. * Creates a material instance
  22409. * @param name defines the name of the material
  22410. * @param scene defines the scene to reference
  22411. * @param doNotAdd specifies if the material should be added to the scene
  22412. */
  22413. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  22414. /**
  22415. * Returns a string representation of the current material
  22416. * @param fullDetails defines a boolean indicating which levels of logging is desired
  22417. * @returns a string with material information
  22418. */
  22419. toString(fullDetails?: boolean): string;
  22420. /**
  22421. * Gets the class name of the material
  22422. * @returns a string with the class name of the material
  22423. */
  22424. getClassName(): string;
  22425. /**
  22426. * Specifies if updates for the material been locked
  22427. */
  22428. readonly isFrozen: boolean;
  22429. /**
  22430. * Locks updates for the material
  22431. */
  22432. freeze(): void;
  22433. /**
  22434. * Unlocks updates for the material
  22435. */
  22436. unfreeze(): void;
  22437. /**
  22438. * Specifies if the material is ready to be used
  22439. * @param mesh defines the mesh to check
  22440. * @param useInstances specifies if instances should be used
  22441. * @returns a boolean indicating if the material is ready to be used
  22442. */
  22443. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  22444. /**
  22445. * Specifies that the submesh is ready to be used
  22446. * @param mesh defines the mesh to check
  22447. * @param subMesh defines which submesh to check
  22448. * @param useInstances specifies that instances should be used
  22449. * @returns a boolean indicating that the submesh is ready or not
  22450. */
  22451. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  22452. /**
  22453. * Returns the material effect
  22454. * @returns the effect associated with the material
  22455. */
  22456. getEffect(): Nullable<Effect>;
  22457. /**
  22458. * Returns the current scene
  22459. * @returns a Scene
  22460. */
  22461. getScene(): Scene;
  22462. /**
  22463. * Specifies if the material will require alpha blending
  22464. * @returns a boolean specifying if alpha blending is needed
  22465. */
  22466. needAlphaBlending(): boolean;
  22467. /**
  22468. * Specifies if the mesh will require alpha blending
  22469. * @param mesh defines the mesh to check
  22470. * @returns a boolean specifying if alpha blending is needed for the mesh
  22471. */
  22472. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  22473. /**
  22474. * Specifies if this material should be rendered in alpha test mode
  22475. * @returns a boolean specifying if an alpha test is needed.
  22476. */
  22477. needAlphaTesting(): boolean;
  22478. /**
  22479. * Gets the texture used for the alpha test
  22480. * @returns the texture to use for alpha testing
  22481. */
  22482. getAlphaTestTexture(): Nullable<BaseTexture>;
  22483. /**
  22484. * Marks the material to indicate that it needs to be re-calculated
  22485. */
  22486. markDirty(): void;
  22487. /** @hidden */
  22488. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  22489. /**
  22490. * Binds the material to the mesh
  22491. * @param world defines the world transformation matrix
  22492. * @param mesh defines the mesh to bind the material to
  22493. */
  22494. bind(world: Matrix, mesh?: Mesh): void;
  22495. /**
  22496. * Binds the submesh to the material
  22497. * @param world defines the world transformation matrix
  22498. * @param mesh defines the mesh containing the submesh
  22499. * @param subMesh defines the submesh to bind the material to
  22500. */
  22501. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  22502. /**
  22503. * Binds the world matrix to the material
  22504. * @param world defines the world transformation matrix
  22505. */
  22506. bindOnlyWorldMatrix(world: Matrix): void;
  22507. /**
  22508. * Binds the scene's uniform buffer to the effect.
  22509. * @param effect defines the effect to bind to the scene uniform buffer
  22510. * @param sceneUbo defines the uniform buffer storing scene data
  22511. */
  22512. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  22513. /**
  22514. * Binds the view matrix to the effect
  22515. * @param effect defines the effect to bind the view matrix to
  22516. */
  22517. bindView(effect: Effect): void;
  22518. /**
  22519. * Binds the view projection matrix to the effect
  22520. * @param effect defines the effect to bind the view projection matrix to
  22521. */
  22522. bindViewProjection(effect: Effect): void;
  22523. /**
  22524. * Specifies if material alpha testing should be turned on for the mesh
  22525. * @param mesh defines the mesh to check
  22526. */
  22527. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  22528. /**
  22529. * Processes to execute after binding the material to a mesh
  22530. * @param mesh defines the rendered mesh
  22531. */
  22532. protected _afterBind(mesh?: Mesh): void;
  22533. /**
  22534. * Unbinds the material from the mesh
  22535. */
  22536. unbind(): void;
  22537. /**
  22538. * Gets the active textures from the material
  22539. * @returns an array of textures
  22540. */
  22541. getActiveTextures(): BaseTexture[];
  22542. /**
  22543. * Specifies if the material uses a texture
  22544. * @param texture defines the texture to check against the material
  22545. * @returns a boolean specifying if the material uses the texture
  22546. */
  22547. hasTexture(texture: BaseTexture): boolean;
  22548. /**
  22549. * Makes a duplicate of the material, and gives it a new name
  22550. * @param name defines the new name for the duplicated material
  22551. * @returns the cloned material
  22552. */
  22553. clone(name: string): Nullable<Material>;
  22554. /**
  22555. * Gets the meshes bound to the material
  22556. * @returns an array of meshes bound to the material
  22557. */
  22558. getBindedMeshes(): AbstractMesh[];
  22559. /**
  22560. * Force shader compilation
  22561. * @param mesh defines the mesh associated with this material
  22562. * @param onCompiled defines a function to execute once the material is compiled
  22563. * @param options defines the options to configure the compilation
  22564. */
  22565. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  22566. clipPlane: boolean;
  22567. }>): void;
  22568. /**
  22569. * Force shader compilation
  22570. * @param mesh defines the mesh that will use this material
  22571. * @param options defines additional options for compiling the shaders
  22572. * @returns a promise that resolves when the compilation completes
  22573. */
  22574. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  22575. clipPlane: boolean;
  22576. }>): Promise<void>;
  22577. private static readonly _ImageProcessingDirtyCallBack;
  22578. private static readonly _TextureDirtyCallBack;
  22579. private static readonly _FresnelDirtyCallBack;
  22580. private static readonly _MiscDirtyCallBack;
  22581. private static readonly _LightsDirtyCallBack;
  22582. private static readonly _AttributeDirtyCallBack;
  22583. private static _FresnelAndMiscDirtyCallBack;
  22584. private static _TextureAndMiscDirtyCallBack;
  22585. private static readonly _DirtyCallbackArray;
  22586. private static readonly _RunDirtyCallBacks;
  22587. /**
  22588. * Marks a define in the material to indicate that it needs to be re-computed
  22589. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  22590. */
  22591. markAsDirty(flag: number): void;
  22592. /**
  22593. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  22594. * @param func defines a function which checks material defines against the submeshes
  22595. */
  22596. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  22597. /**
  22598. * Indicates that image processing needs to be re-calculated for all submeshes
  22599. */
  22600. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  22601. /**
  22602. * Indicates that textures need to be re-calculated for all submeshes
  22603. */
  22604. protected _markAllSubMeshesAsTexturesDirty(): void;
  22605. /**
  22606. * Indicates that fresnel needs to be re-calculated for all submeshes
  22607. */
  22608. protected _markAllSubMeshesAsFresnelDirty(): void;
  22609. /**
  22610. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  22611. */
  22612. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  22613. /**
  22614. * Indicates that lights need to be re-calculated for all submeshes
  22615. */
  22616. protected _markAllSubMeshesAsLightsDirty(): void;
  22617. /**
  22618. * Indicates that attributes need to be re-calculated for all submeshes
  22619. */
  22620. protected _markAllSubMeshesAsAttributesDirty(): void;
  22621. /**
  22622. * Indicates that misc needs to be re-calculated for all submeshes
  22623. */
  22624. protected _markAllSubMeshesAsMiscDirty(): void;
  22625. /**
  22626. * Indicates that textures and misc need to be re-calculated for all submeshes
  22627. */
  22628. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  22629. /**
  22630. * Disposes the material
  22631. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  22632. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  22633. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  22634. */
  22635. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  22636. /** @hidden */
  22637. private releaseVertexArrayObject;
  22638. /**
  22639. * Serializes this material
  22640. * @returns the serialized material object
  22641. */
  22642. serialize(): any;
  22643. /**
  22644. * Creates a material from parsed material data
  22645. * @param parsedMaterial defines parsed material data
  22646. * @param scene defines the hosting scene
  22647. * @param rootUrl defines the root URL to use to load textures
  22648. * @returns a new material
  22649. */
  22650. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  22651. }
  22652. }
  22653. declare module "babylonjs/Meshes/subMesh" {
  22654. import { Nullable, IndicesArray, DeepImmutable } from "babylonjs/types";
  22655. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  22656. import { Engine } from "babylonjs/Engines/engine";
  22657. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  22658. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  22659. import { Effect } from "babylonjs/Materials/effect";
  22660. import { Collider } from "babylonjs/Collisions/collider";
  22661. import { Material } from "babylonjs/Materials/material";
  22662. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  22663. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22664. import { Mesh } from "babylonjs/Meshes/mesh";
  22665. import { Ray } from "babylonjs/Culling/ray";
  22666. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  22667. /**
  22668. * Base class for submeshes
  22669. */
  22670. export class BaseSubMesh {
  22671. /** @hidden */
  22672. _materialDefines: Nullable<MaterialDefines>;
  22673. /** @hidden */
  22674. _materialEffect: Nullable<Effect>;
  22675. /**
  22676. * Gets associated effect
  22677. */
  22678. readonly effect: Nullable<Effect>;
  22679. /**
  22680. * Sets associated effect (effect used to render this submesh)
  22681. * @param effect defines the effect to associate with
  22682. * @param defines defines the set of defines used to compile this effect
  22683. */
  22684. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  22685. }
  22686. /**
  22687. * Defines a subdivision inside a mesh
  22688. */
  22689. export class SubMesh extends BaseSubMesh implements ICullable {
  22690. /** the material index to use */
  22691. materialIndex: number;
  22692. /** vertex index start */
  22693. verticesStart: number;
  22694. /** vertices count */
  22695. verticesCount: number;
  22696. /** index start */
  22697. indexStart: number;
  22698. /** indices count */
  22699. indexCount: number;
  22700. /** @hidden */
  22701. _linesIndexCount: number;
  22702. private _mesh;
  22703. private _renderingMesh;
  22704. private _boundingInfo;
  22705. private _linesIndexBuffer;
  22706. /** @hidden */
  22707. _lastColliderWorldVertices: Nullable<Vector3[]>;
  22708. /** @hidden */
  22709. _trianglePlanes: Plane[];
  22710. /** @hidden */
  22711. _lastColliderTransformMatrix: Matrix;
  22712. /** @hidden */
  22713. _renderId: number;
  22714. /** @hidden */
  22715. _alphaIndex: number;
  22716. /** @hidden */
  22717. _distanceToCamera: number;
  22718. /** @hidden */
  22719. _id: number;
  22720. private _currentMaterial;
  22721. /**
  22722. * Add a new submesh to a mesh
  22723. * @param materialIndex defines the material index to use
  22724. * @param verticesStart defines vertex index start
  22725. * @param verticesCount defines vertices count
  22726. * @param indexStart defines index start
  22727. * @param indexCount defines indices count
  22728. * @param mesh defines the parent mesh
  22729. * @param renderingMesh defines an optional rendering mesh
  22730. * @param createBoundingBox defines if bounding box should be created for this submesh
  22731. * @returns the new submesh
  22732. */
  22733. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  22734. /**
  22735. * Creates a new submesh
  22736. * @param materialIndex defines the material index to use
  22737. * @param verticesStart defines vertex index start
  22738. * @param verticesCount defines vertices count
  22739. * @param indexStart defines index start
  22740. * @param indexCount defines indices count
  22741. * @param mesh defines the parent mesh
  22742. * @param renderingMesh defines an optional rendering mesh
  22743. * @param createBoundingBox defines if bounding box should be created for this submesh
  22744. */
  22745. constructor(
  22746. /** the material index to use */
  22747. materialIndex: number,
  22748. /** vertex index start */
  22749. verticesStart: number,
  22750. /** vertices count */
  22751. verticesCount: number,
  22752. /** index start */
  22753. indexStart: number,
  22754. /** indices count */
  22755. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  22756. /**
  22757. * Returns true if this submesh covers the entire parent mesh
  22758. * @ignorenaming
  22759. */
  22760. readonly IsGlobal: boolean;
  22761. /**
  22762. * Returns the submesh BoudingInfo object
  22763. * @returns current bounding info (or mesh's one if the submesh is global)
  22764. */
  22765. getBoundingInfo(): BoundingInfo;
  22766. /**
  22767. * Sets the submesh BoundingInfo
  22768. * @param boundingInfo defines the new bounding info to use
  22769. * @returns the SubMesh
  22770. */
  22771. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  22772. /**
  22773. * Returns the mesh of the current submesh
  22774. * @return the parent mesh
  22775. */
  22776. getMesh(): AbstractMesh;
  22777. /**
  22778. * Returns the rendering mesh of the submesh
  22779. * @returns the rendering mesh (could be different from parent mesh)
  22780. */
  22781. getRenderingMesh(): Mesh;
  22782. /**
  22783. * Returns the submesh material
  22784. * @returns null or the current material
  22785. */
  22786. getMaterial(): Nullable<Material>;
  22787. /**
  22788. * Sets a new updated BoundingInfo object to the submesh
  22789. * @returns the SubMesh
  22790. */
  22791. refreshBoundingInfo(): SubMesh;
  22792. /** @hidden */
  22793. _checkCollision(collider: Collider): boolean;
  22794. /**
  22795. * Updates the submesh BoundingInfo
  22796. * @param world defines the world matrix to use to update the bounding info
  22797. * @returns the submesh
  22798. */
  22799. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  22800. /**
  22801. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  22802. * @param frustumPlanes defines the frustum planes
  22803. * @returns true if the submesh is intersecting with the frustum
  22804. */
  22805. isInFrustum(frustumPlanes: Plane[]): boolean;
  22806. /**
  22807. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  22808. * @param frustumPlanes defines the frustum planes
  22809. * @returns true if the submesh is inside the frustum
  22810. */
  22811. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  22812. /**
  22813. * Renders the submesh
  22814. * @param enableAlphaMode defines if alpha needs to be used
  22815. * @returns the submesh
  22816. */
  22817. render(enableAlphaMode: boolean): SubMesh;
  22818. /**
  22819. * @hidden
  22820. */
  22821. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): WebGLBuffer;
  22822. /**
  22823. * Checks if the submesh intersects with a ray
  22824. * @param ray defines the ray to test
  22825. * @returns true is the passed ray intersects the submesh bounding box
  22826. */
  22827. canIntersects(ray: Ray): boolean;
  22828. /**
  22829. * Intersects current submesh with a ray
  22830. * @param ray defines the ray to test
  22831. * @param positions defines mesh's positions array
  22832. * @param indices defines mesh's indices array
  22833. * @param fastCheck defines if only bounding info should be used
  22834. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  22835. * @returns intersection info or null if no intersection
  22836. */
  22837. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  22838. /** @hidden */
  22839. private _intersectLines;
  22840. /** @hidden */
  22841. private _intersectTriangles;
  22842. /** @hidden */
  22843. _rebuild(): void;
  22844. /**
  22845. * Creates a new submesh from the passed mesh
  22846. * @param newMesh defines the new hosting mesh
  22847. * @param newRenderingMesh defines an optional rendering mesh
  22848. * @returns the new submesh
  22849. */
  22850. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  22851. /**
  22852. * Release associated resources
  22853. */
  22854. dispose(): void;
  22855. /**
  22856. * Gets the class name
  22857. * @returns the string "SubMesh".
  22858. */
  22859. getClassName(): string;
  22860. /**
  22861. * Creates a new submesh from indices data
  22862. * @param materialIndex the index of the main mesh material
  22863. * @param startIndex the index where to start the copy in the mesh indices array
  22864. * @param indexCount the number of indices to copy then from the startIndex
  22865. * @param mesh the main mesh to create the submesh from
  22866. * @param renderingMesh the optional rendering mesh
  22867. * @returns a new submesh
  22868. */
  22869. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  22870. }
  22871. }
  22872. declare module "babylonjs/Meshes/geometry" {
  22873. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  22874. import { Scene } from "babylonjs/scene";
  22875. import { Vector3, Vector2 } from "babylonjs/Maths/math";
  22876. import { Engine } from "babylonjs/Engines/engine";
  22877. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  22878. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  22879. import { Effect } from "babylonjs/Materials/effect";
  22880. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  22881. import { Mesh } from "babylonjs/Meshes/mesh";
  22882. /**
  22883. * Class used to store geometry data (vertex buffers + index buffer)
  22884. */
  22885. export class Geometry implements IGetSetVerticesData {
  22886. /**
  22887. * Gets or sets the ID of the geometry
  22888. */
  22889. id: string;
  22890. /**
  22891. * Gets or sets the unique ID of the geometry
  22892. */
  22893. uniqueId: number;
  22894. /**
  22895. * Gets the delay loading state of the geometry (none by default which means not delayed)
  22896. */
  22897. delayLoadState: number;
  22898. /**
  22899. * Gets the file containing the data to load when running in delay load state
  22900. */
  22901. delayLoadingFile: Nullable<string>;
  22902. /**
  22903. * Callback called when the geometry is updated
  22904. */
  22905. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  22906. private _scene;
  22907. private _engine;
  22908. private _meshes;
  22909. private _totalVertices;
  22910. /** @hidden */
  22911. _indices: IndicesArray;
  22912. /** @hidden */
  22913. _vertexBuffers: {
  22914. [key: string]: VertexBuffer;
  22915. };
  22916. private _isDisposed;
  22917. private _extend;
  22918. private _boundingBias;
  22919. /** @hidden */
  22920. _delayInfo: Array<string>;
  22921. private _indexBuffer;
  22922. private _indexBufferIsUpdatable;
  22923. /** @hidden */
  22924. _boundingInfo: Nullable<BoundingInfo>;
  22925. /** @hidden */
  22926. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  22927. /** @hidden */
  22928. _softwareSkinningFrameId: number;
  22929. private _vertexArrayObjects;
  22930. private _updatable;
  22931. /** @hidden */
  22932. _positions: Nullable<Vector3[]>;
  22933. /**
  22934. * 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
  22935. */
  22936. /**
  22937. * 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
  22938. */
  22939. boundingBias: Vector2;
  22940. /**
  22941. * Static function used to attach a new empty geometry to a mesh
  22942. * @param mesh defines the mesh to attach the geometry to
  22943. * @returns the new Geometry
  22944. */
  22945. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  22946. /**
  22947. * Creates a new geometry
  22948. * @param id defines the unique ID
  22949. * @param scene defines the hosting scene
  22950. * @param vertexData defines the VertexData used to get geometry data
  22951. * @param updatable defines if geometry must be updatable (false by default)
  22952. * @param mesh defines the mesh that will be associated with the geometry
  22953. */
  22954. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  22955. /**
  22956. * Gets the current extend of the geometry
  22957. */
  22958. readonly extend: {
  22959. minimum: Vector3;
  22960. maximum: Vector3;
  22961. };
  22962. /**
  22963. * Gets the hosting scene
  22964. * @returns the hosting Scene
  22965. */
  22966. getScene(): Scene;
  22967. /**
  22968. * Gets the hosting engine
  22969. * @returns the hosting Engine
  22970. */
  22971. getEngine(): Engine;
  22972. /**
  22973. * Defines if the geometry is ready to use
  22974. * @returns true if the geometry is ready to be used
  22975. */
  22976. isReady(): boolean;
  22977. /**
  22978. * Gets a value indicating that the geometry should not be serialized
  22979. */
  22980. readonly doNotSerialize: boolean;
  22981. /** @hidden */
  22982. _rebuild(): void;
  22983. /**
  22984. * Affects all geometry data in one call
  22985. * @param vertexData defines the geometry data
  22986. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  22987. */
  22988. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  22989. /**
  22990. * Set specific vertex data
  22991. * @param kind defines the data kind (Position, normal, etc...)
  22992. * @param data defines the vertex data to use
  22993. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22994. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22995. */
  22996. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  22997. /**
  22998. * Removes a specific vertex data
  22999. * @param kind defines the data kind (Position, normal, etc...)
  23000. */
  23001. removeVerticesData(kind: string): void;
  23002. /**
  23003. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  23004. * @param buffer defines the vertex buffer to use
  23005. * @param totalVertices defines the total number of vertices for position kind (could be null)
  23006. */
  23007. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  23008. /**
  23009. * Update a specific vertex buffer
  23010. * This function will directly update the underlying WebGLBuffer according to the passed numeric array or Float32Array
  23011. * It will do nothing if the buffer is not updatable
  23012. * @param kind defines the data kind (Position, normal, etc...)
  23013. * @param data defines the data to use
  23014. * @param offset defines the offset in the target buffer where to store the data
  23015. * @param useBytes set to true if the offset is in bytes
  23016. */
  23017. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  23018. /**
  23019. * Update a specific vertex buffer
  23020. * This function will create a new buffer if the current one is not updatable
  23021. * @param kind defines the data kind (Position, normal, etc...)
  23022. * @param data defines the data to use
  23023. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  23024. */
  23025. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  23026. private _updateBoundingInfo;
  23027. /** @hidden */
  23028. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<WebGLBuffer>): void;
  23029. /**
  23030. * Gets total number of vertices
  23031. * @returns the total number of vertices
  23032. */
  23033. getTotalVertices(): number;
  23034. /**
  23035. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  23036. * @param kind defines the data kind (Position, normal, etc...)
  23037. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  23038. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23039. * @returns a float array containing vertex data
  23040. */
  23041. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  23042. /**
  23043. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  23044. * @param kind defines the data kind (Position, normal, etc...)
  23045. * @returns true if the vertex buffer with the specified kind is updatable
  23046. */
  23047. isVertexBufferUpdatable(kind: string): boolean;
  23048. /**
  23049. * Gets a specific vertex buffer
  23050. * @param kind defines the data kind (Position, normal, etc...)
  23051. * @returns a VertexBuffer
  23052. */
  23053. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  23054. /**
  23055. * Returns all vertex buffers
  23056. * @return an object holding all vertex buffers indexed by kind
  23057. */
  23058. getVertexBuffers(): Nullable<{
  23059. [key: string]: VertexBuffer;
  23060. }>;
  23061. /**
  23062. * Gets a boolean indicating if specific vertex buffer is present
  23063. * @param kind defines the data kind (Position, normal, etc...)
  23064. * @returns true if data is present
  23065. */
  23066. isVerticesDataPresent(kind: string): boolean;
  23067. /**
  23068. * Gets a list of all attached data kinds (Position, normal, etc...)
  23069. * @returns a list of string containing all kinds
  23070. */
  23071. getVerticesDataKinds(): string[];
  23072. /**
  23073. * Update index buffer
  23074. * @param indices defines the indices to store in the index buffer
  23075. * @param offset defines the offset in the target buffer where to store the data
  23076. * @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)
  23077. */
  23078. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  23079. /**
  23080. * Creates a new index buffer
  23081. * @param indices defines the indices to store in the index buffer
  23082. * @param totalVertices defines the total number of vertices (could be null)
  23083. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  23084. */
  23085. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  23086. /**
  23087. * Return the total number of indices
  23088. * @returns the total number of indices
  23089. */
  23090. getTotalIndices(): number;
  23091. /**
  23092. * Gets the index buffer array
  23093. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  23094. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23095. * @returns the index buffer array
  23096. */
  23097. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  23098. /**
  23099. * Gets the index buffer
  23100. * @return the index buffer
  23101. */
  23102. getIndexBuffer(): Nullable<WebGLBuffer>;
  23103. /** @hidden */
  23104. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  23105. /**
  23106. * Release the associated resources for a specific mesh
  23107. * @param mesh defines the source mesh
  23108. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  23109. */
  23110. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  23111. /**
  23112. * Apply current geometry to a given mesh
  23113. * @param mesh defines the mesh to apply geometry to
  23114. */
  23115. applyToMesh(mesh: Mesh): void;
  23116. private _updateExtend;
  23117. private _applyToMesh;
  23118. private notifyUpdate;
  23119. /**
  23120. * Load the geometry if it was flagged as delay loaded
  23121. * @param scene defines the hosting scene
  23122. * @param onLoaded defines a callback called when the geometry is loaded
  23123. */
  23124. load(scene: Scene, onLoaded?: () => void): void;
  23125. private _queueLoad;
  23126. /**
  23127. * Invert the geometry to move from a right handed system to a left handed one.
  23128. */
  23129. toLeftHanded(): void;
  23130. /** @hidden */
  23131. _resetPointsArrayCache(): void;
  23132. /** @hidden */
  23133. _generatePointsArray(): boolean;
  23134. /**
  23135. * Gets a value indicating if the geometry is disposed
  23136. * @returns true if the geometry was disposed
  23137. */
  23138. isDisposed(): boolean;
  23139. private _disposeVertexArrayObjects;
  23140. /**
  23141. * Free all associated resources
  23142. */
  23143. dispose(): void;
  23144. /**
  23145. * Clone the current geometry into a new geometry
  23146. * @param id defines the unique ID of the new geometry
  23147. * @returns a new geometry object
  23148. */
  23149. copy(id: string): Geometry;
  23150. /**
  23151. * Serialize the current geometry info (and not the vertices data) into a JSON object
  23152. * @return a JSON representation of the current geometry data (without the vertices data)
  23153. */
  23154. serialize(): any;
  23155. private toNumberArray;
  23156. /**
  23157. * Serialize all vertices data into a JSON oject
  23158. * @returns a JSON representation of the current geometry data
  23159. */
  23160. serializeVerticeData(): any;
  23161. /**
  23162. * Extracts a clone of a mesh geometry
  23163. * @param mesh defines the source mesh
  23164. * @param id defines the unique ID of the new geometry object
  23165. * @returns the new geometry object
  23166. */
  23167. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  23168. /**
  23169. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  23170. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  23171. * Be aware Math.random() could cause collisions, but:
  23172. * "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"
  23173. * @returns a string containing a new GUID
  23174. */
  23175. static RandomId(): string;
  23176. /** @hidden */
  23177. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  23178. private static _CleanMatricesWeights;
  23179. /**
  23180. * Create a new geometry from persisted data (Using .babylon file format)
  23181. * @param parsedVertexData defines the persisted data
  23182. * @param scene defines the hosting scene
  23183. * @param rootUrl defines the root url to use to load assets (like delayed data)
  23184. * @returns the new geometry object
  23185. */
  23186. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  23187. }
  23188. }
  23189. declare module "babylonjs/Meshes/mesh.vertexData" {
  23190. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  23191. import { Matrix, Vector3, Vector2, Color3, Color4, Vector4 } from "babylonjs/Maths/math";
  23192. import { Geometry } from "babylonjs/Meshes/geometry";
  23193. import { Mesh } from "babylonjs/Meshes/mesh";
  23194. /**
  23195. * Define an interface for all classes that will get and set the data on vertices
  23196. */
  23197. export interface IGetSetVerticesData {
  23198. /**
  23199. * Gets a boolean indicating if specific vertex data is present
  23200. * @param kind defines the vertex data kind to use
  23201. * @returns true is data kind is present
  23202. */
  23203. isVerticesDataPresent(kind: string): boolean;
  23204. /**
  23205. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  23206. * @param kind defines the data kind (Position, normal, etc...)
  23207. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  23208. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23209. * @returns a float array containing vertex data
  23210. */
  23211. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  23212. /**
  23213. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  23214. * @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.
  23215. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23216. * @returns the indices array or an empty array if the mesh has no geometry
  23217. */
  23218. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  23219. /**
  23220. * Set specific vertex data
  23221. * @param kind defines the data kind (Position, normal, etc...)
  23222. * @param data defines the vertex data to use
  23223. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  23224. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  23225. */
  23226. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  23227. /**
  23228. * Update a specific associated vertex buffer
  23229. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  23230. * - VertexBuffer.PositionKind
  23231. * - VertexBuffer.UVKind
  23232. * - VertexBuffer.UV2Kind
  23233. * - VertexBuffer.UV3Kind
  23234. * - VertexBuffer.UV4Kind
  23235. * - VertexBuffer.UV5Kind
  23236. * - VertexBuffer.UV6Kind
  23237. * - VertexBuffer.ColorKind
  23238. * - VertexBuffer.MatricesIndicesKind
  23239. * - VertexBuffer.MatricesIndicesExtraKind
  23240. * - VertexBuffer.MatricesWeightsKind
  23241. * - VertexBuffer.MatricesWeightsExtraKind
  23242. * @param data defines the data source
  23243. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  23244. * @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)
  23245. */
  23246. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  23247. /**
  23248. * Creates a new index buffer
  23249. * @param indices defines the indices to store in the index buffer
  23250. * @param totalVertices defines the total number of vertices (could be null)
  23251. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  23252. */
  23253. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  23254. }
  23255. /**
  23256. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  23257. */
  23258. export class VertexData {
  23259. /**
  23260. * Mesh side orientation : usually the external or front surface
  23261. */
  23262. static readonly FRONTSIDE: number;
  23263. /**
  23264. * Mesh side orientation : usually the internal or back surface
  23265. */
  23266. static readonly BACKSIDE: number;
  23267. /**
  23268. * Mesh side orientation : both internal and external or front and back surfaces
  23269. */
  23270. static readonly DOUBLESIDE: number;
  23271. /**
  23272. * Mesh side orientation : by default, `FRONTSIDE`
  23273. */
  23274. static readonly DEFAULTSIDE: number;
  23275. /**
  23276. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  23277. */
  23278. positions: Nullable<FloatArray>;
  23279. /**
  23280. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  23281. */
  23282. normals: Nullable<FloatArray>;
  23283. /**
  23284. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  23285. */
  23286. tangents: Nullable<FloatArray>;
  23287. /**
  23288. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23289. */
  23290. uvs: Nullable<FloatArray>;
  23291. /**
  23292. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23293. */
  23294. uvs2: Nullable<FloatArray>;
  23295. /**
  23296. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23297. */
  23298. uvs3: Nullable<FloatArray>;
  23299. /**
  23300. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23301. */
  23302. uvs4: Nullable<FloatArray>;
  23303. /**
  23304. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23305. */
  23306. uvs5: Nullable<FloatArray>;
  23307. /**
  23308. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23309. */
  23310. uvs6: Nullable<FloatArray>;
  23311. /**
  23312. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  23313. */
  23314. colors: Nullable<FloatArray>;
  23315. /**
  23316. * 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).
  23317. */
  23318. matricesIndices: Nullable<FloatArray>;
  23319. /**
  23320. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  23321. */
  23322. matricesWeights: Nullable<FloatArray>;
  23323. /**
  23324. * An array extending the number of possible indices
  23325. */
  23326. matricesIndicesExtra: Nullable<FloatArray>;
  23327. /**
  23328. * An array extending the number of possible weights when the number of indices is extended
  23329. */
  23330. matricesWeightsExtra: Nullable<FloatArray>;
  23331. /**
  23332. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  23333. */
  23334. indices: Nullable<IndicesArray>;
  23335. /**
  23336. * Uses the passed data array to set the set the values for the specified kind of data
  23337. * @param data a linear array of floating numbers
  23338. * @param kind the type of data that is being set, eg positions, colors etc
  23339. */
  23340. set(data: FloatArray, kind: string): void;
  23341. /**
  23342. * Associates the vertexData to the passed Mesh.
  23343. * Sets it as updatable or not (default `false`)
  23344. * @param mesh the mesh the vertexData is applied to
  23345. * @param updatable when used and having the value true allows new data to update the vertexData
  23346. * @returns the VertexData
  23347. */
  23348. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  23349. /**
  23350. * Associates the vertexData to the passed Geometry.
  23351. * Sets it as updatable or not (default `false`)
  23352. * @param geometry the geometry the vertexData is applied to
  23353. * @param updatable when used and having the value true allows new data to update the vertexData
  23354. * @returns VertexData
  23355. */
  23356. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  23357. /**
  23358. * Updates the associated mesh
  23359. * @param mesh the mesh to be updated
  23360. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  23361. * @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
  23362. * @returns VertexData
  23363. */
  23364. updateMesh(mesh: Mesh): VertexData;
  23365. /**
  23366. * Updates the associated geometry
  23367. * @param geometry the geometry to be updated
  23368. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  23369. * @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
  23370. * @returns VertexData.
  23371. */
  23372. updateGeometry(geometry: Geometry): VertexData;
  23373. private _applyTo;
  23374. private _update;
  23375. /**
  23376. * Transforms each position and each normal of the vertexData according to the passed Matrix
  23377. * @param matrix the transforming matrix
  23378. * @returns the VertexData
  23379. */
  23380. transform(matrix: Matrix): VertexData;
  23381. /**
  23382. * Merges the passed VertexData into the current one
  23383. * @param other the VertexData to be merged into the current one
  23384. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  23385. * @returns the modified VertexData
  23386. */
  23387. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  23388. private _mergeElement;
  23389. private _validate;
  23390. /**
  23391. * Serializes the VertexData
  23392. * @returns a serialized object
  23393. */
  23394. serialize(): any;
  23395. /**
  23396. * Extracts the vertexData from a mesh
  23397. * @param mesh the mesh from which to extract the VertexData
  23398. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  23399. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  23400. * @returns the object VertexData associated to the passed mesh
  23401. */
  23402. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  23403. /**
  23404. * Extracts the vertexData from the geometry
  23405. * @param geometry the geometry from which to extract the VertexData
  23406. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  23407. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  23408. * @returns the object VertexData associated to the passed mesh
  23409. */
  23410. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  23411. private static _ExtractFrom;
  23412. /**
  23413. * Creates the VertexData for a Ribbon
  23414. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  23415. * * pathArray array of paths, each of which an array of successive Vector3
  23416. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  23417. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  23418. * * 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
  23419. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23420. * * 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)
  23421. * * 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)
  23422. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  23423. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  23424. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  23425. * @returns the VertexData of the ribbon
  23426. */
  23427. static CreateRibbon(options: {
  23428. pathArray: Vector3[][];
  23429. closeArray?: boolean;
  23430. closePath?: boolean;
  23431. offset?: number;
  23432. sideOrientation?: number;
  23433. frontUVs?: Vector4;
  23434. backUVs?: Vector4;
  23435. invertUV?: boolean;
  23436. uvs?: Vector2[];
  23437. colors?: Color4[];
  23438. }): VertexData;
  23439. /**
  23440. * Creates the VertexData for a box
  23441. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23442. * * size sets the width, height and depth of the box to the value of size, optional default 1
  23443. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  23444. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  23445. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  23446. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  23447. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  23448. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23449. * * 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)
  23450. * * 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)
  23451. * @returns the VertexData of the box
  23452. */
  23453. static CreateBox(options: {
  23454. size?: number;
  23455. width?: number;
  23456. height?: number;
  23457. depth?: number;
  23458. faceUV?: Vector4[];
  23459. faceColors?: Color4[];
  23460. sideOrientation?: number;
  23461. frontUVs?: Vector4;
  23462. backUVs?: Vector4;
  23463. }): VertexData;
  23464. /**
  23465. * Creates the VertexData for an ellipsoid, defaults to a sphere
  23466. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23467. * * segments sets the number of horizontal strips optional, default 32
  23468. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  23469. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  23470. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  23471. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  23472. * * 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
  23473. * * 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
  23474. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23475. * * 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)
  23476. * * 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)
  23477. * @returns the VertexData of the ellipsoid
  23478. */
  23479. static CreateSphere(options: {
  23480. segments?: number;
  23481. diameter?: number;
  23482. diameterX?: number;
  23483. diameterY?: number;
  23484. diameterZ?: number;
  23485. arc?: number;
  23486. slice?: number;
  23487. sideOrientation?: number;
  23488. frontUVs?: Vector4;
  23489. backUVs?: Vector4;
  23490. }): VertexData;
  23491. /**
  23492. * Creates the VertexData for a cylinder, cone or prism
  23493. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23494. * * height sets the height (y direction) of the cylinder, optional, default 2
  23495. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  23496. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  23497. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  23498. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  23499. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  23500. * * 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
  23501. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23502. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23503. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  23504. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  23505. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23506. * * 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)
  23507. * * 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)
  23508. * @returns the VertexData of the cylinder, cone or prism
  23509. */
  23510. static CreateCylinder(options: {
  23511. height?: number;
  23512. diameterTop?: number;
  23513. diameterBottom?: number;
  23514. diameter?: number;
  23515. tessellation?: number;
  23516. subdivisions?: number;
  23517. arc?: number;
  23518. faceColors?: Color4[];
  23519. faceUV?: Vector4[];
  23520. hasRings?: boolean;
  23521. enclose?: boolean;
  23522. sideOrientation?: number;
  23523. frontUVs?: Vector4;
  23524. backUVs?: Vector4;
  23525. }): VertexData;
  23526. /**
  23527. * Creates the VertexData for a torus
  23528. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23529. * * diameter the diameter of the torus, optional default 1
  23530. * * thickness the diameter of the tube forming the torus, optional default 0.5
  23531. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  23532. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23533. * * 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)
  23534. * * 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)
  23535. * @returns the VertexData of the torus
  23536. */
  23537. static CreateTorus(options: {
  23538. diameter?: number;
  23539. thickness?: number;
  23540. tessellation?: number;
  23541. sideOrientation?: number;
  23542. frontUVs?: Vector4;
  23543. backUVs?: Vector4;
  23544. }): VertexData;
  23545. /**
  23546. * Creates the VertexData of the LineSystem
  23547. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  23548. * - lines an array of lines, each line being an array of successive Vector3
  23549. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  23550. * @returns the VertexData of the LineSystem
  23551. */
  23552. static CreateLineSystem(options: {
  23553. lines: Vector3[][];
  23554. colors?: Nullable<Color4[][]>;
  23555. }): VertexData;
  23556. /**
  23557. * Create the VertexData for a DashedLines
  23558. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  23559. * - points an array successive Vector3
  23560. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  23561. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  23562. * - dashNb the intended total number of dashes, optional, default 200
  23563. * @returns the VertexData for the DashedLines
  23564. */
  23565. static CreateDashedLines(options: {
  23566. points: Vector3[];
  23567. dashSize?: number;
  23568. gapSize?: number;
  23569. dashNb?: number;
  23570. }): VertexData;
  23571. /**
  23572. * Creates the VertexData for a Ground
  23573. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  23574. * - width the width (x direction) of the ground, optional, default 1
  23575. * - height the height (z direction) of the ground, optional, default 1
  23576. * - subdivisions the number of subdivisions per side, optional, default 1
  23577. * @returns the VertexData of the Ground
  23578. */
  23579. static CreateGround(options: {
  23580. width?: number;
  23581. height?: number;
  23582. subdivisions?: number;
  23583. subdivisionsX?: number;
  23584. subdivisionsY?: number;
  23585. }): VertexData;
  23586. /**
  23587. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  23588. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  23589. * * xmin the ground minimum X coordinate, optional, default -1
  23590. * * zmin the ground minimum Z coordinate, optional, default -1
  23591. * * xmax the ground maximum X coordinate, optional, default 1
  23592. * * zmax the ground maximum Z coordinate, optional, default 1
  23593. * * 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}
  23594. * * 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}
  23595. * @returns the VertexData of the TiledGround
  23596. */
  23597. static CreateTiledGround(options: {
  23598. xmin: number;
  23599. zmin: number;
  23600. xmax: number;
  23601. zmax: number;
  23602. subdivisions?: {
  23603. w: number;
  23604. h: number;
  23605. };
  23606. precision?: {
  23607. w: number;
  23608. h: number;
  23609. };
  23610. }): VertexData;
  23611. /**
  23612. * Creates the VertexData of the Ground designed from a heightmap
  23613. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  23614. * * width the width (x direction) of the ground
  23615. * * height the height (z direction) of the ground
  23616. * * subdivisions the number of subdivisions per side
  23617. * * minHeight the minimum altitude on the ground, optional, default 0
  23618. * * maxHeight the maximum altitude on the ground, optional default 1
  23619. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  23620. * * buffer the array holding the image color data
  23621. * * bufferWidth the width of image
  23622. * * bufferHeight the height of image
  23623. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  23624. * @returns the VertexData of the Ground designed from a heightmap
  23625. */
  23626. static CreateGroundFromHeightMap(options: {
  23627. width: number;
  23628. height: number;
  23629. subdivisions: number;
  23630. minHeight: number;
  23631. maxHeight: number;
  23632. colorFilter: Color3;
  23633. buffer: Uint8Array;
  23634. bufferWidth: number;
  23635. bufferHeight: number;
  23636. alphaFilter: number;
  23637. }): VertexData;
  23638. /**
  23639. * Creates the VertexData for a Plane
  23640. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  23641. * * size sets the width and height of the plane to the value of size, optional default 1
  23642. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  23643. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  23644. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23645. * * 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)
  23646. * * 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)
  23647. * @returns the VertexData of the box
  23648. */
  23649. static CreatePlane(options: {
  23650. size?: number;
  23651. width?: number;
  23652. height?: number;
  23653. sideOrientation?: number;
  23654. frontUVs?: Vector4;
  23655. backUVs?: Vector4;
  23656. }): VertexData;
  23657. /**
  23658. * Creates the VertexData of the Disc or regular Polygon
  23659. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  23660. * * radius the radius of the disc, optional default 0.5
  23661. * * tessellation the number of polygon sides, optional, default 64
  23662. * * 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
  23663. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23664. * * 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)
  23665. * * 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)
  23666. * @returns the VertexData of the box
  23667. */
  23668. static CreateDisc(options: {
  23669. radius?: number;
  23670. tessellation?: number;
  23671. arc?: number;
  23672. sideOrientation?: number;
  23673. frontUVs?: Vector4;
  23674. backUVs?: Vector4;
  23675. }): VertexData;
  23676. /**
  23677. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  23678. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  23679. * @param polygon a mesh built from polygonTriangulation.build()
  23680. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23681. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23682. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23683. * @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)
  23684. * @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)
  23685. * @returns the VertexData of the Polygon
  23686. */
  23687. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  23688. /**
  23689. * Creates the VertexData of the IcoSphere
  23690. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  23691. * * radius the radius of the IcoSphere, optional default 1
  23692. * * radiusX allows stretching in the x direction, optional, default radius
  23693. * * radiusY allows stretching in the y direction, optional, default radius
  23694. * * radiusZ allows stretching in the z direction, optional, default radius
  23695. * * flat when true creates a flat shaded mesh, optional, default true
  23696. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  23697. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23698. * * 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)
  23699. * * 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)
  23700. * @returns the VertexData of the IcoSphere
  23701. */
  23702. static CreateIcoSphere(options: {
  23703. radius?: number;
  23704. radiusX?: number;
  23705. radiusY?: number;
  23706. radiusZ?: number;
  23707. flat?: boolean;
  23708. subdivisions?: number;
  23709. sideOrientation?: number;
  23710. frontUVs?: Vector4;
  23711. backUVs?: Vector4;
  23712. }): VertexData;
  23713. /**
  23714. * Creates the VertexData for a Polyhedron
  23715. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  23716. * * type provided types are:
  23717. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  23718. * * 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)
  23719. * * size the size of the IcoSphere, optional default 1
  23720. * * sizeX allows stretching in the x direction, optional, default size
  23721. * * sizeY allows stretching in the y direction, optional, default size
  23722. * * sizeZ allows stretching in the z direction, optional, default size
  23723. * * 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
  23724. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23725. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23726. * * flat when true creates a flat shaded mesh, optional, default true
  23727. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  23728. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23729. * * 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)
  23730. * * 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)
  23731. * @returns the VertexData of the Polyhedron
  23732. */
  23733. static CreatePolyhedron(options: {
  23734. type?: number;
  23735. size?: number;
  23736. sizeX?: number;
  23737. sizeY?: number;
  23738. sizeZ?: number;
  23739. custom?: any;
  23740. faceUV?: Vector4[];
  23741. faceColors?: Color4[];
  23742. flat?: boolean;
  23743. sideOrientation?: number;
  23744. frontUVs?: Vector4;
  23745. backUVs?: Vector4;
  23746. }): VertexData;
  23747. /**
  23748. * Creates the VertexData for a TorusKnot
  23749. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  23750. * * radius the radius of the torus knot, optional, default 2
  23751. * * tube the thickness of the tube, optional, default 0.5
  23752. * * radialSegments the number of sides on each tube segments, optional, default 32
  23753. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  23754. * * p the number of windings around the z axis, optional, default 2
  23755. * * q the number of windings around the x axis, optional, default 3
  23756. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23757. * * 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)
  23758. * * 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)
  23759. * @returns the VertexData of the Torus Knot
  23760. */
  23761. static CreateTorusKnot(options: {
  23762. radius?: number;
  23763. tube?: number;
  23764. radialSegments?: number;
  23765. tubularSegments?: number;
  23766. p?: number;
  23767. q?: number;
  23768. sideOrientation?: number;
  23769. frontUVs?: Vector4;
  23770. backUVs?: Vector4;
  23771. }): VertexData;
  23772. /**
  23773. * Compute normals for given positions and indices
  23774. * @param positions an array of vertex positions, [...., x, y, z, ......]
  23775. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  23776. * @param normals an array of vertex normals, [...., x, y, z, ......]
  23777. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  23778. * * facetNormals : optional array of facet normals (vector3)
  23779. * * facetPositions : optional array of facet positions (vector3)
  23780. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  23781. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  23782. * * bInfo : optional bounding info, required for facetPartitioning computation
  23783. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  23784. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  23785. * * useRightHandedSystem: optional boolean to for right handed system computation
  23786. * * depthSort : optional boolean to enable the facet depth sort computation
  23787. * * distanceTo : optional Vector3 to compute the facet depth from this location
  23788. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  23789. */
  23790. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  23791. facetNormals?: any;
  23792. facetPositions?: any;
  23793. facetPartitioning?: any;
  23794. ratio?: number;
  23795. bInfo?: any;
  23796. bbSize?: Vector3;
  23797. subDiv?: any;
  23798. useRightHandedSystem?: boolean;
  23799. depthSort?: boolean;
  23800. distanceTo?: Vector3;
  23801. depthSortedFacets?: any;
  23802. }): void;
  23803. /** @hidden */
  23804. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  23805. /**
  23806. * Applies VertexData created from the imported parameters to the geometry
  23807. * @param parsedVertexData the parsed data from an imported file
  23808. * @param geometry the geometry to apply the VertexData to
  23809. */
  23810. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  23811. }
  23812. }
  23813. declare module "babylonjs/Meshes/Builders/discBuilder" {
  23814. import { Nullable } from "babylonjs/types";
  23815. import { Scene } from "babylonjs/scene";
  23816. import { Vector4 } from "babylonjs/Maths/math";
  23817. import { Mesh } from "babylonjs/Meshes/mesh";
  23818. /**
  23819. * Class containing static functions to help procedurally build meshes
  23820. */
  23821. export class DiscBuilder {
  23822. /**
  23823. * Creates a plane polygonal mesh. By default, this is a disc
  23824. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  23825. * * 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
  23826. * * 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
  23827. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23828. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  23829. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23830. * @param name defines the name of the mesh
  23831. * @param options defines the options used to create the mesh
  23832. * @param scene defines the hosting scene
  23833. * @returns the plane polygonal mesh
  23834. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  23835. */
  23836. static CreateDisc(name: string, options: {
  23837. radius?: number;
  23838. tessellation?: number;
  23839. arc?: number;
  23840. updatable?: boolean;
  23841. sideOrientation?: number;
  23842. frontUVs?: Vector4;
  23843. backUVs?: Vector4;
  23844. }, scene?: Nullable<Scene>): Mesh;
  23845. }
  23846. }
  23847. declare module "babylonjs/Particles/solidParticleSystem" {
  23848. import { Vector3 } from "babylonjs/Maths/math";
  23849. import { Mesh } from "babylonjs/Meshes/mesh";
  23850. import { Scene, IDisposable } from "babylonjs/scene";
  23851. import { DepthSortedParticle, SolidParticle } from "babylonjs/Particles/solidParticle";
  23852. /**
  23853. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  23854. *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.
  23855. * The SPS is also a particle system. It provides some methods to manage the particles.
  23856. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  23857. *
  23858. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  23859. */
  23860. export class SolidParticleSystem implements IDisposable {
  23861. /**
  23862. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  23863. * Example : var p = SPS.particles[i];
  23864. */
  23865. particles: SolidParticle[];
  23866. /**
  23867. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  23868. */
  23869. nbParticles: number;
  23870. /**
  23871. * If the particles must ever face the camera (default false). Useful for planar particles.
  23872. */
  23873. billboard: boolean;
  23874. /**
  23875. * Recompute normals when adding a shape
  23876. */
  23877. recomputeNormals: boolean;
  23878. /**
  23879. * This a counter ofr your own usage. It's not set by any SPS functions.
  23880. */
  23881. counter: number;
  23882. /**
  23883. * The SPS name. This name is also given to the underlying mesh.
  23884. */
  23885. name: string;
  23886. /**
  23887. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  23888. */
  23889. mesh: Mesh;
  23890. /**
  23891. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  23892. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  23893. */
  23894. vars: any;
  23895. /**
  23896. * This array is populated when the SPS is set as 'pickable'.
  23897. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  23898. * Each element of this array is an object `{idx: int, faceId: int}`.
  23899. * `idx` is the picked particle index in the `SPS.particles` array
  23900. * `faceId` is the picked face index counted within this particle.
  23901. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  23902. */
  23903. pickedParticles: {
  23904. idx: number;
  23905. faceId: number;
  23906. }[];
  23907. /**
  23908. * This array is populated when `enableDepthSort` is set to true.
  23909. * Each element of this array is an instance of the class DepthSortedParticle.
  23910. */
  23911. depthSortedParticles: DepthSortedParticle[];
  23912. /**
  23913. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  23914. * @hidden
  23915. */
  23916. _bSphereOnly: boolean;
  23917. /**
  23918. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  23919. * @hidden
  23920. */
  23921. _bSphereRadiusFactor: number;
  23922. private _scene;
  23923. private _positions;
  23924. private _indices;
  23925. private _normals;
  23926. private _colors;
  23927. private _uvs;
  23928. private _indices32;
  23929. private _positions32;
  23930. private _normals32;
  23931. private _fixedNormal32;
  23932. private _colors32;
  23933. private _uvs32;
  23934. private _index;
  23935. private _updatable;
  23936. private _pickable;
  23937. private _isVisibilityBoxLocked;
  23938. private _alwaysVisible;
  23939. private _depthSort;
  23940. private _shapeCounter;
  23941. private _copy;
  23942. private _color;
  23943. private _computeParticleColor;
  23944. private _computeParticleTexture;
  23945. private _computeParticleRotation;
  23946. private _computeParticleVertex;
  23947. private _computeBoundingBox;
  23948. private _depthSortParticles;
  23949. private _camera;
  23950. private _mustUnrotateFixedNormals;
  23951. private _particlesIntersect;
  23952. private _needs32Bits;
  23953. /**
  23954. * Creates a SPS (Solid Particle System) object.
  23955. * @param name (String) is the SPS name, this will be the underlying mesh name.
  23956. * @param scene (Scene) is the scene in which the SPS is added.
  23957. * @param options defines the options of the sps e.g.
  23958. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  23959. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  23960. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  23961. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  23962. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  23963. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  23964. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  23965. */
  23966. constructor(name: string, scene: Scene, options?: {
  23967. updatable?: boolean;
  23968. isPickable?: boolean;
  23969. enableDepthSort?: boolean;
  23970. particleIntersection?: boolean;
  23971. boundingSphereOnly?: boolean;
  23972. bSphereRadiusFactor?: number;
  23973. });
  23974. /**
  23975. * Builds the SPS underlying mesh. Returns a standard Mesh.
  23976. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  23977. * @returns the created mesh
  23978. */
  23979. buildMesh(): Mesh;
  23980. /**
  23981. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  23982. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  23983. * Thus the particles generated from `digest()` have their property `position` set yet.
  23984. * @param mesh ( Mesh ) is the mesh to be digested
  23985. * @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
  23986. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  23987. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  23988. * @returns the current SPS
  23989. */
  23990. digest(mesh: Mesh, options?: {
  23991. facetNb?: number;
  23992. number?: number;
  23993. delta?: number;
  23994. }): SolidParticleSystem;
  23995. private _unrotateFixedNormals;
  23996. private _resetCopy;
  23997. private _meshBuilder;
  23998. private _posToShape;
  23999. private _uvsToShapeUV;
  24000. private _addParticle;
  24001. /**
  24002. * Adds some particles to the SPS from the model shape. Returns the shape id.
  24003. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  24004. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  24005. * @param nb (positive integer) the number of particles to be created from this model
  24006. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  24007. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  24008. * @returns the number of shapes in the system
  24009. */
  24010. addShape(mesh: Mesh, nb: number, options?: {
  24011. positionFunction?: any;
  24012. vertexFunction?: any;
  24013. }): number;
  24014. private _rebuildParticle;
  24015. /**
  24016. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  24017. * @returns the SPS.
  24018. */
  24019. rebuildMesh(): SolidParticleSystem;
  24020. /**
  24021. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  24022. * This method calls `updateParticle()` for each particle of the SPS.
  24023. * For an animated SPS, it is usually called within the render loop.
  24024. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  24025. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  24026. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  24027. * @returns the SPS.
  24028. */
  24029. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  24030. /**
  24031. * Disposes the SPS.
  24032. */
  24033. dispose(): void;
  24034. /**
  24035. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  24036. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24037. * @returns the SPS.
  24038. */
  24039. refreshVisibleSize(): SolidParticleSystem;
  24040. /**
  24041. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  24042. * @param size the size (float) of the visibility box
  24043. * note : this doesn't lock the SPS mesh bounding box.
  24044. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24045. */
  24046. setVisibilityBox(size: number): void;
  24047. /**
  24048. * Gets whether the SPS as always visible or not
  24049. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24050. */
  24051. /**
  24052. * Sets the SPS as always visible or not
  24053. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24054. */
  24055. isAlwaysVisible: boolean;
  24056. /**
  24057. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  24058. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24059. */
  24060. /**
  24061. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  24062. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24063. */
  24064. isVisibilityBoxLocked: boolean;
  24065. /**
  24066. * Tells to `setParticles()` to compute the particle rotations or not.
  24067. * Default value : true. The SPS is faster when it's set to false.
  24068. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  24069. */
  24070. /**
  24071. * Gets if `setParticles()` computes the particle rotations or not.
  24072. * Default value : true. The SPS is faster when it's set to false.
  24073. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  24074. */
  24075. computeParticleRotation: boolean;
  24076. /**
  24077. * Tells to `setParticles()` to compute the particle colors or not.
  24078. * Default value : true. The SPS is faster when it's set to false.
  24079. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  24080. */
  24081. /**
  24082. * Gets if `setParticles()` computes the particle colors or not.
  24083. * Default value : true. The SPS is faster when it's set to false.
  24084. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  24085. */
  24086. computeParticleColor: boolean;
  24087. /**
  24088. * Gets if `setParticles()` computes the particle textures or not.
  24089. * Default value : true. The SPS is faster when it's set to false.
  24090. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  24091. */
  24092. computeParticleTexture: boolean;
  24093. /**
  24094. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  24095. * Default value : false. The SPS is faster when it's set to false.
  24096. * Note : the particle custom vertex positions aren't stored values.
  24097. */
  24098. /**
  24099. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  24100. * Default value : false. The SPS is faster when it's set to false.
  24101. * Note : the particle custom vertex positions aren't stored values.
  24102. */
  24103. computeParticleVertex: boolean;
  24104. /**
  24105. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  24106. */
  24107. /**
  24108. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  24109. */
  24110. computeBoundingBox: boolean;
  24111. /**
  24112. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  24113. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  24114. * Default : `true`
  24115. */
  24116. /**
  24117. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  24118. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  24119. * Default : `true`
  24120. */
  24121. depthSortParticles: boolean;
  24122. /**
  24123. * This function does nothing. It may be overwritten to set all the particle first values.
  24124. * The SPS doesn't call this function, you may have to call it by your own.
  24125. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  24126. */
  24127. initParticles(): void;
  24128. /**
  24129. * This function does nothing. It may be overwritten to recycle a particle.
  24130. * The SPS doesn't call this function, you may have to call it by your own.
  24131. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  24132. * @param particle The particle to recycle
  24133. * @returns the recycled particle
  24134. */
  24135. recycleParticle(particle: SolidParticle): SolidParticle;
  24136. /**
  24137. * Updates a particle : this function should be overwritten by the user.
  24138. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  24139. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  24140. * @example : just set a particle position or velocity and recycle conditions
  24141. * @param particle The particle to update
  24142. * @returns the updated particle
  24143. */
  24144. updateParticle(particle: SolidParticle): SolidParticle;
  24145. /**
  24146. * Updates a vertex of a particle : it can be overwritten by the user.
  24147. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  24148. * @param particle the current particle
  24149. * @param vertex the current index of the current particle
  24150. * @param pt the index of the current vertex in the particle shape
  24151. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  24152. * @example : just set a vertex particle position
  24153. * @returns the updated vertex
  24154. */
  24155. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  24156. /**
  24157. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  24158. * This does nothing and may be overwritten by the user.
  24159. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24160. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24161. * @param update the boolean update value actually passed to setParticles()
  24162. */
  24163. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  24164. /**
  24165. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  24166. * This will be passed three parameters.
  24167. * This does nothing and may be overwritten by the user.
  24168. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24169. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24170. * @param update the boolean update value actually passed to setParticles()
  24171. */
  24172. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  24173. }
  24174. }
  24175. declare module "babylonjs/Particles/solidParticle" {
  24176. import { Nullable } from "babylonjs/types";
  24177. import { Color4, Vector3, Matrix, Quaternion, Vector4, Plane } from "babylonjs/Maths/math";
  24178. import { Mesh } from "babylonjs/Meshes/mesh";
  24179. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  24180. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  24181. /**
  24182. * Represents one particle of a solid particle system.
  24183. */
  24184. export class SolidParticle {
  24185. /**
  24186. * particle global index
  24187. */
  24188. idx: number;
  24189. /**
  24190. * The color of the particle
  24191. */
  24192. color: Nullable<Color4>;
  24193. /**
  24194. * The world space position of the particle.
  24195. */
  24196. position: Vector3;
  24197. /**
  24198. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  24199. */
  24200. rotation: Vector3;
  24201. /**
  24202. * The world space rotation quaternion of the particle.
  24203. */
  24204. rotationQuaternion: Nullable<Quaternion>;
  24205. /**
  24206. * The scaling of the particle.
  24207. */
  24208. scaling: Vector3;
  24209. /**
  24210. * The uvs of the particle.
  24211. */
  24212. uvs: Vector4;
  24213. /**
  24214. * The current speed of the particle.
  24215. */
  24216. velocity: Vector3;
  24217. /**
  24218. * The pivot point in the particle local space.
  24219. */
  24220. pivot: Vector3;
  24221. /**
  24222. * Must the particle be translated from its pivot point in its local space ?
  24223. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  24224. * Default : false
  24225. */
  24226. translateFromPivot: boolean;
  24227. /**
  24228. * Is the particle active or not ?
  24229. */
  24230. alive: boolean;
  24231. /**
  24232. * Is the particle visible or not ?
  24233. */
  24234. isVisible: boolean;
  24235. /**
  24236. * Index of this particle in the global "positions" array (Internal use)
  24237. * @hidden
  24238. */
  24239. _pos: number;
  24240. /**
  24241. * @hidden Index of this particle in the global "indices" array (Internal use)
  24242. */
  24243. _ind: number;
  24244. /**
  24245. * @hidden ModelShape of this particle (Internal use)
  24246. */
  24247. _model: ModelShape;
  24248. /**
  24249. * ModelShape id of this particle
  24250. */
  24251. shapeId: number;
  24252. /**
  24253. * Index of the particle in its shape id (Internal use)
  24254. */
  24255. idxInShape: number;
  24256. /**
  24257. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  24258. */
  24259. _modelBoundingInfo: BoundingInfo;
  24260. /**
  24261. * @hidden Particle BoundingInfo object (Internal use)
  24262. */
  24263. _boundingInfo: BoundingInfo;
  24264. /**
  24265. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  24266. */
  24267. _sps: SolidParticleSystem;
  24268. /**
  24269. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  24270. */
  24271. _stillInvisible: boolean;
  24272. /**
  24273. * @hidden Last computed particle rotation matrix
  24274. */
  24275. _rotationMatrix: number[];
  24276. /**
  24277. * Parent particle Id, if any.
  24278. * Default null.
  24279. */
  24280. parentId: Nullable<number>;
  24281. /**
  24282. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  24283. * The possible values are :
  24284. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  24285. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  24286. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  24287. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  24288. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  24289. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  24290. * */
  24291. cullingStrategy: number;
  24292. /**
  24293. * @hidden Internal global position in the SPS.
  24294. */
  24295. _globalPosition: Vector3;
  24296. /**
  24297. * Creates a Solid Particle object.
  24298. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  24299. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  24300. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  24301. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  24302. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  24303. * @param shapeId (integer) is the model shape identifier in the SPS.
  24304. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  24305. * @param sps defines the sps it is associated to
  24306. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  24307. */
  24308. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  24309. /**
  24310. * Legacy support, changed scale to scaling
  24311. */
  24312. /**
  24313. * Legacy support, changed scale to scaling
  24314. */
  24315. scale: Vector3;
  24316. /**
  24317. * Legacy support, changed quaternion to rotationQuaternion
  24318. */
  24319. /**
  24320. * Legacy support, changed quaternion to rotationQuaternion
  24321. */
  24322. quaternion: Nullable<Quaternion>;
  24323. /**
  24324. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  24325. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  24326. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  24327. * @returns true if it intersects
  24328. */
  24329. intersectsMesh(target: Mesh | SolidParticle): boolean;
  24330. /**
  24331. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  24332. * A particle is in the frustum if its bounding box intersects the frustum
  24333. * @param frustumPlanes defines the frustum to test
  24334. * @returns true if the particle is in the frustum planes
  24335. */
  24336. isInFrustum(frustumPlanes: Plane[]): boolean;
  24337. /**
  24338. * get the rotation matrix of the particle
  24339. * @hidden
  24340. */
  24341. getRotationMatrix(m: Matrix): void;
  24342. }
  24343. /**
  24344. * Represents the shape of the model used by one particle of a solid particle system.
  24345. * SPS internal tool, don't use it manually.
  24346. */
  24347. export class ModelShape {
  24348. /**
  24349. * The shape id
  24350. * @hidden
  24351. */
  24352. shapeID: number;
  24353. /**
  24354. * flat array of model positions (internal use)
  24355. * @hidden
  24356. */
  24357. _shape: Vector3[];
  24358. /**
  24359. * flat array of model UVs (internal use)
  24360. * @hidden
  24361. */
  24362. _shapeUV: number[];
  24363. /**
  24364. * length of the shape in the model indices array (internal use)
  24365. * @hidden
  24366. */
  24367. _indicesLength: number;
  24368. /**
  24369. * Custom position function (internal use)
  24370. * @hidden
  24371. */
  24372. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  24373. /**
  24374. * Custom vertex function (internal use)
  24375. * @hidden
  24376. */
  24377. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  24378. /**
  24379. * 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.
  24380. * SPS internal tool, don't use it manually.
  24381. * @hidden
  24382. */
  24383. 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>);
  24384. }
  24385. /**
  24386. * Represents a Depth Sorted Particle in the solid particle system.
  24387. */
  24388. export class DepthSortedParticle {
  24389. /**
  24390. * Index of the particle in the "indices" array
  24391. */
  24392. ind: number;
  24393. /**
  24394. * Length of the particle shape in the "indices" array
  24395. */
  24396. indicesLength: number;
  24397. /**
  24398. * Squared distance from the particle to the camera
  24399. */
  24400. sqDistance: number;
  24401. }
  24402. }
  24403. declare module "babylonjs/Meshes/abstractMesh" {
  24404. import { Observable } from "babylonjs/Misc/observable";
  24405. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  24406. import { Camera } from "babylonjs/Cameras/camera";
  24407. import { Scene, IDisposable } from "babylonjs/scene";
  24408. import { Matrix, Vector3, Color3, Color4, Plane, Vector2 } from "babylonjs/Maths/math";
  24409. import { Node } from "babylonjs/node";
  24410. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  24411. import { TransformNode } from "babylonjs/Meshes/transformNode";
  24412. import { SubMesh } from "babylonjs/Meshes/subMesh";
  24413. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  24414. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  24415. import { Material } from "babylonjs/Materials/material";
  24416. import { Light } from "babylonjs/Lights/light";
  24417. import { Skeleton } from "babylonjs/Bones/skeleton";
  24418. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  24419. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  24420. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  24421. import { Ray } from "babylonjs/Culling/ray";
  24422. import { Collider } from "babylonjs/Collisions/collider";
  24423. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  24424. /**
  24425. * Class used to store all common mesh properties
  24426. */
  24427. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  24428. /** No occlusion */
  24429. static OCCLUSION_TYPE_NONE: number;
  24430. /** Occlusion set to optimisitic */
  24431. static OCCLUSION_TYPE_OPTIMISTIC: number;
  24432. /** Occlusion set to strict */
  24433. static OCCLUSION_TYPE_STRICT: number;
  24434. /** Use an accurante occlusion algorithm */
  24435. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  24436. /** Use a conservative occlusion algorithm */
  24437. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  24438. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  24439. * Test order :
  24440. * Is the bounding sphere outside the frustum ?
  24441. * If not, are the bounding box vertices outside the frustum ?
  24442. * It not, then the cullable object is in the frustum.
  24443. */
  24444. static readonly CULLINGSTRATEGY_STANDARD: number;
  24445. /** Culling strategy : Bounding Sphere Only.
  24446. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  24447. * It's also less accurate than the standard because some not visible objects can still be selected.
  24448. * Test : is the bounding sphere outside the frustum ?
  24449. * If not, then the cullable object is in the frustum.
  24450. */
  24451. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  24452. /** Culling strategy : Optimistic Inclusion.
  24453. * This in an inclusion test first, then the standard exclusion test.
  24454. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  24455. * 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.
  24456. * Anyway, it's as accurate as the standard strategy.
  24457. * Test :
  24458. * Is the cullable object bounding sphere center in the frustum ?
  24459. * If not, apply the default culling strategy.
  24460. */
  24461. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  24462. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  24463. * This in an inclusion test first, then the bounding sphere only exclusion test.
  24464. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  24465. * 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.
  24466. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  24467. * Test :
  24468. * Is the cullable object bounding sphere center in the frustum ?
  24469. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  24470. */
  24471. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  24472. /**
  24473. * No billboard
  24474. */
  24475. static readonly BILLBOARDMODE_NONE: number;
  24476. /** Billboard on X axis */
  24477. static readonly BILLBOARDMODE_X: number;
  24478. /** Billboard on Y axis */
  24479. static readonly BILLBOARDMODE_Y: number;
  24480. /** Billboard on Z axis */
  24481. static readonly BILLBOARDMODE_Z: number;
  24482. /** Billboard on all axes */
  24483. static readonly BILLBOARDMODE_ALL: number;
  24484. private _facetData;
  24485. /**
  24486. * The culling strategy to use to check whether the mesh must be rendered or not.
  24487. * This value can be changed at any time and will be used on the next render mesh selection.
  24488. * The possible values are :
  24489. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  24490. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  24491. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  24492. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  24493. * Please read each static variable documentation to get details about the culling process.
  24494. * */
  24495. cullingStrategy: number;
  24496. /**
  24497. * Gets the number of facets in the mesh
  24498. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  24499. */
  24500. readonly facetNb: number;
  24501. /**
  24502. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  24503. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  24504. */
  24505. partitioningSubdivisions: number;
  24506. /**
  24507. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  24508. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  24509. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  24510. */
  24511. partitioningBBoxRatio: number;
  24512. /**
  24513. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  24514. * Works only for updatable meshes.
  24515. * Doesn't work with multi-materials
  24516. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  24517. */
  24518. mustDepthSortFacets: boolean;
  24519. /**
  24520. * The location (Vector3) where the facet depth sort must be computed from.
  24521. * By default, the active camera position.
  24522. * Used only when facet depth sort is enabled
  24523. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  24524. */
  24525. facetDepthSortFrom: Vector3;
  24526. /**
  24527. * gets a boolean indicating if facetData is enabled
  24528. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  24529. */
  24530. readonly isFacetDataEnabled: boolean;
  24531. /** @hidden */
  24532. _updateNonUniformScalingState(value: boolean): boolean;
  24533. /**
  24534. * An event triggered when this mesh collides with another one
  24535. */
  24536. onCollideObservable: Observable<AbstractMesh>;
  24537. private _onCollideObserver;
  24538. /** Set a function to call when this mesh collides with another one */
  24539. onCollide: () => void;
  24540. /**
  24541. * An event triggered when the collision's position changes
  24542. */
  24543. onCollisionPositionChangeObservable: Observable<Vector3>;
  24544. private _onCollisionPositionChangeObserver;
  24545. /** Set a function to call when the collision's position changes */
  24546. onCollisionPositionChange: () => void;
  24547. /**
  24548. * An event triggered when material is changed
  24549. */
  24550. onMaterialChangedObservable: Observable<AbstractMesh>;
  24551. /**
  24552. * Gets or sets the orientation for POV movement & rotation
  24553. */
  24554. definedFacingForward: boolean;
  24555. /** @hidden */
  24556. _occlusionQuery: Nullable<WebGLQuery>;
  24557. private _visibility;
  24558. /**
  24559. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  24560. */
  24561. /**
  24562. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  24563. */
  24564. visibility: number;
  24565. /** Gets or sets the alpha index used to sort transparent meshes
  24566. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  24567. */
  24568. alphaIndex: number;
  24569. /**
  24570. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  24571. */
  24572. isVisible: boolean;
  24573. /**
  24574. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  24575. */
  24576. isPickable: boolean;
  24577. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  24578. showSubMeshesBoundingBox: boolean;
  24579. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  24580. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  24581. */
  24582. isBlocker: boolean;
  24583. /**
  24584. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  24585. */
  24586. enablePointerMoveEvents: boolean;
  24587. /**
  24588. * Specifies the rendering group id for this mesh (0 by default)
  24589. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  24590. */
  24591. renderingGroupId: number;
  24592. private _material;
  24593. /** Gets or sets current material */
  24594. material: Nullable<Material>;
  24595. private _receiveShadows;
  24596. /**
  24597. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  24598. * @see http://doc.babylonjs.com/babylon101/shadows
  24599. */
  24600. receiveShadows: boolean;
  24601. /** Defines color to use when rendering outline */
  24602. outlineColor: Color3;
  24603. /** Define width to use when rendering outline */
  24604. outlineWidth: number;
  24605. /** Defines color to use when rendering overlay */
  24606. overlayColor: Color3;
  24607. /** Defines alpha to use when rendering overlay */
  24608. overlayAlpha: number;
  24609. private _hasVertexAlpha;
  24610. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  24611. hasVertexAlpha: boolean;
  24612. private _useVertexColors;
  24613. /** 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) */
  24614. useVertexColors: boolean;
  24615. private _computeBonesUsingShaders;
  24616. /**
  24617. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  24618. */
  24619. computeBonesUsingShaders: boolean;
  24620. private _numBoneInfluencers;
  24621. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  24622. numBoneInfluencers: number;
  24623. private _applyFog;
  24624. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  24625. applyFog: boolean;
  24626. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  24627. useOctreeForRenderingSelection: boolean;
  24628. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  24629. useOctreeForPicking: boolean;
  24630. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  24631. useOctreeForCollisions: boolean;
  24632. private _layerMask;
  24633. /**
  24634. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  24635. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  24636. */
  24637. layerMask: number;
  24638. /**
  24639. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  24640. */
  24641. alwaysSelectAsActiveMesh: boolean;
  24642. /**
  24643. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  24644. */
  24645. doNotSyncBoundingInfo: boolean;
  24646. /**
  24647. * Gets or sets the current action manager
  24648. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  24649. */
  24650. actionManager: Nullable<AbstractActionManager>;
  24651. private _checkCollisions;
  24652. private _collisionMask;
  24653. private _collisionGroup;
  24654. /**
  24655. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  24656. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24657. */
  24658. ellipsoid: Vector3;
  24659. /**
  24660. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  24661. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24662. */
  24663. ellipsoidOffset: Vector3;
  24664. private _collider;
  24665. private _oldPositionForCollisions;
  24666. private _diffPositionForCollisions;
  24667. /**
  24668. * Gets or sets a collision mask used to mask collisions (default is -1).
  24669. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  24670. */
  24671. collisionMask: number;
  24672. /**
  24673. * Gets or sets the current collision group mask (-1 by default).
  24674. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  24675. */
  24676. collisionGroup: number;
  24677. /**
  24678. * Defines edge width used when edgesRenderer is enabled
  24679. * @see https://www.babylonjs-playground.com/#10OJSG#13
  24680. */
  24681. edgesWidth: number;
  24682. /**
  24683. * Defines edge color used when edgesRenderer is enabled
  24684. * @see https://www.babylonjs-playground.com/#10OJSG#13
  24685. */
  24686. edgesColor: Color4;
  24687. /** @hidden */
  24688. _edgesRenderer: Nullable<IEdgesRenderer>;
  24689. /** @hidden */
  24690. _masterMesh: Nullable<AbstractMesh>;
  24691. /** @hidden */
  24692. _boundingInfo: Nullable<BoundingInfo>;
  24693. /** @hidden */
  24694. _renderId: number;
  24695. /**
  24696. * Gets or sets the list of subMeshes
  24697. * @see http://doc.babylonjs.com/how_to/multi_materials
  24698. */
  24699. subMeshes: SubMesh[];
  24700. /** @hidden */
  24701. _intersectionsInProgress: AbstractMesh[];
  24702. /** @hidden */
  24703. _unIndexed: boolean;
  24704. /** @hidden */
  24705. _lightSources: Light[];
  24706. /** @hidden */
  24707. readonly _positions: Nullable<Vector3[]>;
  24708. /** @hidden */
  24709. _waitingActions: any;
  24710. /** @hidden */
  24711. _waitingFreezeWorldMatrix: Nullable<boolean>;
  24712. private _skeleton;
  24713. /** @hidden */
  24714. _bonesTransformMatrices: Nullable<Float32Array>;
  24715. /**
  24716. * Gets or sets a skeleton to apply skining transformations
  24717. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  24718. */
  24719. skeleton: Nullable<Skeleton>;
  24720. /**
  24721. * An event triggered when the mesh is rebuilt.
  24722. */
  24723. onRebuildObservable: Observable<AbstractMesh>;
  24724. /**
  24725. * Creates a new AbstractMesh
  24726. * @param name defines the name of the mesh
  24727. * @param scene defines the hosting scene
  24728. */
  24729. constructor(name: string, scene?: Nullable<Scene>);
  24730. /**
  24731. * Returns the string "AbstractMesh"
  24732. * @returns "AbstractMesh"
  24733. */
  24734. getClassName(): string;
  24735. /**
  24736. * Gets a string representation of the current mesh
  24737. * @param fullDetails defines a boolean indicating if full details must be included
  24738. * @returns a string representation of the current mesh
  24739. */
  24740. toString(fullDetails?: boolean): string;
  24741. /**
  24742. * @hidden
  24743. */
  24744. protected _getEffectiveParent(): Nullable<Node>;
  24745. /** @hidden */
  24746. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  24747. /** @hidden */
  24748. _rebuild(): void;
  24749. /** @hidden */
  24750. _resyncLightSources(): void;
  24751. /** @hidden */
  24752. _resyncLighSource(light: Light): void;
  24753. /** @hidden */
  24754. _unBindEffect(): void;
  24755. /** @hidden */
  24756. _removeLightSource(light: Light): void;
  24757. private _markSubMeshesAsDirty;
  24758. /** @hidden */
  24759. _markSubMeshesAsLightDirty(): void;
  24760. /** @hidden */
  24761. _markSubMeshesAsAttributesDirty(): void;
  24762. /** @hidden */
  24763. _markSubMeshesAsMiscDirty(): void;
  24764. /**
  24765. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  24766. */
  24767. scaling: Vector3;
  24768. /**
  24769. * Returns true if the mesh is blocked. Implemented by child classes
  24770. */
  24771. readonly isBlocked: boolean;
  24772. /**
  24773. * Returns the mesh itself by default. Implemented by child classes
  24774. * @param camera defines the camera to use to pick the right LOD level
  24775. * @returns the currentAbstractMesh
  24776. */
  24777. getLOD(camera: Camera): Nullable<AbstractMesh>;
  24778. /**
  24779. * Returns 0 by default. Implemented by child classes
  24780. * @returns an integer
  24781. */
  24782. getTotalVertices(): number;
  24783. /**
  24784. * Returns a positive integer : the total number of indices in this mesh geometry.
  24785. * @returns the numner of indices or zero if the mesh has no geometry.
  24786. */
  24787. getTotalIndices(): number;
  24788. /**
  24789. * Returns null by default. Implemented by child classes
  24790. * @returns null
  24791. */
  24792. getIndices(): Nullable<IndicesArray>;
  24793. /**
  24794. * Returns the array of the requested vertex data kind. Implemented by child classes
  24795. * @param kind defines the vertex data kind to use
  24796. * @returns null
  24797. */
  24798. getVerticesData(kind: string): Nullable<FloatArray>;
  24799. /**
  24800. * Sets the vertex data of the mesh geometry for the requested `kind`.
  24801. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  24802. * Note that a new underlying VertexBuffer object is created each call.
  24803. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  24804. * @param kind defines vertex data kind:
  24805. * * VertexBuffer.PositionKind
  24806. * * VertexBuffer.UVKind
  24807. * * VertexBuffer.UV2Kind
  24808. * * VertexBuffer.UV3Kind
  24809. * * VertexBuffer.UV4Kind
  24810. * * VertexBuffer.UV5Kind
  24811. * * VertexBuffer.UV6Kind
  24812. * * VertexBuffer.ColorKind
  24813. * * VertexBuffer.MatricesIndicesKind
  24814. * * VertexBuffer.MatricesIndicesExtraKind
  24815. * * VertexBuffer.MatricesWeightsKind
  24816. * * VertexBuffer.MatricesWeightsExtraKind
  24817. * @param data defines the data source
  24818. * @param updatable defines if the data must be flagged as updatable (or static)
  24819. * @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
  24820. * @returns the current mesh
  24821. */
  24822. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  24823. /**
  24824. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  24825. * If the mesh has no geometry, it is simply returned as it is.
  24826. * @param kind defines vertex data kind:
  24827. * * VertexBuffer.PositionKind
  24828. * * VertexBuffer.UVKind
  24829. * * VertexBuffer.UV2Kind
  24830. * * VertexBuffer.UV3Kind
  24831. * * VertexBuffer.UV4Kind
  24832. * * VertexBuffer.UV5Kind
  24833. * * VertexBuffer.UV6Kind
  24834. * * VertexBuffer.ColorKind
  24835. * * VertexBuffer.MatricesIndicesKind
  24836. * * VertexBuffer.MatricesIndicesExtraKind
  24837. * * VertexBuffer.MatricesWeightsKind
  24838. * * VertexBuffer.MatricesWeightsExtraKind
  24839. * @param data defines the data source
  24840. * @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
  24841. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  24842. * @returns the current mesh
  24843. */
  24844. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  24845. /**
  24846. * Sets the mesh indices,
  24847. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  24848. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  24849. * @param totalVertices Defines the total number of vertices
  24850. * @returns the current mesh
  24851. */
  24852. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  24853. /**
  24854. * Gets a boolean indicating if specific vertex data is present
  24855. * @param kind defines the vertex data kind to use
  24856. * @returns true is data kind is present
  24857. */
  24858. isVerticesDataPresent(kind: string): boolean;
  24859. /**
  24860. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  24861. * @returns a BoundingInfo
  24862. */
  24863. getBoundingInfo(): BoundingInfo;
  24864. /**
  24865. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  24866. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  24867. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  24868. * @returns the current mesh
  24869. */
  24870. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean): AbstractMesh;
  24871. /**
  24872. * Overwrite the current bounding info
  24873. * @param boundingInfo defines the new bounding info
  24874. * @returns the current mesh
  24875. */
  24876. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  24877. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  24878. readonly useBones: boolean;
  24879. /** @hidden */
  24880. _preActivate(): void;
  24881. /** @hidden */
  24882. _preActivateForIntermediateRendering(renderId: number): void;
  24883. /** @hidden */
  24884. _activate(renderId: number): void;
  24885. /**
  24886. * Gets the current world matrix
  24887. * @returns a Matrix
  24888. */
  24889. getWorldMatrix(): Matrix;
  24890. /** @hidden */
  24891. _getWorldMatrixDeterminant(): number;
  24892. /**
  24893. * Perform relative position change from the point of view of behind the front of the mesh.
  24894. * This is performed taking into account the meshes current rotation, so you do not have to care.
  24895. * Supports definition of mesh facing forward or backward
  24896. * @param amountRight defines the distance on the right axis
  24897. * @param amountUp defines the distance on the up axis
  24898. * @param amountForward defines the distance on the forward axis
  24899. * @returns the current mesh
  24900. */
  24901. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  24902. /**
  24903. * Calculate relative position change from the point of view of behind the front of the mesh.
  24904. * This is performed taking into account the meshes current rotation, so you do not have to care.
  24905. * Supports definition of mesh facing forward or backward
  24906. * @param amountRight defines the distance on the right axis
  24907. * @param amountUp defines the distance on the up axis
  24908. * @param amountForward defines the distance on the forward axis
  24909. * @returns the new displacement vector
  24910. */
  24911. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  24912. /**
  24913. * Perform relative rotation change from the point of view of behind the front of the mesh.
  24914. * Supports definition of mesh facing forward or backward
  24915. * @param flipBack defines the flip
  24916. * @param twirlClockwise defines the twirl
  24917. * @param tiltRight defines the tilt
  24918. * @returns the current mesh
  24919. */
  24920. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  24921. /**
  24922. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  24923. * Supports definition of mesh facing forward or backward.
  24924. * @param flipBack defines the flip
  24925. * @param twirlClockwise defines the twirl
  24926. * @param tiltRight defines the tilt
  24927. * @returns the new rotation vector
  24928. */
  24929. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  24930. /**
  24931. * Return the minimum and maximum world vectors of the entire hierarchy under current mesh
  24932. * @param includeDescendants Include bounding info from descendants as well (true by default)
  24933. * @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
  24934. * @returns the new bounding vectors
  24935. */
  24936. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  24937. min: Vector3;
  24938. max: Vector3;
  24939. };
  24940. /**
  24941. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  24942. * This means the mesh underlying bounding box and sphere are recomputed.
  24943. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  24944. * @returns the current mesh
  24945. */
  24946. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  24947. /** @hidden */
  24948. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  24949. /** @hidden */
  24950. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  24951. /** @hidden */
  24952. _updateBoundingInfo(): AbstractMesh;
  24953. /** @hidden */
  24954. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  24955. /** @hidden */
  24956. protected _afterComputeWorldMatrix(): void;
  24957. /** @hidden */
  24958. readonly _effectiveMesh: AbstractMesh;
  24959. /**
  24960. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  24961. * A mesh is in the frustum if its bounding box intersects the frustum
  24962. * @param frustumPlanes defines the frustum to test
  24963. * @returns true if the mesh is in the frustum planes
  24964. */
  24965. isInFrustum(frustumPlanes: Plane[]): boolean;
  24966. /**
  24967. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  24968. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  24969. * @param frustumPlanes defines the frustum to test
  24970. * @returns true if the mesh is completely in the frustum planes
  24971. */
  24972. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  24973. /**
  24974. * True if the mesh intersects another mesh or a SolidParticle object
  24975. * @param mesh defines a target mesh or SolidParticle to test
  24976. * @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)
  24977. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  24978. * @returns true if there is an intersection
  24979. */
  24980. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  24981. /**
  24982. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  24983. * @param point defines the point to test
  24984. * @returns true if there is an intersection
  24985. */
  24986. intersectsPoint(point: Vector3): boolean;
  24987. /**
  24988. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  24989. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24990. */
  24991. checkCollisions: boolean;
  24992. /**
  24993. * Gets Collider object used to compute collisions (not physics)
  24994. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24995. */
  24996. readonly collider: Collider;
  24997. /**
  24998. * Move the mesh using collision engine
  24999. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25000. * @param displacement defines the requested displacement vector
  25001. * @returns the current mesh
  25002. */
  25003. moveWithCollisions(displacement: Vector3): AbstractMesh;
  25004. private _onCollisionPositionChange;
  25005. /** @hidden */
  25006. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  25007. /** @hidden */
  25008. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  25009. /** @hidden */
  25010. _checkCollision(collider: Collider): AbstractMesh;
  25011. /** @hidden */
  25012. _generatePointsArray(): boolean;
  25013. /**
  25014. * Checks if the passed Ray intersects with the mesh
  25015. * @param ray defines the ray to use
  25016. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  25017. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  25018. * @returns the picking info
  25019. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  25020. */
  25021. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  25022. /**
  25023. * Clones the current mesh
  25024. * @param name defines the mesh name
  25025. * @param newParent defines the new mesh parent
  25026. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  25027. * @returns the new mesh
  25028. */
  25029. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  25030. /**
  25031. * Disposes all the submeshes of the current meshnp
  25032. * @returns the current mesh
  25033. */
  25034. releaseSubMeshes(): AbstractMesh;
  25035. /**
  25036. * Releases resources associated with this abstract mesh.
  25037. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25038. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25039. */
  25040. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25041. /**
  25042. * Adds the passed mesh as a child to the current mesh
  25043. * @param mesh defines the child mesh
  25044. * @returns the current mesh
  25045. */
  25046. addChild(mesh: AbstractMesh): AbstractMesh;
  25047. /**
  25048. * Removes the passed mesh from the current mesh children list
  25049. * @param mesh defines the child mesh
  25050. * @returns the current mesh
  25051. */
  25052. removeChild(mesh: AbstractMesh): AbstractMesh;
  25053. /** @hidden */
  25054. private _initFacetData;
  25055. /**
  25056. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  25057. * This method can be called within the render loop.
  25058. * 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
  25059. * @returns the current mesh
  25060. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25061. */
  25062. updateFacetData(): AbstractMesh;
  25063. /**
  25064. * Returns the facetLocalNormals array.
  25065. * The normals are expressed in the mesh local spac
  25066. * @returns an array of Vector3
  25067. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25068. */
  25069. getFacetLocalNormals(): Vector3[];
  25070. /**
  25071. * Returns the facetLocalPositions array.
  25072. * The facet positions are expressed in the mesh local space
  25073. * @returns an array of Vector3
  25074. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25075. */
  25076. getFacetLocalPositions(): Vector3[];
  25077. /**
  25078. * Returns the facetLocalPartioning array
  25079. * @returns an array of array of numbers
  25080. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25081. */
  25082. getFacetLocalPartitioning(): number[][];
  25083. /**
  25084. * Returns the i-th facet position in the world system.
  25085. * This method allocates a new Vector3 per call
  25086. * @param i defines the facet index
  25087. * @returns a new Vector3
  25088. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25089. */
  25090. getFacetPosition(i: number): Vector3;
  25091. /**
  25092. * Sets the reference Vector3 with the i-th facet position in the world system
  25093. * @param i defines the facet index
  25094. * @param ref defines the target vector
  25095. * @returns the current mesh
  25096. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25097. */
  25098. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  25099. /**
  25100. * Returns the i-th facet normal in the world system.
  25101. * This method allocates a new Vector3 per call
  25102. * @param i defines the facet index
  25103. * @returns a new Vector3
  25104. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25105. */
  25106. getFacetNormal(i: number): Vector3;
  25107. /**
  25108. * Sets the reference Vector3 with the i-th facet normal in the world system
  25109. * @param i defines the facet index
  25110. * @param ref defines the target vector
  25111. * @returns the current mesh
  25112. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25113. */
  25114. getFacetNormalToRef(i: number, ref: Vector3): this;
  25115. /**
  25116. * 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)
  25117. * @param x defines x coordinate
  25118. * @param y defines y coordinate
  25119. * @param z defines z coordinate
  25120. * @returns the array of facet indexes
  25121. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25122. */
  25123. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  25124. /**
  25125. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  25126. * @param projected sets as the (x,y,z) world projection on the facet
  25127. * @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
  25128. * @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
  25129. * @param x defines x coordinate
  25130. * @param y defines y coordinate
  25131. * @param z defines z coordinate
  25132. * @returns the face index if found (or null instead)
  25133. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25134. */
  25135. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  25136. /**
  25137. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  25138. * @param projected sets as the (x,y,z) local projection on the facet
  25139. * @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
  25140. * @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
  25141. * @param x defines x coordinate
  25142. * @param y defines y coordinate
  25143. * @param z defines z coordinate
  25144. * @returns the face index if found (or null instead)
  25145. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25146. */
  25147. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  25148. /**
  25149. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  25150. * @returns the parameters
  25151. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25152. */
  25153. getFacetDataParameters(): any;
  25154. /**
  25155. * Disables the feature FacetData and frees the related memory
  25156. * @returns the current mesh
  25157. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25158. */
  25159. disableFacetData(): AbstractMesh;
  25160. /**
  25161. * Updates the AbstractMesh indices array
  25162. * @param indices defines the data source
  25163. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  25164. * @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)
  25165. * @returns the current mesh
  25166. */
  25167. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  25168. /**
  25169. * Creates new normals data for the mesh
  25170. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  25171. * @returns the current mesh
  25172. */
  25173. createNormals(updatable: boolean): AbstractMesh;
  25174. /**
  25175. * Align the mesh with a normal
  25176. * @param normal defines the normal to use
  25177. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  25178. * @returns the current mesh
  25179. */
  25180. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  25181. /** @hidden */
  25182. _checkOcclusionQuery(): boolean;
  25183. }
  25184. }
  25185. declare module "babylonjs/Actions/actionEvent" {
  25186. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25187. import { Nullable } from "babylonjs/types";
  25188. import { Sprite } from "babylonjs/Sprites/sprite";
  25189. import { Scene } from "babylonjs/scene";
  25190. import { Vector2 } from "babylonjs/Maths/math";
  25191. /**
  25192. * Interface used to define ActionEvent
  25193. */
  25194. export interface IActionEvent {
  25195. /** The mesh or sprite that triggered the action */
  25196. source: any;
  25197. /** The X mouse cursor position at the time of the event */
  25198. pointerX: number;
  25199. /** The Y mouse cursor position at the time of the event */
  25200. pointerY: number;
  25201. /** The mesh that is currently pointed at (can be null) */
  25202. meshUnderPointer: Nullable<AbstractMesh>;
  25203. /** the original (browser) event that triggered the ActionEvent */
  25204. sourceEvent?: any;
  25205. /** additional data for the event */
  25206. additionalData?: any;
  25207. }
  25208. /**
  25209. * ActionEvent is the event being sent when an action is triggered.
  25210. */
  25211. export class ActionEvent implements IActionEvent {
  25212. /** The mesh or sprite that triggered the action */
  25213. source: any;
  25214. /** The X mouse cursor position at the time of the event */
  25215. pointerX: number;
  25216. /** The Y mouse cursor position at the time of the event */
  25217. pointerY: number;
  25218. /** The mesh that is currently pointed at (can be null) */
  25219. meshUnderPointer: Nullable<AbstractMesh>;
  25220. /** the original (browser) event that triggered the ActionEvent */
  25221. sourceEvent?: any;
  25222. /** additional data for the event */
  25223. additionalData?: any;
  25224. /**
  25225. * Creates a new ActionEvent
  25226. * @param source The mesh or sprite that triggered the action
  25227. * @param pointerX The X mouse cursor position at the time of the event
  25228. * @param pointerY The Y mouse cursor position at the time of the event
  25229. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  25230. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  25231. * @param additionalData additional data for the event
  25232. */
  25233. constructor(
  25234. /** The mesh or sprite that triggered the action */
  25235. source: any,
  25236. /** The X mouse cursor position at the time of the event */
  25237. pointerX: number,
  25238. /** The Y mouse cursor position at the time of the event */
  25239. pointerY: number,
  25240. /** The mesh that is currently pointed at (can be null) */
  25241. meshUnderPointer: Nullable<AbstractMesh>,
  25242. /** the original (browser) event that triggered the ActionEvent */
  25243. sourceEvent?: any,
  25244. /** additional data for the event */
  25245. additionalData?: any);
  25246. /**
  25247. * Helper function to auto-create an ActionEvent from a source mesh.
  25248. * @param source The source mesh that triggered the event
  25249. * @param evt The original (browser) event
  25250. * @param additionalData additional data for the event
  25251. * @returns the new ActionEvent
  25252. */
  25253. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  25254. /**
  25255. * Helper function to auto-create an ActionEvent from a source sprite
  25256. * @param source The source sprite that triggered the event
  25257. * @param scene Scene associated with the sprite
  25258. * @param evt The original (browser) event
  25259. * @param additionalData additional data for the event
  25260. * @returns the new ActionEvent
  25261. */
  25262. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  25263. /**
  25264. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  25265. * @param scene the scene where the event occurred
  25266. * @param evt The original (browser) event
  25267. * @returns the new ActionEvent
  25268. */
  25269. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  25270. /**
  25271. * Helper function to auto-create an ActionEvent from a primitive
  25272. * @param prim defines the target primitive
  25273. * @param pointerPos defines the pointer position
  25274. * @param evt The original (browser) event
  25275. * @param additionalData additional data for the event
  25276. * @returns the new ActionEvent
  25277. */
  25278. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  25279. }
  25280. }
  25281. declare module "babylonjs/Actions/abstractActionManager" {
  25282. import { IDisposable } from "babylonjs/scene";
  25283. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  25284. import { IAction } from "babylonjs/Actions/action";
  25285. import { Nullable } from "babylonjs/types";
  25286. /**
  25287. * Abstract class used to decouple action Manager from scene and meshes.
  25288. * Do not instantiate.
  25289. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  25290. */
  25291. export abstract class AbstractActionManager implements IDisposable {
  25292. /** Gets the list of active triggers */
  25293. static Triggers: {
  25294. [key: string]: number;
  25295. };
  25296. /** Gets the cursor to use when hovering items */
  25297. hoverCursor: string;
  25298. /** Gets the list of actions */
  25299. actions: IAction[];
  25300. /**
  25301. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  25302. */
  25303. isRecursive: boolean;
  25304. /**
  25305. * Releases all associated resources
  25306. */
  25307. abstract dispose(): void;
  25308. /**
  25309. * Does this action manager has pointer triggers
  25310. */
  25311. abstract readonly hasPointerTriggers: boolean;
  25312. /**
  25313. * Does this action manager has pick triggers
  25314. */
  25315. abstract readonly hasPickTriggers: boolean;
  25316. /**
  25317. * Process a specific trigger
  25318. * @param trigger defines the trigger to process
  25319. * @param evt defines the event details to be processed
  25320. */
  25321. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  25322. /**
  25323. * Does this action manager handles actions of any of the given triggers
  25324. * @param triggers defines the triggers to be tested
  25325. * @return a boolean indicating whether one (or more) of the triggers is handled
  25326. */
  25327. abstract hasSpecificTriggers(triggers: number[]): boolean;
  25328. /**
  25329. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  25330. * speed.
  25331. * @param triggerA defines the trigger to be tested
  25332. * @param triggerB defines the trigger to be tested
  25333. * @return a boolean indicating whether one (or more) of the triggers is handled
  25334. */
  25335. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  25336. /**
  25337. * Does this action manager handles actions of a given trigger
  25338. * @param trigger defines the trigger to be tested
  25339. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  25340. * @return whether the trigger is handled
  25341. */
  25342. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  25343. /**
  25344. * Serialize this manager to a JSON object
  25345. * @param name defines the property name to store this manager
  25346. * @returns a JSON representation of this manager
  25347. */
  25348. abstract serialize(name: string): any;
  25349. /**
  25350. * Registers an action to this action manager
  25351. * @param action defines the action to be registered
  25352. * @return the action amended (prepared) after registration
  25353. */
  25354. abstract registerAction(action: IAction): Nullable<IAction>;
  25355. /**
  25356. * Unregisters an action to this action manager
  25357. * @param action defines the action to be unregistered
  25358. * @return a boolean indicating whether the action has been unregistered
  25359. */
  25360. abstract unregisterAction(action: IAction): Boolean;
  25361. /**
  25362. * Does exist one action manager with at least one trigger
  25363. **/
  25364. static readonly HasTriggers: boolean;
  25365. /**
  25366. * Does exist one action manager with at least one pick trigger
  25367. **/
  25368. static readonly HasPickTriggers: boolean;
  25369. /**
  25370. * Does exist one action manager that handles actions of a given trigger
  25371. * @param trigger defines the trigger to be tested
  25372. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  25373. **/
  25374. static HasSpecificTrigger(trigger: number): boolean;
  25375. }
  25376. }
  25377. declare module "babylonjs/node" {
  25378. import { Scene } from "babylonjs/scene";
  25379. import { Nullable } from "babylonjs/types";
  25380. import { Matrix } from "babylonjs/Maths/math";
  25381. import { Engine } from "babylonjs/Engines/engine";
  25382. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  25383. import { Observable } from "babylonjs/Misc/observable";
  25384. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  25385. import { IInspectable } from "babylonjs/Misc/iInspectable";
  25386. import { Animatable } from "babylonjs/Animations/animatable";
  25387. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  25388. import { Animation } from "babylonjs/Animations/animation";
  25389. import { AnimationRange } from "babylonjs/Animations/animationRange";
  25390. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25391. /**
  25392. * Defines how a node can be built from a string name.
  25393. */
  25394. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  25395. /**
  25396. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  25397. */
  25398. export class Node implements IBehaviorAware<Node> {
  25399. /** @hidden */
  25400. static _AnimationRangeFactory: (name: string, from: number, to: number) => import("babylonjs/Animations/animationRange").AnimationRange;
  25401. private static _NodeConstructors;
  25402. /**
  25403. * Add a new node constructor
  25404. * @param type defines the type name of the node to construct
  25405. * @param constructorFunc defines the constructor function
  25406. */
  25407. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  25408. /**
  25409. * Returns a node constructor based on type name
  25410. * @param type defines the type name
  25411. * @param name defines the new node name
  25412. * @param scene defines the hosting scene
  25413. * @param options defines optional options to transmit to constructors
  25414. * @returns the new constructor or null
  25415. */
  25416. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  25417. /**
  25418. * Gets or sets the name of the node
  25419. */
  25420. name: string;
  25421. /**
  25422. * Gets or sets the id of the node
  25423. */
  25424. id: string;
  25425. /**
  25426. * Gets or sets the unique id of the node
  25427. */
  25428. uniqueId: number;
  25429. /**
  25430. * Gets or sets a string used to store user defined state for the node
  25431. */
  25432. state: string;
  25433. /**
  25434. * Gets or sets an object used to store user defined information for the node
  25435. */
  25436. metadata: any;
  25437. /**
  25438. * For internal use only. Please do not use.
  25439. */
  25440. reservedDataStore: any;
  25441. /**
  25442. * List of inspectable custom properties (used by the Inspector)
  25443. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  25444. */
  25445. inspectableCustomProperties: IInspectable[];
  25446. /**
  25447. * Gets or sets a boolean used to define if the node must be serialized
  25448. */
  25449. doNotSerialize: boolean;
  25450. /** @hidden */
  25451. _isDisposed: boolean;
  25452. /**
  25453. * Gets a list of Animations associated with the node
  25454. */
  25455. animations: import("babylonjs/Animations/animation").Animation[];
  25456. protected _ranges: {
  25457. [name: string]: Nullable<AnimationRange>;
  25458. };
  25459. /**
  25460. * Callback raised when the node is ready to be used
  25461. */
  25462. onReady: (node: Node) => void;
  25463. private _isEnabled;
  25464. private _isParentEnabled;
  25465. private _isReady;
  25466. /** @hidden */
  25467. _currentRenderId: number;
  25468. private _parentUpdateId;
  25469. protected _childUpdateId: number;
  25470. /** @hidden */
  25471. _waitingParentId: Nullable<string>;
  25472. /** @hidden */
  25473. _scene: Scene;
  25474. /** @hidden */
  25475. _cache: any;
  25476. private _parentNode;
  25477. private _children;
  25478. /** @hidden */
  25479. _worldMatrix: Matrix;
  25480. /** @hidden */
  25481. _worldMatrixDeterminant: number;
  25482. /** @hidden */
  25483. private _sceneRootNodesIndex;
  25484. /**
  25485. * Gets a boolean indicating if the node has been disposed
  25486. * @returns true if the node was disposed
  25487. */
  25488. isDisposed(): boolean;
  25489. /**
  25490. * Gets or sets the parent of the node (without keeping the current position in the scene)
  25491. * @see https://doc.babylonjs.com/how_to/parenting
  25492. */
  25493. parent: Nullable<Node>;
  25494. private addToSceneRootNodes;
  25495. private removeFromSceneRootNodes;
  25496. private _animationPropertiesOverride;
  25497. /**
  25498. * Gets or sets the animation properties override
  25499. */
  25500. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  25501. /**
  25502. * Gets a string idenfifying the name of the class
  25503. * @returns "Node" string
  25504. */
  25505. getClassName(): string;
  25506. /** @hidden */
  25507. readonly _isNode: boolean;
  25508. /**
  25509. * An event triggered when the mesh is disposed
  25510. */
  25511. onDisposeObservable: Observable<Node>;
  25512. private _onDisposeObserver;
  25513. /**
  25514. * Sets a callback that will be raised when the node will be disposed
  25515. */
  25516. onDispose: () => void;
  25517. /**
  25518. * Creates a new Node
  25519. * @param name the name and id to be given to this node
  25520. * @param scene the scene this node will be added to
  25521. * @param addToRootNodes the node will be added to scene.rootNodes
  25522. */
  25523. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  25524. /**
  25525. * Gets the scene of the node
  25526. * @returns a scene
  25527. */
  25528. getScene(): Scene;
  25529. /**
  25530. * Gets the engine of the node
  25531. * @returns a Engine
  25532. */
  25533. getEngine(): Engine;
  25534. private _behaviors;
  25535. /**
  25536. * Attach a behavior to the node
  25537. * @see http://doc.babylonjs.com/features/behaviour
  25538. * @param behavior defines the behavior to attach
  25539. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  25540. * @returns the current Node
  25541. */
  25542. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  25543. /**
  25544. * Remove an attached behavior
  25545. * @see http://doc.babylonjs.com/features/behaviour
  25546. * @param behavior defines the behavior to attach
  25547. * @returns the current Node
  25548. */
  25549. removeBehavior(behavior: Behavior<Node>): Node;
  25550. /**
  25551. * Gets the list of attached behaviors
  25552. * @see http://doc.babylonjs.com/features/behaviour
  25553. */
  25554. readonly behaviors: Behavior<Node>[];
  25555. /**
  25556. * Gets an attached behavior by name
  25557. * @param name defines the name of the behavior to look for
  25558. * @see http://doc.babylonjs.com/features/behaviour
  25559. * @returns null if behavior was not found else the requested behavior
  25560. */
  25561. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  25562. /**
  25563. * Returns the latest update of the World matrix
  25564. * @returns a Matrix
  25565. */
  25566. getWorldMatrix(): Matrix;
  25567. /** @hidden */
  25568. _getWorldMatrixDeterminant(): number;
  25569. /**
  25570. * Returns directly the latest state of the mesh World matrix.
  25571. * A Matrix is returned.
  25572. */
  25573. readonly worldMatrixFromCache: Matrix;
  25574. /** @hidden */
  25575. _initCache(): void;
  25576. /** @hidden */
  25577. updateCache(force?: boolean): void;
  25578. /** @hidden */
  25579. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  25580. /** @hidden */
  25581. _updateCache(ignoreParentClass?: boolean): void;
  25582. /** @hidden */
  25583. _isSynchronized(): boolean;
  25584. /** @hidden */
  25585. _markSyncedWithParent(): void;
  25586. /** @hidden */
  25587. isSynchronizedWithParent(): boolean;
  25588. /** @hidden */
  25589. isSynchronized(): boolean;
  25590. /**
  25591. * Is this node ready to be used/rendered
  25592. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  25593. * @return true if the node is ready
  25594. */
  25595. isReady(completeCheck?: boolean): boolean;
  25596. /**
  25597. * Is this node enabled?
  25598. * 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
  25599. * @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
  25600. * @return whether this node (and its parent) is enabled
  25601. */
  25602. isEnabled(checkAncestors?: boolean): boolean;
  25603. /** @hidden */
  25604. protected _syncParentEnabledState(): void;
  25605. /**
  25606. * Set the enabled state of this node
  25607. * @param value defines the new enabled state
  25608. */
  25609. setEnabled(value: boolean): void;
  25610. /**
  25611. * Is this node a descendant of the given node?
  25612. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  25613. * @param ancestor defines the parent node to inspect
  25614. * @returns a boolean indicating if this node is a descendant of the given node
  25615. */
  25616. isDescendantOf(ancestor: Node): boolean;
  25617. /** @hidden */
  25618. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  25619. /**
  25620. * Will return all nodes that have this node as ascendant
  25621. * @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
  25622. * @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
  25623. * @return all children nodes of all types
  25624. */
  25625. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  25626. /**
  25627. * Get all child-meshes of this node
  25628. * @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)
  25629. * @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
  25630. * @returns an array of AbstractMesh
  25631. */
  25632. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  25633. /**
  25634. * Get all direct children of this node
  25635. * @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
  25636. * @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)
  25637. * @returns an array of Node
  25638. */
  25639. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  25640. /** @hidden */
  25641. _setReady(state: boolean): void;
  25642. /**
  25643. * Get an animation by name
  25644. * @param name defines the name of the animation to look for
  25645. * @returns null if not found else the requested animation
  25646. */
  25647. getAnimationByName(name: string): Nullable<Animation>;
  25648. /**
  25649. * Creates an animation range for this node
  25650. * @param name defines the name of the range
  25651. * @param from defines the starting key
  25652. * @param to defines the end key
  25653. */
  25654. createAnimationRange(name: string, from: number, to: number): void;
  25655. /**
  25656. * Delete a specific animation range
  25657. * @param name defines the name of the range to delete
  25658. * @param deleteFrames defines if animation frames from the range must be deleted as well
  25659. */
  25660. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  25661. /**
  25662. * Get an animation range by name
  25663. * @param name defines the name of the animation range to look for
  25664. * @returns null if not found else the requested animation range
  25665. */
  25666. getAnimationRange(name: string): Nullable<AnimationRange>;
  25667. /**
  25668. * Gets the list of all animation ranges defined on this node
  25669. * @returns an array
  25670. */
  25671. getAnimationRanges(): Nullable<AnimationRange>[];
  25672. /**
  25673. * Will start the animation sequence
  25674. * @param name defines the range frames for animation sequence
  25675. * @param loop defines if the animation should loop (false by default)
  25676. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  25677. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  25678. * @returns the object created for this animation. If range does not exist, it will return null
  25679. */
  25680. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  25681. /**
  25682. * Serialize animation ranges into a JSON compatible object
  25683. * @returns serialization object
  25684. */
  25685. serializeAnimationRanges(): any;
  25686. /**
  25687. * Computes the world matrix of the node
  25688. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  25689. * @returns the world matrix
  25690. */
  25691. computeWorldMatrix(force?: boolean): Matrix;
  25692. /**
  25693. * Releases resources associated with this node.
  25694. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25695. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25696. */
  25697. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25698. /**
  25699. * Parse animation range data from a serialization object and store them into a given node
  25700. * @param node defines where to store the animation ranges
  25701. * @param parsedNode defines the serialization object to read data from
  25702. * @param scene defines the hosting scene
  25703. */
  25704. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  25705. }
  25706. }
  25707. declare module "babylonjs/Animations/animation" {
  25708. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  25709. import { Vector3, Quaternion, Vector2, Color3, Size, Matrix } from "babylonjs/Maths/math";
  25710. import { Nullable } from "babylonjs/types";
  25711. import { Scene } from "babylonjs/scene";
  25712. import { IAnimatable } from "babylonjs/Misc/tools";
  25713. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  25714. import { AnimationRange } from "babylonjs/Animations/animationRange";
  25715. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  25716. import { Node } from "babylonjs/node";
  25717. import { Animatable } from "babylonjs/Animations/animatable";
  25718. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  25719. /**
  25720. * Class used to store any kind of animation
  25721. */
  25722. export class Animation {
  25723. /**Name of the animation */
  25724. name: string;
  25725. /**Property to animate */
  25726. targetProperty: string;
  25727. /**The frames per second of the animation */
  25728. framePerSecond: number;
  25729. /**The data type of the animation */
  25730. dataType: number;
  25731. /**The loop mode of the animation */
  25732. loopMode?: number | undefined;
  25733. /**Specifies if blending should be enabled */
  25734. enableBlending?: boolean | undefined;
  25735. /**
  25736. * Use matrix interpolation instead of using direct key value when animating matrices
  25737. */
  25738. static AllowMatricesInterpolation: boolean;
  25739. /**
  25740. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  25741. */
  25742. static AllowMatrixDecomposeForInterpolation: boolean;
  25743. /**
  25744. * Stores the key frames of the animation
  25745. */
  25746. private _keys;
  25747. /**
  25748. * Stores the easing function of the animation
  25749. */
  25750. private _easingFunction;
  25751. /**
  25752. * @hidden Internal use only
  25753. */
  25754. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  25755. /**
  25756. * The set of event that will be linked to this animation
  25757. */
  25758. private _events;
  25759. /**
  25760. * Stores an array of target property paths
  25761. */
  25762. targetPropertyPath: string[];
  25763. /**
  25764. * Stores the blending speed of the animation
  25765. */
  25766. blendingSpeed: number;
  25767. /**
  25768. * Stores the animation ranges for the animation
  25769. */
  25770. private _ranges;
  25771. /**
  25772. * @hidden Internal use
  25773. */
  25774. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  25775. /**
  25776. * Sets up an animation
  25777. * @param property The property to animate
  25778. * @param animationType The animation type to apply
  25779. * @param framePerSecond The frames per second of the animation
  25780. * @param easingFunction The easing function used in the animation
  25781. * @returns The created animation
  25782. */
  25783. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  25784. /**
  25785. * Create and start an animation on a node
  25786. * @param name defines the name of the global animation that will be run on all nodes
  25787. * @param node defines the root node where the animation will take place
  25788. * @param targetProperty defines property to animate
  25789. * @param framePerSecond defines the number of frame per second yo use
  25790. * @param totalFrame defines the number of frames in total
  25791. * @param from defines the initial value
  25792. * @param to defines the final value
  25793. * @param loopMode defines which loop mode you want to use (off by default)
  25794. * @param easingFunction defines the easing function to use (linear by default)
  25795. * @param onAnimationEnd defines the callback to call when animation end
  25796. * @returns the animatable created for this animation
  25797. */
  25798. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  25799. /**
  25800. * Create and start an animation on a node and its descendants
  25801. * @param name defines the name of the global animation that will be run on all nodes
  25802. * @param node defines the root node where the animation will take place
  25803. * @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
  25804. * @param targetProperty defines property to animate
  25805. * @param framePerSecond defines the number of frame per second to use
  25806. * @param totalFrame defines the number of frames in total
  25807. * @param from defines the initial value
  25808. * @param to defines the final value
  25809. * @param loopMode defines which loop mode you want to use (off by default)
  25810. * @param easingFunction defines the easing function to use (linear by default)
  25811. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  25812. * @returns the list of animatables created for all nodes
  25813. * @example https://www.babylonjs-playground.com/#MH0VLI
  25814. */
  25815. 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[]>;
  25816. /**
  25817. * Creates a new animation, merges it with the existing animations and starts it
  25818. * @param name Name of the animation
  25819. * @param node Node which contains the scene that begins the animations
  25820. * @param targetProperty Specifies which property to animate
  25821. * @param framePerSecond The frames per second of the animation
  25822. * @param totalFrame The total number of frames
  25823. * @param from The frame at the beginning of the animation
  25824. * @param to The frame at the end of the animation
  25825. * @param loopMode Specifies the loop mode of the animation
  25826. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  25827. * @param onAnimationEnd Callback to run once the animation is complete
  25828. * @returns Nullable animation
  25829. */
  25830. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  25831. /**
  25832. * Transition property of an host to the target Value
  25833. * @param property The property to transition
  25834. * @param targetValue The target Value of the property
  25835. * @param host The object where the property to animate belongs
  25836. * @param scene Scene used to run the animation
  25837. * @param frameRate Framerate (in frame/s) to use
  25838. * @param transition The transition type we want to use
  25839. * @param duration The duration of the animation, in milliseconds
  25840. * @param onAnimationEnd Callback trigger at the end of the animation
  25841. * @returns Nullable animation
  25842. */
  25843. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  25844. /**
  25845. * Return the array of runtime animations currently using this animation
  25846. */
  25847. readonly runtimeAnimations: RuntimeAnimation[];
  25848. /**
  25849. * Specifies if any of the runtime animations are currently running
  25850. */
  25851. readonly hasRunningRuntimeAnimations: boolean;
  25852. /**
  25853. * Initializes the animation
  25854. * @param name Name of the animation
  25855. * @param targetProperty Property to animate
  25856. * @param framePerSecond The frames per second of the animation
  25857. * @param dataType The data type of the animation
  25858. * @param loopMode The loop mode of the animation
  25859. * @param enableBlending Specifies if blending should be enabled
  25860. */
  25861. constructor(
  25862. /**Name of the animation */
  25863. name: string,
  25864. /**Property to animate */
  25865. targetProperty: string,
  25866. /**The frames per second of the animation */
  25867. framePerSecond: number,
  25868. /**The data type of the animation */
  25869. dataType: number,
  25870. /**The loop mode of the animation */
  25871. loopMode?: number | undefined,
  25872. /**Specifies if blending should be enabled */
  25873. enableBlending?: boolean | undefined);
  25874. /**
  25875. * Converts the animation to a string
  25876. * @param fullDetails support for multiple levels of logging within scene loading
  25877. * @returns String form of the animation
  25878. */
  25879. toString(fullDetails?: boolean): string;
  25880. /**
  25881. * Add an event to this animation
  25882. * @param event Event to add
  25883. */
  25884. addEvent(event: AnimationEvent): void;
  25885. /**
  25886. * Remove all events found at the given frame
  25887. * @param frame The frame to remove events from
  25888. */
  25889. removeEvents(frame: number): void;
  25890. /**
  25891. * Retrieves all the events from the animation
  25892. * @returns Events from the animation
  25893. */
  25894. getEvents(): AnimationEvent[];
  25895. /**
  25896. * Creates an animation range
  25897. * @param name Name of the animation range
  25898. * @param from Starting frame of the animation range
  25899. * @param to Ending frame of the animation
  25900. */
  25901. createRange(name: string, from: number, to: number): void;
  25902. /**
  25903. * Deletes an animation range by name
  25904. * @param name Name of the animation range to delete
  25905. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  25906. */
  25907. deleteRange(name: string, deleteFrames?: boolean): void;
  25908. /**
  25909. * Gets the animation range by name, or null if not defined
  25910. * @param name Name of the animation range
  25911. * @returns Nullable animation range
  25912. */
  25913. getRange(name: string): Nullable<AnimationRange>;
  25914. /**
  25915. * Gets the key frames from the animation
  25916. * @returns The key frames of the animation
  25917. */
  25918. getKeys(): Array<IAnimationKey>;
  25919. /**
  25920. * Gets the highest frame rate of the animation
  25921. * @returns Highest frame rate of the animation
  25922. */
  25923. getHighestFrame(): number;
  25924. /**
  25925. * Gets the easing function of the animation
  25926. * @returns Easing function of the animation
  25927. */
  25928. getEasingFunction(): IEasingFunction;
  25929. /**
  25930. * Sets the easing function of the animation
  25931. * @param easingFunction A custom mathematical formula for animation
  25932. */
  25933. setEasingFunction(easingFunction: EasingFunction): void;
  25934. /**
  25935. * Interpolates a scalar linearly
  25936. * @param startValue Start value of the animation curve
  25937. * @param endValue End value of the animation curve
  25938. * @param gradient Scalar amount to interpolate
  25939. * @returns Interpolated scalar value
  25940. */
  25941. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  25942. /**
  25943. * Interpolates a scalar cubically
  25944. * @param startValue Start value of the animation curve
  25945. * @param outTangent End tangent of the animation
  25946. * @param endValue End value of the animation curve
  25947. * @param inTangent Start tangent of the animation curve
  25948. * @param gradient Scalar amount to interpolate
  25949. * @returns Interpolated scalar value
  25950. */
  25951. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  25952. /**
  25953. * Interpolates a quaternion using a spherical linear interpolation
  25954. * @param startValue Start value of the animation curve
  25955. * @param endValue End value of the animation curve
  25956. * @param gradient Scalar amount to interpolate
  25957. * @returns Interpolated quaternion value
  25958. */
  25959. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  25960. /**
  25961. * Interpolates a quaternion cubically
  25962. * @param startValue Start value of the animation curve
  25963. * @param outTangent End tangent of the animation curve
  25964. * @param endValue End value of the animation curve
  25965. * @param inTangent Start tangent of the animation curve
  25966. * @param gradient Scalar amount to interpolate
  25967. * @returns Interpolated quaternion value
  25968. */
  25969. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  25970. /**
  25971. * Interpolates a Vector3 linearl
  25972. * @param startValue Start value of the animation curve
  25973. * @param endValue End value of the animation curve
  25974. * @param gradient Scalar amount to interpolate
  25975. * @returns Interpolated scalar value
  25976. */
  25977. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  25978. /**
  25979. * Interpolates a Vector3 cubically
  25980. * @param startValue Start value of the animation curve
  25981. * @param outTangent End tangent of the animation
  25982. * @param endValue End value of the animation curve
  25983. * @param inTangent Start tangent of the animation curve
  25984. * @param gradient Scalar amount to interpolate
  25985. * @returns InterpolatedVector3 value
  25986. */
  25987. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  25988. /**
  25989. * Interpolates a Vector2 linearly
  25990. * @param startValue Start value of the animation curve
  25991. * @param endValue End value of the animation curve
  25992. * @param gradient Scalar amount to interpolate
  25993. * @returns Interpolated Vector2 value
  25994. */
  25995. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  25996. /**
  25997. * Interpolates a Vector2 cubically
  25998. * @param startValue Start value of the animation curve
  25999. * @param outTangent End tangent of the animation
  26000. * @param endValue End value of the animation curve
  26001. * @param inTangent Start tangent of the animation curve
  26002. * @param gradient Scalar amount to interpolate
  26003. * @returns Interpolated Vector2 value
  26004. */
  26005. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  26006. /**
  26007. * Interpolates a size linearly
  26008. * @param startValue Start value of the animation curve
  26009. * @param endValue End value of the animation curve
  26010. * @param gradient Scalar amount to interpolate
  26011. * @returns Interpolated Size value
  26012. */
  26013. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  26014. /**
  26015. * Interpolates a Color3 linearly
  26016. * @param startValue Start value of the animation curve
  26017. * @param endValue End value of the animation curve
  26018. * @param gradient Scalar amount to interpolate
  26019. * @returns Interpolated Color3 value
  26020. */
  26021. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  26022. /**
  26023. * @hidden Internal use only
  26024. */
  26025. _getKeyValue(value: any): any;
  26026. /**
  26027. * @hidden Internal use only
  26028. */
  26029. _interpolate(currentFrame: number, repeatCount: number, workValue?: any, loopMode?: number, offsetValue?: any, highLimitValue?: any): any;
  26030. /**
  26031. * Defines the function to use to interpolate matrices
  26032. * @param startValue defines the start matrix
  26033. * @param endValue defines the end matrix
  26034. * @param gradient defines the gradient between both matrices
  26035. * @param result defines an optional target matrix where to store the interpolation
  26036. * @returns the interpolated matrix
  26037. */
  26038. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  26039. /**
  26040. * Makes a copy of the animation
  26041. * @returns Cloned animation
  26042. */
  26043. clone(): Animation;
  26044. /**
  26045. * Sets the key frames of the animation
  26046. * @param values The animation key frames to set
  26047. */
  26048. setKeys(values: Array<IAnimationKey>): void;
  26049. /**
  26050. * Serializes the animation to an object
  26051. * @returns Serialized object
  26052. */
  26053. serialize(): any;
  26054. /**
  26055. * Float animation type
  26056. */
  26057. private static _ANIMATIONTYPE_FLOAT;
  26058. /**
  26059. * Vector3 animation type
  26060. */
  26061. private static _ANIMATIONTYPE_VECTOR3;
  26062. /**
  26063. * Quaternion animation type
  26064. */
  26065. private static _ANIMATIONTYPE_QUATERNION;
  26066. /**
  26067. * Matrix animation type
  26068. */
  26069. private static _ANIMATIONTYPE_MATRIX;
  26070. /**
  26071. * Color3 animation type
  26072. */
  26073. private static _ANIMATIONTYPE_COLOR3;
  26074. /**
  26075. * Vector2 animation type
  26076. */
  26077. private static _ANIMATIONTYPE_VECTOR2;
  26078. /**
  26079. * Size animation type
  26080. */
  26081. private static _ANIMATIONTYPE_SIZE;
  26082. /**
  26083. * Relative Loop Mode
  26084. */
  26085. private static _ANIMATIONLOOPMODE_RELATIVE;
  26086. /**
  26087. * Cycle Loop Mode
  26088. */
  26089. private static _ANIMATIONLOOPMODE_CYCLE;
  26090. /**
  26091. * Constant Loop Mode
  26092. */
  26093. private static _ANIMATIONLOOPMODE_CONSTANT;
  26094. /**
  26095. * Get the float animation type
  26096. */
  26097. static readonly ANIMATIONTYPE_FLOAT: number;
  26098. /**
  26099. * Get the Vector3 animation type
  26100. */
  26101. static readonly ANIMATIONTYPE_VECTOR3: number;
  26102. /**
  26103. * Get the Vector2 animation type
  26104. */
  26105. static readonly ANIMATIONTYPE_VECTOR2: number;
  26106. /**
  26107. * Get the Size animation type
  26108. */
  26109. static readonly ANIMATIONTYPE_SIZE: number;
  26110. /**
  26111. * Get the Quaternion animation type
  26112. */
  26113. static readonly ANIMATIONTYPE_QUATERNION: number;
  26114. /**
  26115. * Get the Matrix animation type
  26116. */
  26117. static readonly ANIMATIONTYPE_MATRIX: number;
  26118. /**
  26119. * Get the Color3 animation type
  26120. */
  26121. static readonly ANIMATIONTYPE_COLOR3: number;
  26122. /**
  26123. * Get the Relative Loop Mode
  26124. */
  26125. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  26126. /**
  26127. * Get the Cycle Loop Mode
  26128. */
  26129. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  26130. /**
  26131. * Get the Constant Loop Mode
  26132. */
  26133. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  26134. /** @hidden */
  26135. static _UniversalLerp(left: any, right: any, amount: number): any;
  26136. /**
  26137. * Parses an animation object and creates an animation
  26138. * @param parsedAnimation Parsed animation object
  26139. * @returns Animation object
  26140. */
  26141. static Parse(parsedAnimation: any): Animation;
  26142. /**
  26143. * Appends the serialized animations from the source animations
  26144. * @param source Source containing the animations
  26145. * @param destination Target to store the animations
  26146. */
  26147. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  26148. }
  26149. }
  26150. declare module "babylonjs/Materials/Textures/baseTexture" {
  26151. import { Observable } from "babylonjs/Misc/observable";
  26152. import { IAnimatable } from "babylonjs/Misc/tools";
  26153. import { Nullable } from "babylonjs/types";
  26154. import { Scene } from "babylonjs/scene";
  26155. import { Matrix, ISize } from "babylonjs/Maths/math";
  26156. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  26157. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  26158. /**
  26159. * Base class of all the textures in babylon.
  26160. * It groups all the common properties the materials, post process, lights... might need
  26161. * in order to make a correct use of the texture.
  26162. */
  26163. export class BaseTexture implements IAnimatable {
  26164. /**
  26165. * Default anisotropic filtering level for the application.
  26166. * It is set to 4 as a good tradeoff between perf and quality.
  26167. */
  26168. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  26169. /**
  26170. * Gets or sets the unique id of the texture
  26171. */
  26172. uniqueId: number;
  26173. /**
  26174. * Define the name of the texture.
  26175. */
  26176. name: string;
  26177. /**
  26178. * Gets or sets an object used to store user defined information.
  26179. */
  26180. metadata: any;
  26181. /**
  26182. * For internal use only. Please do not use.
  26183. */
  26184. reservedDataStore: any;
  26185. private _hasAlpha;
  26186. /**
  26187. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  26188. */
  26189. hasAlpha: boolean;
  26190. /**
  26191. * Defines if the alpha value should be determined via the rgb values.
  26192. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  26193. */
  26194. getAlphaFromRGB: boolean;
  26195. /**
  26196. * Intensity or strength of the texture.
  26197. * It is commonly used by materials to fine tune the intensity of the texture
  26198. */
  26199. level: number;
  26200. /**
  26201. * Define the UV chanel to use starting from 0 and defaulting to 0.
  26202. * This is part of the texture as textures usually maps to one uv set.
  26203. */
  26204. coordinatesIndex: number;
  26205. private _coordinatesMode;
  26206. /**
  26207. * How a texture is mapped.
  26208. *
  26209. * | Value | Type | Description |
  26210. * | ----- | ----------------------------------- | ----------- |
  26211. * | 0 | EXPLICIT_MODE | |
  26212. * | 1 | SPHERICAL_MODE | |
  26213. * | 2 | PLANAR_MODE | |
  26214. * | 3 | CUBIC_MODE | |
  26215. * | 4 | PROJECTION_MODE | |
  26216. * | 5 | SKYBOX_MODE | |
  26217. * | 6 | INVCUBIC_MODE | |
  26218. * | 7 | EQUIRECTANGULAR_MODE | |
  26219. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  26220. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  26221. */
  26222. coordinatesMode: number;
  26223. /**
  26224. * | Value | Type | Description |
  26225. * | ----- | ------------------ | ----------- |
  26226. * | 0 | CLAMP_ADDRESSMODE | |
  26227. * | 1 | WRAP_ADDRESSMODE | |
  26228. * | 2 | MIRROR_ADDRESSMODE | |
  26229. */
  26230. wrapU: number;
  26231. /**
  26232. * | Value | Type | Description |
  26233. * | ----- | ------------------ | ----------- |
  26234. * | 0 | CLAMP_ADDRESSMODE | |
  26235. * | 1 | WRAP_ADDRESSMODE | |
  26236. * | 2 | MIRROR_ADDRESSMODE | |
  26237. */
  26238. wrapV: number;
  26239. /**
  26240. * | Value | Type | Description |
  26241. * | ----- | ------------------ | ----------- |
  26242. * | 0 | CLAMP_ADDRESSMODE | |
  26243. * | 1 | WRAP_ADDRESSMODE | |
  26244. * | 2 | MIRROR_ADDRESSMODE | |
  26245. */
  26246. wrapR: number;
  26247. /**
  26248. * With compliant hardware and browser (supporting anisotropic filtering)
  26249. * this defines the level of anisotropic filtering in the texture.
  26250. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  26251. */
  26252. anisotropicFilteringLevel: number;
  26253. /**
  26254. * Define if the texture is a cube texture or if false a 2d texture.
  26255. */
  26256. isCube: boolean;
  26257. /**
  26258. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  26259. */
  26260. is3D: boolean;
  26261. /**
  26262. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  26263. * HDR texture are usually stored in linear space.
  26264. * This only impacts the PBR and Background materials
  26265. */
  26266. gammaSpace: boolean;
  26267. /**
  26268. * Gets whether or not the texture contains RGBD data.
  26269. */
  26270. readonly isRGBD: boolean;
  26271. /**
  26272. * Is Z inverted in the texture (useful in a cube texture).
  26273. */
  26274. invertZ: boolean;
  26275. /**
  26276. * Are mip maps generated for this texture or not.
  26277. */
  26278. readonly noMipmap: boolean;
  26279. /**
  26280. * @hidden
  26281. */
  26282. lodLevelInAlpha: boolean;
  26283. /**
  26284. * With prefiltered texture, defined the offset used during the prefiltering steps.
  26285. */
  26286. lodGenerationOffset: number;
  26287. /**
  26288. * With prefiltered texture, defined the scale used during the prefiltering steps.
  26289. */
  26290. lodGenerationScale: number;
  26291. /**
  26292. * Define if the texture is a render target.
  26293. */
  26294. isRenderTarget: boolean;
  26295. /**
  26296. * Define the unique id of the texture in the scene.
  26297. */
  26298. readonly uid: string;
  26299. /**
  26300. * Return a string representation of the texture.
  26301. * @returns the texture as a string
  26302. */
  26303. toString(): string;
  26304. /**
  26305. * Get the class name of the texture.
  26306. * @returns "BaseTexture"
  26307. */
  26308. getClassName(): string;
  26309. /**
  26310. * Define the list of animation attached to the texture.
  26311. */
  26312. animations: import("babylonjs/Animations/animation").Animation[];
  26313. /**
  26314. * An event triggered when the texture is disposed.
  26315. */
  26316. onDisposeObservable: Observable<BaseTexture>;
  26317. private _onDisposeObserver;
  26318. /**
  26319. * Callback triggered when the texture has been disposed.
  26320. * Kept for back compatibility, you can use the onDisposeObservable instead.
  26321. */
  26322. onDispose: () => void;
  26323. /**
  26324. * Define the current state of the loading sequence when in delayed load mode.
  26325. */
  26326. delayLoadState: number;
  26327. private _scene;
  26328. /** @hidden */
  26329. _texture: Nullable<InternalTexture>;
  26330. private _uid;
  26331. /**
  26332. * Define if the texture is preventinga material to render or not.
  26333. * If not and the texture is not ready, the engine will use a default black texture instead.
  26334. */
  26335. readonly isBlocking: boolean;
  26336. /**
  26337. * Instantiates a new BaseTexture.
  26338. * Base class of all the textures in babylon.
  26339. * It groups all the common properties the materials, post process, lights... might need
  26340. * in order to make a correct use of the texture.
  26341. * @param scene Define the scene the texture blongs to
  26342. */
  26343. constructor(scene: Nullable<Scene>);
  26344. /**
  26345. * Get the scene the texture belongs to.
  26346. * @returns the scene or null if undefined
  26347. */
  26348. getScene(): Nullable<Scene>;
  26349. /**
  26350. * Get the texture transform matrix used to offset tile the texture for istance.
  26351. * @returns the transformation matrix
  26352. */
  26353. getTextureMatrix(): Matrix;
  26354. /**
  26355. * Get the texture reflection matrix used to rotate/transform the reflection.
  26356. * @returns the reflection matrix
  26357. */
  26358. getReflectionTextureMatrix(): Matrix;
  26359. /**
  26360. * Get the underlying lower level texture from Babylon.
  26361. * @returns the insternal texture
  26362. */
  26363. getInternalTexture(): Nullable<InternalTexture>;
  26364. /**
  26365. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  26366. * @returns true if ready or not blocking
  26367. */
  26368. isReadyOrNotBlocking(): boolean;
  26369. /**
  26370. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  26371. * @returns true if fully ready
  26372. */
  26373. isReady(): boolean;
  26374. private _cachedSize;
  26375. /**
  26376. * Get the size of the texture.
  26377. * @returns the texture size.
  26378. */
  26379. getSize(): ISize;
  26380. /**
  26381. * Get the base size of the texture.
  26382. * It can be different from the size if the texture has been resized for POT for instance
  26383. * @returns the base size
  26384. */
  26385. getBaseSize(): ISize;
  26386. /**
  26387. * Update the sampling mode of the texture.
  26388. * Default is Trilinear mode.
  26389. *
  26390. * | Value | Type | Description |
  26391. * | ----- | ------------------ | ----------- |
  26392. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  26393. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  26394. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  26395. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  26396. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  26397. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  26398. * | 7 | NEAREST_LINEAR | |
  26399. * | 8 | NEAREST_NEAREST | |
  26400. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  26401. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  26402. * | 11 | LINEAR_LINEAR | |
  26403. * | 12 | LINEAR_NEAREST | |
  26404. *
  26405. * > _mag_: magnification filter (close to the viewer)
  26406. * > _min_: minification filter (far from the viewer)
  26407. * > _mip_: filter used between mip map levels
  26408. *@param samplingMode Define the new sampling mode of the texture
  26409. */
  26410. updateSamplingMode(samplingMode: number): void;
  26411. /**
  26412. * Scales the texture if is `canRescale()`
  26413. * @param ratio the resize factor we want to use to rescale
  26414. */
  26415. scale(ratio: number): void;
  26416. /**
  26417. * Get if the texture can rescale.
  26418. */
  26419. readonly canRescale: boolean;
  26420. /** @hidden */
  26421. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  26422. /** @hidden */
  26423. _rebuild(): void;
  26424. /**
  26425. * Triggers the load sequence in delayed load mode.
  26426. */
  26427. delayLoad(): void;
  26428. /**
  26429. * Clones the texture.
  26430. * @returns the cloned texture
  26431. */
  26432. clone(): Nullable<BaseTexture>;
  26433. /**
  26434. * Get the texture underlying type (INT, FLOAT...)
  26435. */
  26436. readonly textureType: number;
  26437. /**
  26438. * Get the texture underlying format (RGB, RGBA...)
  26439. */
  26440. readonly textureFormat: number;
  26441. /**
  26442. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  26443. * This will returns an RGBA array buffer containing either in values (0-255) or
  26444. * float values (0-1) depending of the underlying buffer type.
  26445. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  26446. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  26447. * @param buffer defines a user defined buffer to fill with data (can be null)
  26448. * @returns The Array buffer containing the pixels data.
  26449. */
  26450. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  26451. /**
  26452. * Release and destroy the underlying lower level texture aka internalTexture.
  26453. */
  26454. releaseInternalTexture(): void;
  26455. /**
  26456. * Get the polynomial representation of the texture data.
  26457. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  26458. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  26459. */
  26460. sphericalPolynomial: Nullable<SphericalPolynomial>;
  26461. /** @hidden */
  26462. readonly _lodTextureHigh: Nullable<BaseTexture>;
  26463. /** @hidden */
  26464. readonly _lodTextureMid: Nullable<BaseTexture>;
  26465. /** @hidden */
  26466. readonly _lodTextureLow: Nullable<BaseTexture>;
  26467. /**
  26468. * Dispose the texture and release its associated resources.
  26469. */
  26470. dispose(): void;
  26471. /**
  26472. * Serialize the texture into a JSON representation that can be parsed later on.
  26473. * @returns the JSON representation of the texture
  26474. */
  26475. serialize(): any;
  26476. /**
  26477. * Helper function to be called back once a list of texture contains only ready textures.
  26478. * @param textures Define the list of textures to wait for
  26479. * @param callback Define the callback triggered once the entire list will be ready
  26480. */
  26481. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  26482. }
  26483. }
  26484. declare module "babylonjs/Materials/uniformBuffer" {
  26485. import { Nullable, FloatArray } from "babylonjs/types";
  26486. import { Matrix, Vector3, Color3, Vector4 } from "babylonjs/Maths/math";
  26487. import { Engine } from "babylonjs/Engines/engine";
  26488. import { Effect } from "babylonjs/Materials/effect";
  26489. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  26490. /**
  26491. * Uniform buffer objects.
  26492. *
  26493. * Handles blocks of uniform on the GPU.
  26494. *
  26495. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  26496. *
  26497. * For more information, please refer to :
  26498. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  26499. */
  26500. export class UniformBuffer {
  26501. private _engine;
  26502. private _buffer;
  26503. private _data;
  26504. private _bufferData;
  26505. private _dynamic?;
  26506. private _uniformLocations;
  26507. private _uniformSizes;
  26508. private _uniformLocationPointer;
  26509. private _needSync;
  26510. private _noUBO;
  26511. private _currentEffect;
  26512. private static _MAX_UNIFORM_SIZE;
  26513. private static _tempBuffer;
  26514. /**
  26515. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  26516. * This is dynamic to allow compat with webgl 1 and 2.
  26517. * You will need to pass the name of the uniform as well as the value.
  26518. */
  26519. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  26520. /**
  26521. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  26522. * This is dynamic to allow compat with webgl 1 and 2.
  26523. * You will need to pass the name of the uniform as well as the value.
  26524. */
  26525. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  26526. /**
  26527. * Lambda to Update a single float in a uniform buffer.
  26528. * This is dynamic to allow compat with webgl 1 and 2.
  26529. * You will need to pass the name of the uniform as well as the value.
  26530. */
  26531. updateFloat: (name: string, x: number) => void;
  26532. /**
  26533. * Lambda to Update a vec2 of float in a uniform buffer.
  26534. * This is dynamic to allow compat with webgl 1 and 2.
  26535. * You will need to pass the name of the uniform as well as the value.
  26536. */
  26537. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  26538. /**
  26539. * Lambda to Update a vec3 of float in a uniform buffer.
  26540. * This is dynamic to allow compat with webgl 1 and 2.
  26541. * You will need to pass the name of the uniform as well as the value.
  26542. */
  26543. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  26544. /**
  26545. * Lambda to Update a vec4 of float in a uniform buffer.
  26546. * This is dynamic to allow compat with webgl 1 and 2.
  26547. * You will need to pass the name of the uniform as well as the value.
  26548. */
  26549. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  26550. /**
  26551. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  26552. * This is dynamic to allow compat with webgl 1 and 2.
  26553. * You will need to pass the name of the uniform as well as the value.
  26554. */
  26555. updateMatrix: (name: string, mat: Matrix) => void;
  26556. /**
  26557. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  26558. * This is dynamic to allow compat with webgl 1 and 2.
  26559. * You will need to pass the name of the uniform as well as the value.
  26560. */
  26561. updateVector3: (name: string, vector: Vector3) => void;
  26562. /**
  26563. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  26564. * This is dynamic to allow compat with webgl 1 and 2.
  26565. * You will need to pass the name of the uniform as well as the value.
  26566. */
  26567. updateVector4: (name: string, vector: Vector4) => void;
  26568. /**
  26569. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  26570. * This is dynamic to allow compat with webgl 1 and 2.
  26571. * You will need to pass the name of the uniform as well as the value.
  26572. */
  26573. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  26574. /**
  26575. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  26576. * This is dynamic to allow compat with webgl 1 and 2.
  26577. * You will need to pass the name of the uniform as well as the value.
  26578. */
  26579. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  26580. /**
  26581. * Instantiates a new Uniform buffer objects.
  26582. *
  26583. * Handles blocks of uniform on the GPU.
  26584. *
  26585. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  26586. *
  26587. * For more information, please refer to :
  26588. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  26589. * @param engine Define the engine the buffer is associated with
  26590. * @param data Define the data contained in the buffer
  26591. * @param dynamic Define if the buffer is updatable
  26592. */
  26593. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  26594. /**
  26595. * Indicates if the buffer is using the WebGL2 UBO implementation,
  26596. * or just falling back on setUniformXXX calls.
  26597. */
  26598. readonly useUbo: boolean;
  26599. /**
  26600. * Indicates if the WebGL underlying uniform buffer is in sync
  26601. * with the javascript cache data.
  26602. */
  26603. readonly isSync: boolean;
  26604. /**
  26605. * Indicates if the WebGL underlying uniform buffer is dynamic.
  26606. * Also, a dynamic UniformBuffer will disable cache verification and always
  26607. * update the underlying WebGL uniform buffer to the GPU.
  26608. * @returns if Dynamic, otherwise false
  26609. */
  26610. isDynamic(): boolean;
  26611. /**
  26612. * The data cache on JS side.
  26613. * @returns the underlying data as a float array
  26614. */
  26615. getData(): Float32Array;
  26616. /**
  26617. * The underlying WebGL Uniform buffer.
  26618. * @returns the webgl buffer
  26619. */
  26620. getBuffer(): Nullable<WebGLBuffer>;
  26621. /**
  26622. * std140 layout specifies how to align data within an UBO structure.
  26623. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  26624. * for specs.
  26625. */
  26626. private _fillAlignment;
  26627. /**
  26628. * Adds an uniform in the buffer.
  26629. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  26630. * for the layout to be correct !
  26631. * @param name Name of the uniform, as used in the uniform block in the shader.
  26632. * @param size Data size, or data directly.
  26633. */
  26634. addUniform(name: string, size: number | number[]): void;
  26635. /**
  26636. * Adds a Matrix 4x4 to the uniform buffer.
  26637. * @param name Name of the uniform, as used in the uniform block in the shader.
  26638. * @param mat A 4x4 matrix.
  26639. */
  26640. addMatrix(name: string, mat: Matrix): void;
  26641. /**
  26642. * Adds a vec2 to the uniform buffer.
  26643. * @param name Name of the uniform, as used in the uniform block in the shader.
  26644. * @param x Define the x component value of the vec2
  26645. * @param y Define the y component value of the vec2
  26646. */
  26647. addFloat2(name: string, x: number, y: number): void;
  26648. /**
  26649. * Adds a vec3 to the uniform buffer.
  26650. * @param name Name of the uniform, as used in the uniform block in the shader.
  26651. * @param x Define the x component value of the vec3
  26652. * @param y Define the y component value of the vec3
  26653. * @param z Define the z component value of the vec3
  26654. */
  26655. addFloat3(name: string, x: number, y: number, z: number): void;
  26656. /**
  26657. * Adds a vec3 to the uniform buffer.
  26658. * @param name Name of the uniform, as used in the uniform block in the shader.
  26659. * @param color Define the vec3 from a Color
  26660. */
  26661. addColor3(name: string, color: Color3): void;
  26662. /**
  26663. * Adds a vec4 to the uniform buffer.
  26664. * @param name Name of the uniform, as used in the uniform block in the shader.
  26665. * @param color Define the rgb components from a Color
  26666. * @param alpha Define the a component of the vec4
  26667. */
  26668. addColor4(name: string, color: Color3, alpha: number): void;
  26669. /**
  26670. * Adds a vec3 to the uniform buffer.
  26671. * @param name Name of the uniform, as used in the uniform block in the shader.
  26672. * @param vector Define the vec3 components from a Vector
  26673. */
  26674. addVector3(name: string, vector: Vector3): void;
  26675. /**
  26676. * Adds a Matrix 3x3 to the uniform buffer.
  26677. * @param name Name of the uniform, as used in the uniform block in the shader.
  26678. */
  26679. addMatrix3x3(name: string): void;
  26680. /**
  26681. * Adds a Matrix 2x2 to the uniform buffer.
  26682. * @param name Name of the uniform, as used in the uniform block in the shader.
  26683. */
  26684. addMatrix2x2(name: string): void;
  26685. /**
  26686. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  26687. */
  26688. create(): void;
  26689. /** @hidden */
  26690. _rebuild(): void;
  26691. /**
  26692. * Updates the WebGL Uniform Buffer on the GPU.
  26693. * If the `dynamic` flag is set to true, no cache comparison is done.
  26694. * Otherwise, the buffer will be updated only if the cache differs.
  26695. */
  26696. update(): void;
  26697. /**
  26698. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  26699. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  26700. * @param data Define the flattened data
  26701. * @param size Define the size of the data.
  26702. */
  26703. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  26704. private _updateMatrix3x3ForUniform;
  26705. private _updateMatrix3x3ForEffect;
  26706. private _updateMatrix2x2ForEffect;
  26707. private _updateMatrix2x2ForUniform;
  26708. private _updateFloatForEffect;
  26709. private _updateFloatForUniform;
  26710. private _updateFloat2ForEffect;
  26711. private _updateFloat2ForUniform;
  26712. private _updateFloat3ForEffect;
  26713. private _updateFloat3ForUniform;
  26714. private _updateFloat4ForEffect;
  26715. private _updateFloat4ForUniform;
  26716. private _updateMatrixForEffect;
  26717. private _updateMatrixForUniform;
  26718. private _updateVector3ForEffect;
  26719. private _updateVector3ForUniform;
  26720. private _updateVector4ForEffect;
  26721. private _updateVector4ForUniform;
  26722. private _updateColor3ForEffect;
  26723. private _updateColor3ForUniform;
  26724. private _updateColor4ForEffect;
  26725. private _updateColor4ForUniform;
  26726. /**
  26727. * Sets a sampler uniform on the effect.
  26728. * @param name Define the name of the sampler.
  26729. * @param texture Define the texture to set in the sampler
  26730. */
  26731. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  26732. /**
  26733. * Directly updates the value of the uniform in the cache AND on the GPU.
  26734. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  26735. * @param data Define the flattened data
  26736. */
  26737. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  26738. /**
  26739. * Binds this uniform buffer to an effect.
  26740. * @param effect Define the effect to bind the buffer to
  26741. * @param name Name of the uniform block in the shader.
  26742. */
  26743. bindToEffect(effect: Effect, name: string): void;
  26744. /**
  26745. * Disposes the uniform buffer.
  26746. */
  26747. dispose(): void;
  26748. }
  26749. }
  26750. declare module "babylonjs/Materials/Textures/internalTextureLoader" {
  26751. import { Nullable } from "babylonjs/types";
  26752. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  26753. /**
  26754. * This represents the required contract to create a new type of texture loader.
  26755. */
  26756. export interface IInternalTextureLoader {
  26757. /**
  26758. * Defines wether the loader supports cascade loading the different faces.
  26759. */
  26760. supportCascades: boolean;
  26761. /**
  26762. * This returns if the loader support the current file information.
  26763. * @param extension defines the file extension of the file being loaded
  26764. * @param textureFormatInUse defines the current compressed format in use iun the engine
  26765. * @param fallback defines the fallback internal texture if any
  26766. * @param isBase64 defines whether the texture is encoded as a base64
  26767. * @param isBuffer defines whether the texture data are stored as a buffer
  26768. * @returns true if the loader can load the specified file
  26769. */
  26770. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  26771. /**
  26772. * Transform the url before loading if required.
  26773. * @param rootUrl the url of the texture
  26774. * @param textureFormatInUse defines the current compressed format in use iun the engine
  26775. * @returns the transformed texture
  26776. */
  26777. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  26778. /**
  26779. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  26780. * @param rootUrl the url of the texture
  26781. * @param textureFormatInUse defines the current compressed format in use iun the engine
  26782. * @returns the fallback texture
  26783. */
  26784. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  26785. /**
  26786. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  26787. * @param data contains the texture data
  26788. * @param texture defines the BabylonJS internal texture
  26789. * @param createPolynomials will be true if polynomials have been requested
  26790. * @param onLoad defines the callback to trigger once the texture is ready
  26791. * @param onError defines the callback to trigger in case of error
  26792. */
  26793. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  26794. /**
  26795. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  26796. * @param data contains the texture data
  26797. * @param texture defines the BabylonJS internal texture
  26798. * @param callback defines the method to call once ready to upload
  26799. */
  26800. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  26801. }
  26802. }
  26803. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  26804. import { Scene } from "babylonjs/scene";
  26805. import { Engine } from "babylonjs/Engines/engine";
  26806. import { Texture } from "babylonjs/Materials/Textures/texture";
  26807. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  26808. /**
  26809. * Creation options of the multi render target texture.
  26810. */
  26811. export interface IMultiRenderTargetOptions {
  26812. /**
  26813. * Define if the texture needs to create mip maps after render.
  26814. */
  26815. generateMipMaps?: boolean;
  26816. /**
  26817. * Define the types of all the draw buffers we want to create
  26818. */
  26819. types?: number[];
  26820. /**
  26821. * Define the sampling modes of all the draw buffers we want to create
  26822. */
  26823. samplingModes?: number[];
  26824. /**
  26825. * Define if a depth buffer is required
  26826. */
  26827. generateDepthBuffer?: boolean;
  26828. /**
  26829. * Define if a stencil buffer is required
  26830. */
  26831. generateStencilBuffer?: boolean;
  26832. /**
  26833. * Define if a depth texture is required instead of a depth buffer
  26834. */
  26835. generateDepthTexture?: boolean;
  26836. /**
  26837. * Define the number of desired draw buffers
  26838. */
  26839. textureCount?: number;
  26840. /**
  26841. * Define if aspect ratio should be adapted to the texture or stay the scene one
  26842. */
  26843. doNotChangeAspectRatio?: boolean;
  26844. /**
  26845. * Define the default type of the buffers we are creating
  26846. */
  26847. defaultType?: number;
  26848. }
  26849. /**
  26850. * A multi render target, like a render target provides the ability to render to a texture.
  26851. * Unlike the render target, it can render to several draw buffers in one draw.
  26852. * This is specially interesting in deferred rendering or for any effects requiring more than
  26853. * just one color from a single pass.
  26854. */
  26855. export class MultiRenderTarget extends RenderTargetTexture {
  26856. private _internalTextures;
  26857. private _textures;
  26858. private _multiRenderTargetOptions;
  26859. /**
  26860. * Get if draw buffers are currently supported by the used hardware and browser.
  26861. */
  26862. readonly isSupported: boolean;
  26863. /**
  26864. * Get the list of textures generated by the multi render target.
  26865. */
  26866. readonly textures: Texture[];
  26867. /**
  26868. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  26869. */
  26870. readonly depthTexture: Texture;
  26871. /**
  26872. * Set the wrapping mode on U of all the textures we are rendering to.
  26873. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  26874. */
  26875. wrapU: number;
  26876. /**
  26877. * Set the wrapping mode on V of all the textures we are rendering to.
  26878. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  26879. */
  26880. wrapV: number;
  26881. /**
  26882. * Instantiate a new multi render target texture.
  26883. * A multi render target, like a render target provides the ability to render to a texture.
  26884. * Unlike the render target, it can render to several draw buffers in one draw.
  26885. * This is specially interesting in deferred rendering or for any effects requiring more than
  26886. * just one color from a single pass.
  26887. * @param name Define the name of the texture
  26888. * @param size Define the size of the buffers to render to
  26889. * @param count Define the number of target we are rendering into
  26890. * @param scene Define the scene the texture belongs to
  26891. * @param options Define the options used to create the multi render target
  26892. */
  26893. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  26894. /** @hidden */
  26895. _rebuild(): void;
  26896. private _createInternalTextures;
  26897. private _createTextures;
  26898. /**
  26899. * Define the number of samples used if MSAA is enabled.
  26900. */
  26901. samples: number;
  26902. /**
  26903. * Resize all the textures in the multi render target.
  26904. * Be carrefull as it will recreate all the data in the new texture.
  26905. * @param size Define the new size
  26906. */
  26907. resize(size: any): void;
  26908. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  26909. /**
  26910. * Dispose the render targets and their associated resources
  26911. */
  26912. dispose(): void;
  26913. /**
  26914. * Release all the underlying texture used as draw buffers.
  26915. */
  26916. releaseInternalTextures(): void;
  26917. }
  26918. }
  26919. declare module "babylonjs/Audio/analyser" {
  26920. import { Scene } from "babylonjs/scene";
  26921. /**
  26922. * Class used to work with sound analyzer using fast fourier transform (FFT)
  26923. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26924. */
  26925. export class Analyser {
  26926. /**
  26927. * Gets or sets the smoothing
  26928. * @ignorenaming
  26929. */
  26930. SMOOTHING: number;
  26931. /**
  26932. * Gets or sets the FFT table size
  26933. * @ignorenaming
  26934. */
  26935. FFT_SIZE: number;
  26936. /**
  26937. * Gets or sets the bar graph amplitude
  26938. * @ignorenaming
  26939. */
  26940. BARGRAPHAMPLITUDE: number;
  26941. /**
  26942. * Gets or sets the position of the debug canvas
  26943. * @ignorenaming
  26944. */
  26945. DEBUGCANVASPOS: {
  26946. x: number;
  26947. y: number;
  26948. };
  26949. /**
  26950. * Gets or sets the debug canvas size
  26951. * @ignorenaming
  26952. */
  26953. DEBUGCANVASSIZE: {
  26954. width: number;
  26955. height: number;
  26956. };
  26957. private _byteFreqs;
  26958. private _byteTime;
  26959. private _floatFreqs;
  26960. private _webAudioAnalyser;
  26961. private _debugCanvas;
  26962. private _debugCanvasContext;
  26963. private _scene;
  26964. private _registerFunc;
  26965. private _audioEngine;
  26966. /**
  26967. * Creates a new analyser
  26968. * @param scene defines hosting scene
  26969. */
  26970. constructor(scene: Scene);
  26971. /**
  26972. * Get the number of data values you will have to play with for the visualization
  26973. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  26974. * @returns a number
  26975. */
  26976. getFrequencyBinCount(): number;
  26977. /**
  26978. * Gets the current frequency data as a byte array
  26979. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  26980. * @returns a Uint8Array
  26981. */
  26982. getByteFrequencyData(): Uint8Array;
  26983. /**
  26984. * Gets the current waveform as a byte array
  26985. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  26986. * @returns a Uint8Array
  26987. */
  26988. getByteTimeDomainData(): Uint8Array;
  26989. /**
  26990. * Gets the current frequency data as a float array
  26991. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  26992. * @returns a Float32Array
  26993. */
  26994. getFloatFrequencyData(): Float32Array;
  26995. /**
  26996. * Renders the debug canvas
  26997. */
  26998. drawDebugCanvas(): void;
  26999. /**
  27000. * Stops rendering the debug canvas and removes it
  27001. */
  27002. stopDebugCanvas(): void;
  27003. /**
  27004. * Connects two audio nodes
  27005. * @param inputAudioNode defines first node to connect
  27006. * @param outputAudioNode defines second node to connect
  27007. */
  27008. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  27009. /**
  27010. * Releases all associated resources
  27011. */
  27012. dispose(): void;
  27013. }
  27014. }
  27015. declare module "babylonjs/Audio/audioEngine" {
  27016. import { IDisposable } from "babylonjs/scene";
  27017. import { Analyser } from "babylonjs/Audio/analyser";
  27018. import { Nullable } from "babylonjs/types";
  27019. import { Observable } from "babylonjs/Misc/observable";
  27020. /**
  27021. * This represents an audio engine and it is responsible
  27022. * to play, synchronize and analyse sounds throughout the application.
  27023. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27024. */
  27025. export interface IAudioEngine extends IDisposable {
  27026. /**
  27027. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  27028. */
  27029. readonly canUseWebAudio: boolean;
  27030. /**
  27031. * Gets the current AudioContext if available.
  27032. */
  27033. readonly audioContext: Nullable<AudioContext>;
  27034. /**
  27035. * The master gain node defines the global audio volume of your audio engine.
  27036. */
  27037. readonly masterGain: GainNode;
  27038. /**
  27039. * Gets whether or not mp3 are supported by your browser.
  27040. */
  27041. readonly isMP3supported: boolean;
  27042. /**
  27043. * Gets whether or not ogg are supported by your browser.
  27044. */
  27045. readonly isOGGsupported: boolean;
  27046. /**
  27047. * Defines if Babylon should emit a warning if WebAudio is not supported.
  27048. * @ignoreNaming
  27049. */
  27050. WarnedWebAudioUnsupported: boolean;
  27051. /**
  27052. * Defines if the audio engine relies on a custom unlocked button.
  27053. * In this case, the embedded button will not be displayed.
  27054. */
  27055. useCustomUnlockedButton: boolean;
  27056. /**
  27057. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  27058. */
  27059. readonly unlocked: boolean;
  27060. /**
  27061. * Event raised when audio has been unlocked on the browser.
  27062. */
  27063. onAudioUnlockedObservable: Observable<AudioEngine>;
  27064. /**
  27065. * Event raised when audio has been locked on the browser.
  27066. */
  27067. onAudioLockedObservable: Observable<AudioEngine>;
  27068. /**
  27069. * Flags the audio engine in Locked state.
  27070. * This happens due to new browser policies preventing audio to autoplay.
  27071. */
  27072. lock(): void;
  27073. /**
  27074. * Unlocks the audio engine once a user action has been done on the dom.
  27075. * This is helpful to resume play once browser policies have been satisfied.
  27076. */
  27077. unlock(): void;
  27078. }
  27079. /**
  27080. * This represents the default audio engine used in babylon.
  27081. * It is responsible to play, synchronize and analyse sounds throughout the application.
  27082. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27083. */
  27084. export class AudioEngine implements IAudioEngine {
  27085. private _audioContext;
  27086. private _audioContextInitialized;
  27087. private _muteButton;
  27088. private _hostElement;
  27089. /**
  27090. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  27091. */
  27092. canUseWebAudio: boolean;
  27093. /**
  27094. * The master gain node defines the global audio volume of your audio engine.
  27095. */
  27096. masterGain: GainNode;
  27097. /**
  27098. * Defines if Babylon should emit a warning if WebAudio is not supported.
  27099. * @ignoreNaming
  27100. */
  27101. WarnedWebAudioUnsupported: boolean;
  27102. /**
  27103. * Gets whether or not mp3 are supported by your browser.
  27104. */
  27105. isMP3supported: boolean;
  27106. /**
  27107. * Gets whether or not ogg are supported by your browser.
  27108. */
  27109. isOGGsupported: boolean;
  27110. /**
  27111. * Gets whether audio has been unlocked on the device.
  27112. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  27113. * a user interaction has happened.
  27114. */
  27115. unlocked: boolean;
  27116. /**
  27117. * Defines if the audio engine relies on a custom unlocked button.
  27118. * In this case, the embedded button will not be displayed.
  27119. */
  27120. useCustomUnlockedButton: boolean;
  27121. /**
  27122. * Event raised when audio has been unlocked on the browser.
  27123. */
  27124. onAudioUnlockedObservable: Observable<AudioEngine>;
  27125. /**
  27126. * Event raised when audio has been locked on the browser.
  27127. */
  27128. onAudioLockedObservable: Observable<AudioEngine>;
  27129. /**
  27130. * Gets the current AudioContext if available.
  27131. */
  27132. readonly audioContext: Nullable<AudioContext>;
  27133. private _connectedAnalyser;
  27134. /**
  27135. * Instantiates a new audio engine.
  27136. *
  27137. * There should be only one per page as some browsers restrict the number
  27138. * of audio contexts you can create.
  27139. * @param hostElement defines the host element where to display the mute icon if necessary
  27140. */
  27141. constructor(hostElement?: Nullable<HTMLElement>);
  27142. /**
  27143. * Flags the audio engine in Locked state.
  27144. * This happens due to new browser policies preventing audio to autoplay.
  27145. */
  27146. lock(): void;
  27147. /**
  27148. * Unlocks the audio engine once a user action has been done on the dom.
  27149. * This is helpful to resume play once browser policies have been satisfied.
  27150. */
  27151. unlock(): void;
  27152. private _resumeAudioContext;
  27153. private _initializeAudioContext;
  27154. private _tryToRun;
  27155. private _triggerRunningState;
  27156. private _triggerSuspendedState;
  27157. private _displayMuteButton;
  27158. private _moveButtonToTopLeft;
  27159. private _onResize;
  27160. private _hideMuteButton;
  27161. /**
  27162. * Destroy and release the resources associated with the audio ccontext.
  27163. */
  27164. dispose(): void;
  27165. /**
  27166. * Gets the global volume sets on the master gain.
  27167. * @returns the global volume if set or -1 otherwise
  27168. */
  27169. getGlobalVolume(): number;
  27170. /**
  27171. * Sets the global volume of your experience (sets on the master gain).
  27172. * @param newVolume Defines the new global volume of the application
  27173. */
  27174. setGlobalVolume(newVolume: number): void;
  27175. /**
  27176. * Connect the audio engine to an audio analyser allowing some amazing
  27177. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  27178. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  27179. * @param analyser The analyser to connect to the engine
  27180. */
  27181. connectToAnalyser(analyser: Analyser): void;
  27182. }
  27183. }
  27184. declare module "babylonjs/Loading/loadingScreen" {
  27185. /**
  27186. * Interface used to present a loading screen while loading a scene
  27187. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  27188. */
  27189. export interface ILoadingScreen {
  27190. /**
  27191. * Function called to display the loading screen
  27192. */
  27193. displayLoadingUI: () => void;
  27194. /**
  27195. * Function called to hide the loading screen
  27196. */
  27197. hideLoadingUI: () => void;
  27198. /**
  27199. * Gets or sets the color to use for the background
  27200. */
  27201. loadingUIBackgroundColor: string;
  27202. /**
  27203. * Gets or sets the text to display while loading
  27204. */
  27205. loadingUIText: string;
  27206. }
  27207. /**
  27208. * Class used for the default loading screen
  27209. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  27210. */
  27211. export class DefaultLoadingScreen implements ILoadingScreen {
  27212. private _renderingCanvas;
  27213. private _loadingText;
  27214. private _loadingDivBackgroundColor;
  27215. private _loadingDiv;
  27216. private _loadingTextDiv;
  27217. /**
  27218. * Creates a new default loading screen
  27219. * @param _renderingCanvas defines the canvas used to render the scene
  27220. * @param _loadingText defines the default text to display
  27221. * @param _loadingDivBackgroundColor defines the default background color
  27222. */
  27223. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  27224. /**
  27225. * Function called to display the loading screen
  27226. */
  27227. displayLoadingUI(): void;
  27228. /**
  27229. * Function called to hide the loading screen
  27230. */
  27231. hideLoadingUI(): void;
  27232. /**
  27233. * Gets or sets the text to display while loading
  27234. */
  27235. loadingUIText: string;
  27236. /**
  27237. * Gets or sets the color to use for the background
  27238. */
  27239. loadingUIBackgroundColor: string;
  27240. private _resizeLoadingUI;
  27241. }
  27242. }
  27243. declare module "babylonjs/Materials/Textures/videoTexture" {
  27244. import { Observable } from "babylonjs/Misc/observable";
  27245. import { Nullable } from "babylonjs/types";
  27246. import { Scene } from "babylonjs/scene";
  27247. import { Texture } from "babylonjs/Materials/Textures/texture";
  27248. /**
  27249. * Settings for finer control over video usage
  27250. */
  27251. export interface VideoTextureSettings {
  27252. /**
  27253. * Applies `autoplay` to video, if specified
  27254. */
  27255. autoPlay?: boolean;
  27256. /**
  27257. * Applies `loop` to video, if specified
  27258. */
  27259. loop?: boolean;
  27260. /**
  27261. * Automatically updates internal texture from video at every frame in the render loop
  27262. */
  27263. autoUpdateTexture: boolean;
  27264. /**
  27265. * Image src displayed during the video loading or until the user interacts with the video.
  27266. */
  27267. poster?: string;
  27268. }
  27269. /**
  27270. * If you want to display a video in your scene, this is the special texture for that.
  27271. * This special texture works similar to other textures, with the exception of a few parameters.
  27272. * @see https://doc.babylonjs.com/how_to/video_texture
  27273. */
  27274. export class VideoTexture extends Texture {
  27275. /**
  27276. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  27277. */
  27278. readonly autoUpdateTexture: boolean;
  27279. /**
  27280. * The video instance used by the texture internally
  27281. */
  27282. readonly video: HTMLVideoElement;
  27283. private _onUserActionRequestedObservable;
  27284. /**
  27285. * Event triggerd when a dom action is required by the user to play the video.
  27286. * This happens due to recent changes in browser policies preventing video to auto start.
  27287. */
  27288. readonly onUserActionRequestedObservable: Observable<Texture>;
  27289. private _generateMipMaps;
  27290. private _engine;
  27291. private _stillImageCaptured;
  27292. private _displayingPosterTexture;
  27293. private _settings;
  27294. private _createInternalTextureOnEvent;
  27295. /**
  27296. * Creates a video texture.
  27297. * If you want to display a video in your scene, this is the special texture for that.
  27298. * This special texture works similar to other textures, with the exception of a few parameters.
  27299. * @see https://doc.babylonjs.com/how_to/video_texture
  27300. * @param name optional name, will detect from video source, if not defined
  27301. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  27302. * @param scene is obviously the current scene.
  27303. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  27304. * @param invertY is false by default but can be used to invert video on Y axis
  27305. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  27306. * @param settings allows finer control over video usage
  27307. */
  27308. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  27309. private _getName;
  27310. private _getVideo;
  27311. private _createInternalTexture;
  27312. private reset;
  27313. /**
  27314. * @hidden Internal method to initiate `update`.
  27315. */
  27316. _rebuild(): void;
  27317. /**
  27318. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  27319. */
  27320. update(): void;
  27321. /**
  27322. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  27323. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  27324. */
  27325. updateTexture(isVisible: boolean): void;
  27326. protected _updateInternalTexture: () => void;
  27327. /**
  27328. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  27329. * @param url New url.
  27330. */
  27331. updateURL(url: string): void;
  27332. /**
  27333. * Dispose the texture and release its associated resources.
  27334. */
  27335. dispose(): void;
  27336. /**
  27337. * Creates a video texture straight from a stream.
  27338. * @param scene Define the scene the texture should be created in
  27339. * @param stream Define the stream the texture should be created from
  27340. * @returns The created video texture as a promise
  27341. */
  27342. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  27343. /**
  27344. * Creates a video texture straight from your WebCam video feed.
  27345. * @param scene Define the scene the texture should be created in
  27346. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  27347. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  27348. * @returns The created video texture as a promise
  27349. */
  27350. static CreateFromWebCamAsync(scene: Scene, constraints: {
  27351. minWidth: number;
  27352. maxWidth: number;
  27353. minHeight: number;
  27354. maxHeight: number;
  27355. deviceId: string;
  27356. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  27357. /**
  27358. * Creates a video texture straight from your WebCam video feed.
  27359. * @param scene Define the scene the texture should be created in
  27360. * @param onReady Define a callback to triggered once the texture will be ready
  27361. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  27362. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  27363. */
  27364. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  27365. minWidth: number;
  27366. maxWidth: number;
  27367. minHeight: number;
  27368. maxHeight: number;
  27369. deviceId: string;
  27370. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  27371. }
  27372. }
  27373. declare module "babylonjs/Engines/engine" {
  27374. import { Observable } from "babylonjs/Misc/observable";
  27375. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  27376. import { ICustomAnimationFrameRequester, PerfCounter, IFileRequest } from "babylonjs/Misc/tools";
  27377. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  27378. import { Camera } from "babylonjs/Cameras/camera";
  27379. import { Scene } from "babylonjs/scene";
  27380. import { Matrix, Color3, Color4, Viewport } from "babylonjs/Maths/math";
  27381. import { IDisplayChangedEventArgs } from "babylonjs/Engines/engine";
  27382. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  27383. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  27384. import { Effect, EffectCreationOptions, EffectFallbacks } from "babylonjs/Materials/effect";
  27385. import { Material } from "babylonjs/Materials/material";
  27386. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  27387. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  27388. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  27389. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  27390. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  27391. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  27392. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  27393. import { _DepthCullingState, _StencilState, _AlphaState } from "babylonjs/States/index";
  27394. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  27395. import { WebRequest } from "babylonjs/Misc/webRequest";
  27396. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  27397. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  27398. /**
  27399. * Interface for attribute information associated with buffer instanciation
  27400. */
  27401. export class InstancingAttributeInfo {
  27402. /**
  27403. * Index/offset of the attribute in the vertex shader
  27404. */
  27405. index: number;
  27406. /**
  27407. * size of the attribute, 1, 2, 3 or 4
  27408. */
  27409. attributeSize: number;
  27410. /**
  27411. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  27412. * default is FLOAT
  27413. */
  27414. attribyteType: number;
  27415. /**
  27416. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  27417. */
  27418. normalized: boolean;
  27419. /**
  27420. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  27421. */
  27422. offset: number;
  27423. /**
  27424. * Name of the GLSL attribute, for debugging purpose only
  27425. */
  27426. attributeName: string;
  27427. }
  27428. /**
  27429. * Define options used to create a depth texture
  27430. */
  27431. export class DepthTextureCreationOptions {
  27432. /** Specifies whether or not a stencil should be allocated in the texture */
  27433. generateStencil?: boolean;
  27434. /** Specifies whether or not bilinear filtering is enable on the texture */
  27435. bilinearFiltering?: boolean;
  27436. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  27437. comparisonFunction?: number;
  27438. /** Specifies if the created texture is a cube texture */
  27439. isCube?: boolean;
  27440. }
  27441. /**
  27442. * Class used to describe the capabilities of the engine relatively to the current browser
  27443. */
  27444. export class EngineCapabilities {
  27445. /** Maximum textures units per fragment shader */
  27446. maxTexturesImageUnits: number;
  27447. /** Maximum texture units per vertex shader */
  27448. maxVertexTextureImageUnits: number;
  27449. /** Maximum textures units in the entire pipeline */
  27450. maxCombinedTexturesImageUnits: number;
  27451. /** Maximum texture size */
  27452. maxTextureSize: number;
  27453. /** Maximum cube texture size */
  27454. maxCubemapTextureSize: number;
  27455. /** Maximum render texture size */
  27456. maxRenderTextureSize: number;
  27457. /** Maximum number of vertex attributes */
  27458. maxVertexAttribs: number;
  27459. /** Maximum number of varyings */
  27460. maxVaryingVectors: number;
  27461. /** Maximum number of uniforms per vertex shader */
  27462. maxVertexUniformVectors: number;
  27463. /** Maximum number of uniforms per fragment shader */
  27464. maxFragmentUniformVectors: number;
  27465. /** Defines if standard derivates (dx/dy) are supported */
  27466. standardDerivatives: boolean;
  27467. /** Defines if s3tc texture compression is supported */
  27468. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  27469. /** Defines if pvrtc texture compression is supported */
  27470. pvrtc: any;
  27471. /** Defines if etc1 texture compression is supported */
  27472. etc1: any;
  27473. /** Defines if etc2 texture compression is supported */
  27474. etc2: any;
  27475. /** Defines if astc texture compression is supported */
  27476. astc: any;
  27477. /** Defines if float textures are supported */
  27478. textureFloat: boolean;
  27479. /** Defines if vertex array objects are supported */
  27480. vertexArrayObject: boolean;
  27481. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  27482. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  27483. /** Gets the maximum level of anisotropy supported */
  27484. maxAnisotropy: number;
  27485. /** Defines if instancing is supported */
  27486. instancedArrays: boolean;
  27487. /** Defines if 32 bits indices are supported */
  27488. uintIndices: boolean;
  27489. /** Defines if high precision shaders are supported */
  27490. highPrecisionShaderSupported: boolean;
  27491. /** Defines if depth reading in the fragment shader is supported */
  27492. fragmentDepthSupported: boolean;
  27493. /** Defines if float texture linear filtering is supported*/
  27494. textureFloatLinearFiltering: boolean;
  27495. /** Defines if rendering to float textures is supported */
  27496. textureFloatRender: boolean;
  27497. /** Defines if half float textures are supported*/
  27498. textureHalfFloat: boolean;
  27499. /** Defines if half float texture linear filtering is supported*/
  27500. textureHalfFloatLinearFiltering: boolean;
  27501. /** Defines if rendering to half float textures is supported */
  27502. textureHalfFloatRender: boolean;
  27503. /** Defines if textureLOD shader command is supported */
  27504. textureLOD: boolean;
  27505. /** Defines if draw buffers extension is supported */
  27506. drawBuffersExtension: boolean;
  27507. /** Defines if depth textures are supported */
  27508. depthTextureExtension: boolean;
  27509. /** Defines if float color buffer are supported */
  27510. colorBufferFloat: boolean;
  27511. /** Gets disjoint timer query extension (null if not supported) */
  27512. timerQuery: EXT_disjoint_timer_query;
  27513. /** Defines if timestamp can be used with timer query */
  27514. canUseTimestampForTimerQuery: boolean;
  27515. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  27516. multiview: any;
  27517. /** Function used to let the system compiles shaders in background */
  27518. parallelShaderCompile: {
  27519. COMPLETION_STATUS_KHR: number;
  27520. };
  27521. }
  27522. /** Interface defining initialization parameters for Engine class */
  27523. export interface EngineOptions extends WebGLContextAttributes {
  27524. /**
  27525. * Defines if the engine should no exceed a specified device ratio
  27526. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  27527. */
  27528. limitDeviceRatio?: number;
  27529. /**
  27530. * Defines if webvr should be enabled automatically
  27531. * @see http://doc.babylonjs.com/how_to/webvr_camera
  27532. */
  27533. autoEnableWebVR?: boolean;
  27534. /**
  27535. * Defines if webgl2 should be turned off even if supported
  27536. * @see http://doc.babylonjs.com/features/webgl2
  27537. */
  27538. disableWebGL2Support?: boolean;
  27539. /**
  27540. * Defines if webaudio should be initialized as well
  27541. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27542. */
  27543. audioEngine?: boolean;
  27544. /**
  27545. * Defines if animations should run using a deterministic lock step
  27546. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  27547. */
  27548. deterministicLockstep?: boolean;
  27549. /** Defines the maximum steps to use with deterministic lock step mode */
  27550. lockstepMaxSteps?: number;
  27551. /**
  27552. * Defines that engine should ignore context lost events
  27553. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  27554. */
  27555. doNotHandleContextLost?: boolean;
  27556. /**
  27557. * Defines that engine should ignore modifying touch action attribute and style
  27558. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  27559. */
  27560. doNotHandleTouchAction?: boolean;
  27561. /**
  27562. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  27563. */
  27564. useHighPrecisionFloats?: boolean;
  27565. }
  27566. /**
  27567. * Defines the interface used by display changed events
  27568. */
  27569. export interface IDisplayChangedEventArgs {
  27570. /** Gets the vrDisplay object (if any) */
  27571. vrDisplay: Nullable<any>;
  27572. /** Gets a boolean indicating if webVR is supported */
  27573. vrSupported: boolean;
  27574. }
  27575. /**
  27576. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  27577. */
  27578. export class Engine {
  27579. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  27580. static ExceptionList: ({
  27581. key: string;
  27582. capture: string;
  27583. captureConstraint: number;
  27584. targets: string[];
  27585. } | {
  27586. key: string;
  27587. capture: null;
  27588. captureConstraint: null;
  27589. targets: string[];
  27590. })[];
  27591. /** Gets the list of created engines */
  27592. static readonly Instances: Engine[];
  27593. /**
  27594. * Gets the latest created engine
  27595. */
  27596. static readonly LastCreatedEngine: Nullable<Engine>;
  27597. /**
  27598. * Gets the latest created scene
  27599. */
  27600. static readonly LastCreatedScene: Nullable<Scene>;
  27601. /**
  27602. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  27603. * @param flag defines which part of the materials must be marked as dirty
  27604. * @param predicate defines a predicate used to filter which materials should be affected
  27605. */
  27606. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  27607. /**
  27608. * Hidden
  27609. */
  27610. static _TextureLoaders: IInternalTextureLoader[];
  27611. /** Defines that alpha blending is disabled */
  27612. static readonly ALPHA_DISABLE: number;
  27613. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  27614. static readonly ALPHA_ADD: number;
  27615. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  27616. static readonly ALPHA_COMBINE: number;
  27617. /** Defines that alpha blending to DEST - SRC * DEST */
  27618. static readonly ALPHA_SUBTRACT: number;
  27619. /** Defines that alpha blending to SRC * DEST */
  27620. static readonly ALPHA_MULTIPLY: number;
  27621. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  27622. static readonly ALPHA_MAXIMIZED: number;
  27623. /** Defines that alpha blending to SRC + DEST */
  27624. static readonly ALPHA_ONEONE: number;
  27625. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  27626. static readonly ALPHA_PREMULTIPLIED: number;
  27627. /**
  27628. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  27629. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  27630. */
  27631. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  27632. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  27633. static readonly ALPHA_INTERPOLATE: number;
  27634. /**
  27635. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  27636. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  27637. */
  27638. static readonly ALPHA_SCREENMODE: number;
  27639. /** Defines that the ressource is not delayed*/
  27640. static readonly DELAYLOADSTATE_NONE: number;
  27641. /** Defines that the ressource was successfully delay loaded */
  27642. static readonly DELAYLOADSTATE_LOADED: number;
  27643. /** Defines that the ressource is currently delay loading */
  27644. static readonly DELAYLOADSTATE_LOADING: number;
  27645. /** Defines that the ressource is delayed and has not started loading */
  27646. static readonly DELAYLOADSTATE_NOTLOADED: number;
  27647. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  27648. static readonly NEVER: number;
  27649. /** 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 */
  27650. static readonly ALWAYS: number;
  27651. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  27652. static readonly LESS: number;
  27653. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  27654. static readonly EQUAL: number;
  27655. /** 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 */
  27656. static readonly LEQUAL: number;
  27657. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  27658. static readonly GREATER: number;
  27659. /** 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 */
  27660. static readonly GEQUAL: number;
  27661. /** 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 */
  27662. static readonly NOTEQUAL: number;
  27663. /** Passed to stencilOperation to specify that stencil value must be kept */
  27664. static readonly KEEP: number;
  27665. /** Passed to stencilOperation to specify that stencil value must be replaced */
  27666. static readonly REPLACE: number;
  27667. /** Passed to stencilOperation to specify that stencil value must be incremented */
  27668. static readonly INCR: number;
  27669. /** Passed to stencilOperation to specify that stencil value must be decremented */
  27670. static readonly DECR: number;
  27671. /** Passed to stencilOperation to specify that stencil value must be inverted */
  27672. static readonly INVERT: number;
  27673. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  27674. static readonly INCR_WRAP: number;
  27675. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  27676. static readonly DECR_WRAP: number;
  27677. /** Texture is not repeating outside of 0..1 UVs */
  27678. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  27679. /** Texture is repeating outside of 0..1 UVs */
  27680. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  27681. /** Texture is repeating and mirrored */
  27682. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  27683. /** ALPHA */
  27684. static readonly TEXTUREFORMAT_ALPHA: number;
  27685. /** LUMINANCE */
  27686. static readonly TEXTUREFORMAT_LUMINANCE: number;
  27687. /** LUMINANCE_ALPHA */
  27688. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  27689. /** RGB */
  27690. static readonly TEXTUREFORMAT_RGB: number;
  27691. /** RGBA */
  27692. static readonly TEXTUREFORMAT_RGBA: number;
  27693. /** RED */
  27694. static readonly TEXTUREFORMAT_RED: number;
  27695. /** RED (2nd reference) */
  27696. static readonly TEXTUREFORMAT_R: number;
  27697. /** RG */
  27698. static readonly TEXTUREFORMAT_RG: number;
  27699. /** RED_INTEGER */
  27700. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  27701. /** RED_INTEGER (2nd reference) */
  27702. static readonly TEXTUREFORMAT_R_INTEGER: number;
  27703. /** RG_INTEGER */
  27704. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  27705. /** RGB_INTEGER */
  27706. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  27707. /** RGBA_INTEGER */
  27708. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  27709. /** UNSIGNED_BYTE */
  27710. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  27711. /** UNSIGNED_BYTE (2nd reference) */
  27712. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  27713. /** FLOAT */
  27714. static readonly TEXTURETYPE_FLOAT: number;
  27715. /** HALF_FLOAT */
  27716. static readonly TEXTURETYPE_HALF_FLOAT: number;
  27717. /** BYTE */
  27718. static readonly TEXTURETYPE_BYTE: number;
  27719. /** SHORT */
  27720. static readonly TEXTURETYPE_SHORT: number;
  27721. /** UNSIGNED_SHORT */
  27722. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  27723. /** INT */
  27724. static readonly TEXTURETYPE_INT: number;
  27725. /** UNSIGNED_INT */
  27726. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  27727. /** UNSIGNED_SHORT_4_4_4_4 */
  27728. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  27729. /** UNSIGNED_SHORT_5_5_5_1 */
  27730. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  27731. /** UNSIGNED_SHORT_5_6_5 */
  27732. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  27733. /** UNSIGNED_INT_2_10_10_10_REV */
  27734. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  27735. /** UNSIGNED_INT_24_8 */
  27736. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  27737. /** UNSIGNED_INT_10F_11F_11F_REV */
  27738. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  27739. /** UNSIGNED_INT_5_9_9_9_REV */
  27740. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  27741. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  27742. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  27743. /** nearest is mag = nearest and min = nearest and mip = linear */
  27744. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  27745. /** Bilinear is mag = linear and min = linear and mip = nearest */
  27746. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  27747. /** Trilinear is mag = linear and min = linear and mip = linear */
  27748. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  27749. /** nearest is mag = nearest and min = nearest and mip = linear */
  27750. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  27751. /** Bilinear is mag = linear and min = linear and mip = nearest */
  27752. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  27753. /** Trilinear is mag = linear and min = linear and mip = linear */
  27754. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  27755. /** mag = nearest and min = nearest and mip = nearest */
  27756. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  27757. /** mag = nearest and min = linear and mip = nearest */
  27758. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  27759. /** mag = nearest and min = linear and mip = linear */
  27760. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  27761. /** mag = nearest and min = linear and mip = none */
  27762. static readonly TEXTURE_NEAREST_LINEAR: number;
  27763. /** mag = nearest and min = nearest and mip = none */
  27764. static readonly TEXTURE_NEAREST_NEAREST: number;
  27765. /** mag = linear and min = nearest and mip = nearest */
  27766. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  27767. /** mag = linear and min = nearest and mip = linear */
  27768. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  27769. /** mag = linear and min = linear and mip = none */
  27770. static readonly TEXTURE_LINEAR_LINEAR: number;
  27771. /** mag = linear and min = nearest and mip = none */
  27772. static readonly TEXTURE_LINEAR_NEAREST: number;
  27773. /** Explicit coordinates mode */
  27774. static readonly TEXTURE_EXPLICIT_MODE: number;
  27775. /** Spherical coordinates mode */
  27776. static readonly TEXTURE_SPHERICAL_MODE: number;
  27777. /** Planar coordinates mode */
  27778. static readonly TEXTURE_PLANAR_MODE: number;
  27779. /** Cubic coordinates mode */
  27780. static readonly TEXTURE_CUBIC_MODE: number;
  27781. /** Projection coordinates mode */
  27782. static readonly TEXTURE_PROJECTION_MODE: number;
  27783. /** Skybox coordinates mode */
  27784. static readonly TEXTURE_SKYBOX_MODE: number;
  27785. /** Inverse Cubic coordinates mode */
  27786. static readonly TEXTURE_INVCUBIC_MODE: number;
  27787. /** Equirectangular coordinates mode */
  27788. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  27789. /** Equirectangular Fixed coordinates mode */
  27790. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  27791. /** Equirectangular Fixed Mirrored coordinates mode */
  27792. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  27793. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  27794. static readonly SCALEMODE_FLOOR: number;
  27795. /** Defines that texture rescaling will look for the nearest power of 2 size */
  27796. static readonly SCALEMODE_NEAREST: number;
  27797. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  27798. static readonly SCALEMODE_CEILING: number;
  27799. /**
  27800. * Returns the current npm package of the sdk
  27801. */
  27802. static readonly NpmPackage: string;
  27803. /**
  27804. * Returns the current version of the framework
  27805. */
  27806. static readonly Version: string;
  27807. /**
  27808. * Returns a string describing the current engine
  27809. */
  27810. readonly description: string;
  27811. /**
  27812. * Gets or sets the epsilon value used by collision engine
  27813. */
  27814. static CollisionsEpsilon: number;
  27815. /**
  27816. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  27817. */
  27818. static ShadersRepository: string;
  27819. /**
  27820. * Method called to create the default loading screen.
  27821. * This can be overriden in your own app.
  27822. * @param canvas The rendering canvas element
  27823. * @returns The loading screen
  27824. */
  27825. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  27826. /**
  27827. * Method called to create the default rescale post process on each engine.
  27828. */
  27829. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  27830. /**
  27831. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  27832. */
  27833. forcePOTTextures: boolean;
  27834. /**
  27835. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  27836. */
  27837. isFullscreen: boolean;
  27838. /**
  27839. * Gets a boolean indicating if the pointer is currently locked
  27840. */
  27841. isPointerLock: boolean;
  27842. /**
  27843. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  27844. */
  27845. cullBackFaces: boolean;
  27846. /**
  27847. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  27848. */
  27849. renderEvenInBackground: boolean;
  27850. /**
  27851. * Gets or sets a boolean indicating that cache can be kept between frames
  27852. */
  27853. preventCacheWipeBetweenFrames: boolean;
  27854. /**
  27855. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  27856. **/
  27857. enableOfflineSupport: boolean;
  27858. /**
  27859. * 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)
  27860. **/
  27861. disableManifestCheck: boolean;
  27862. /**
  27863. * Gets the list of created scenes
  27864. */
  27865. scenes: Scene[];
  27866. /**
  27867. * Event raised when a new scene is created
  27868. */
  27869. onNewSceneAddedObservable: Observable<Scene>;
  27870. /**
  27871. * Gets the list of created postprocesses
  27872. */
  27873. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  27874. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  27875. validateShaderPrograms: boolean;
  27876. /**
  27877. * Observable event triggered each time the rendering canvas is resized
  27878. */
  27879. onResizeObservable: Observable<Engine>;
  27880. /**
  27881. * Observable event triggered each time the canvas loses focus
  27882. */
  27883. onCanvasBlurObservable: Observable<Engine>;
  27884. /**
  27885. * Observable event triggered each time the canvas gains focus
  27886. */
  27887. onCanvasFocusObservable: Observable<Engine>;
  27888. /**
  27889. * Observable event triggered each time the canvas receives pointerout event
  27890. */
  27891. onCanvasPointerOutObservable: Observable<PointerEvent>;
  27892. /**
  27893. * Observable event triggered before each texture is initialized
  27894. */
  27895. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  27896. private _vrDisplay;
  27897. private _vrSupported;
  27898. private _oldSize;
  27899. private _oldHardwareScaleFactor;
  27900. private _vrExclusivePointerMode;
  27901. private _webVRInitPromise;
  27902. /**
  27903. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  27904. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  27905. */
  27906. readonly isInVRExclusivePointerMode: boolean;
  27907. /**
  27908. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  27909. */
  27910. disableUniformBuffers: boolean;
  27911. /** @hidden */
  27912. _uniformBuffers: UniformBuffer[];
  27913. /**
  27914. * Gets a boolean indicating that the engine supports uniform buffers
  27915. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  27916. */
  27917. readonly supportsUniformBuffers: boolean;
  27918. /**
  27919. * Observable raised when the engine begins a new frame
  27920. */
  27921. onBeginFrameObservable: Observable<Engine>;
  27922. /**
  27923. * If set, will be used to request the next animation frame for the render loop
  27924. */
  27925. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  27926. /**
  27927. * Observable raised when the engine ends the current frame
  27928. */
  27929. onEndFrameObservable: Observable<Engine>;
  27930. /**
  27931. * Observable raised when the engine is about to compile a shader
  27932. */
  27933. onBeforeShaderCompilationObservable: Observable<Engine>;
  27934. /**
  27935. * Observable raised when the engine has jsut compiled a shader
  27936. */
  27937. onAfterShaderCompilationObservable: Observable<Engine>;
  27938. /** @hidden */
  27939. _gl: WebGLRenderingContext;
  27940. private _renderingCanvas;
  27941. private _windowIsBackground;
  27942. private _webGLVersion;
  27943. protected _highPrecisionShadersAllowed: boolean;
  27944. /** @hidden */
  27945. readonly _shouldUseHighPrecisionShader: boolean;
  27946. /**
  27947. * Gets a boolean indicating that only power of 2 textures are supported
  27948. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  27949. */
  27950. readonly needPOTTextures: boolean;
  27951. /** @hidden */
  27952. _badOS: boolean;
  27953. /** @hidden */
  27954. _badDesktopOS: boolean;
  27955. /**
  27956. * Gets the audio engine
  27957. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27958. * @ignorenaming
  27959. */
  27960. static audioEngine: IAudioEngine;
  27961. /**
  27962. * Default AudioEngine factory responsible of creating the Audio Engine.
  27963. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  27964. */
  27965. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  27966. /**
  27967. * Default offline support factory responsible of creating a tool used to store data locally.
  27968. * By default, this will create a Database object if the workload has been embedded.
  27969. */
  27970. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  27971. private _onFocus;
  27972. private _onBlur;
  27973. private _onCanvasPointerOut;
  27974. private _onCanvasBlur;
  27975. private _onCanvasFocus;
  27976. private _onFullscreenChange;
  27977. private _onPointerLockChange;
  27978. private _onVRDisplayPointerRestricted;
  27979. private _onVRDisplayPointerUnrestricted;
  27980. private _onVrDisplayConnect;
  27981. private _onVrDisplayDisconnect;
  27982. private _onVrDisplayPresentChange;
  27983. /**
  27984. * Observable signaled when VR display mode changes
  27985. */
  27986. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  27987. /**
  27988. * Observable signaled when VR request present is complete
  27989. */
  27990. onVRRequestPresentComplete: Observable<boolean>;
  27991. /**
  27992. * Observable signaled when VR request present starts
  27993. */
  27994. onVRRequestPresentStart: Observable<Engine>;
  27995. private _hardwareScalingLevel;
  27996. /** @hidden */
  27997. protected _caps: EngineCapabilities;
  27998. private _pointerLockRequested;
  27999. private _isStencilEnable;
  28000. private _colorWrite;
  28001. private _loadingScreen;
  28002. /** @hidden */
  28003. _drawCalls: PerfCounter;
  28004. private _glVersion;
  28005. private _glRenderer;
  28006. private _glVendor;
  28007. private _videoTextureSupported;
  28008. private _renderingQueueLaunched;
  28009. private _activeRenderLoops;
  28010. private _deterministicLockstep;
  28011. private _lockstepMaxSteps;
  28012. /**
  28013. * Observable signaled when a context lost event is raised
  28014. */
  28015. onContextLostObservable: Observable<Engine>;
  28016. /**
  28017. * Observable signaled when a context restored event is raised
  28018. */
  28019. onContextRestoredObservable: Observable<Engine>;
  28020. private _onContextLost;
  28021. private _onContextRestored;
  28022. private _contextWasLost;
  28023. private _doNotHandleContextLost;
  28024. /**
  28025. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  28026. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  28027. */
  28028. doNotHandleContextLost: boolean;
  28029. private _performanceMonitor;
  28030. private _fps;
  28031. private _deltaTime;
  28032. /**
  28033. * Turn this value on if you want to pause FPS computation when in background
  28034. */
  28035. disablePerformanceMonitorInBackground: boolean;
  28036. /**
  28037. * Gets the performance monitor attached to this engine
  28038. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  28039. */
  28040. readonly performanceMonitor: PerformanceMonitor;
  28041. /**
  28042. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  28043. */
  28044. disableVertexArrayObjects: boolean;
  28045. /** @hidden */
  28046. protected _depthCullingState: _DepthCullingState;
  28047. /** @hidden */
  28048. protected _stencilState: _StencilState;
  28049. /** @hidden */
  28050. protected _alphaState: _AlphaState;
  28051. /** @hidden */
  28052. protected _alphaMode: number;
  28053. protected _internalTexturesCache: InternalTexture[];
  28054. /** @hidden */
  28055. protected _activeChannel: number;
  28056. private _currentTextureChannel;
  28057. /** @hidden */
  28058. protected _boundTexturesCache: {
  28059. [key: string]: Nullable<InternalTexture>;
  28060. };
  28061. /** @hidden */
  28062. protected _currentEffect: Nullable<Effect>;
  28063. /** @hidden */
  28064. protected _currentProgram: Nullable<WebGLProgram>;
  28065. private _compiledEffects;
  28066. private _vertexAttribArraysEnabled;
  28067. /** @hidden */
  28068. protected _cachedViewport: Nullable<Viewport>;
  28069. private _cachedVertexArrayObject;
  28070. /** @hidden */
  28071. protected _cachedVertexBuffers: any;
  28072. /** @hidden */
  28073. protected _cachedIndexBuffer: Nullable<WebGLBuffer>;
  28074. /** @hidden */
  28075. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  28076. /** @hidden */
  28077. protected _currentRenderTarget: Nullable<InternalTexture>;
  28078. private _uintIndicesCurrentlySet;
  28079. private _currentBoundBuffer;
  28080. /** @hidden */
  28081. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  28082. private _currentBufferPointers;
  28083. private _currentInstanceLocations;
  28084. private _currentInstanceBuffers;
  28085. private _textureUnits;
  28086. private _workingCanvas;
  28087. private _workingContext;
  28088. private _rescalePostProcess;
  28089. private _dummyFramebuffer;
  28090. private _externalData;
  28091. private _bindedRenderFunction;
  28092. private _vaoRecordInProgress;
  28093. private _mustWipeVertexAttributes;
  28094. private _emptyTexture;
  28095. private _emptyCubeTexture;
  28096. private _emptyTexture3D;
  28097. /** @hidden */
  28098. _frameHandler: number;
  28099. private _nextFreeTextureSlots;
  28100. private _maxSimultaneousTextures;
  28101. private _activeRequests;
  28102. private _texturesSupported;
  28103. private _textureFormatInUse;
  28104. /**
  28105. * Gets the list of texture formats supported
  28106. */
  28107. readonly texturesSupported: Array<string>;
  28108. /**
  28109. * Gets the list of texture formats in use
  28110. */
  28111. readonly textureFormatInUse: Nullable<string>;
  28112. /**
  28113. * Gets the current viewport
  28114. */
  28115. readonly currentViewport: Nullable<Viewport>;
  28116. /**
  28117. * Gets the default empty texture
  28118. */
  28119. readonly emptyTexture: InternalTexture;
  28120. /**
  28121. * Gets the default empty 3D texture
  28122. */
  28123. readonly emptyTexture3D: InternalTexture;
  28124. /**
  28125. * Gets the default empty cube texture
  28126. */
  28127. readonly emptyCubeTexture: InternalTexture;
  28128. /**
  28129. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  28130. */
  28131. readonly premultipliedAlpha: boolean;
  28132. /**
  28133. * Creates a new engine
  28134. * @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
  28135. * @param antialias defines enable antialiasing (default: false)
  28136. * @param options defines further options to be sent to the getContext() function
  28137. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  28138. */
  28139. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  28140. private _disableTouchAction;
  28141. private _rebuildInternalTextures;
  28142. private _rebuildEffects;
  28143. /**
  28144. * Gets a boolean indicating if all created effects are ready
  28145. * @returns true if all effects are ready
  28146. */
  28147. areAllEffectsReady(): boolean;
  28148. private _rebuildBuffers;
  28149. private _initGLContext;
  28150. /**
  28151. * Gets version of the current webGL context
  28152. */
  28153. readonly webGLVersion: number;
  28154. /**
  28155. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  28156. */
  28157. readonly isStencilEnable: boolean;
  28158. private _prepareWorkingCanvas;
  28159. /**
  28160. * Reset the texture cache to empty state
  28161. */
  28162. resetTextureCache(): void;
  28163. /**
  28164. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  28165. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  28166. * @returns true if engine is in deterministic lock step mode
  28167. */
  28168. isDeterministicLockStep(): boolean;
  28169. /**
  28170. * Gets the max steps when engine is running in deterministic lock step
  28171. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  28172. * @returns the max steps
  28173. */
  28174. getLockstepMaxSteps(): number;
  28175. /**
  28176. * Gets an object containing information about the current webGL context
  28177. * @returns an object containing the vender, the renderer and the version of the current webGL context
  28178. */
  28179. getGlInfo(): {
  28180. vendor: string;
  28181. renderer: string;
  28182. version: string;
  28183. };
  28184. /**
  28185. * Gets current aspect ratio
  28186. * @param camera defines the camera to use to get the aspect ratio
  28187. * @param useScreen defines if screen size must be used (or the current render target if any)
  28188. * @returns a number defining the aspect ratio
  28189. */
  28190. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  28191. /**
  28192. * Gets current screen aspect ratio
  28193. * @returns a number defining the aspect ratio
  28194. */
  28195. getScreenAspectRatio(): number;
  28196. /**
  28197. * Gets the current render width
  28198. * @param useScreen defines if screen size must be used (or the current render target if any)
  28199. * @returns a number defining the current render width
  28200. */
  28201. getRenderWidth(useScreen?: boolean): number;
  28202. /**
  28203. * Gets the current render height
  28204. * @param useScreen defines if screen size must be used (or the current render target if any)
  28205. * @returns a number defining the current render height
  28206. */
  28207. getRenderHeight(useScreen?: boolean): number;
  28208. /**
  28209. * Gets the HTML canvas attached with the current webGL context
  28210. * @returns a HTML canvas
  28211. */
  28212. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  28213. /**
  28214. * Gets the client rect of the HTML canvas attached with the current webGL context
  28215. * @returns a client rectanglee
  28216. */
  28217. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  28218. /**
  28219. * Defines the hardware scaling level.
  28220. * By default the hardware scaling level is computed from the window device ratio.
  28221. * 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.
  28222. * @param level defines the level to use
  28223. */
  28224. setHardwareScalingLevel(level: number): void;
  28225. /**
  28226. * Gets the current hardware scaling level.
  28227. * By default the hardware scaling level is computed from the window device ratio.
  28228. * 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.
  28229. * @returns a number indicating the current hardware scaling level
  28230. */
  28231. getHardwareScalingLevel(): number;
  28232. /**
  28233. * Gets the list of loaded textures
  28234. * @returns an array containing all loaded textures
  28235. */
  28236. getLoadedTexturesCache(): InternalTexture[];
  28237. /**
  28238. * Gets the object containing all engine capabilities
  28239. * @returns the EngineCapabilities object
  28240. */
  28241. getCaps(): EngineCapabilities;
  28242. /**
  28243. * Gets the current depth function
  28244. * @returns a number defining the depth function
  28245. */
  28246. getDepthFunction(): Nullable<number>;
  28247. /**
  28248. * Sets the current depth function
  28249. * @param depthFunc defines the function to use
  28250. */
  28251. setDepthFunction(depthFunc: number): void;
  28252. /**
  28253. * Sets the current depth function to GREATER
  28254. */
  28255. setDepthFunctionToGreater(): void;
  28256. /**
  28257. * Sets the current depth function to GEQUAL
  28258. */
  28259. setDepthFunctionToGreaterOrEqual(): void;
  28260. /**
  28261. * Sets the current depth function to LESS
  28262. */
  28263. setDepthFunctionToLess(): void;
  28264. private _cachedStencilBuffer;
  28265. private _cachedStencilFunction;
  28266. private _cachedStencilMask;
  28267. private _cachedStencilOperationPass;
  28268. private _cachedStencilOperationFail;
  28269. private _cachedStencilOperationDepthFail;
  28270. private _cachedStencilReference;
  28271. /**
  28272. * Caches the the state of the stencil buffer
  28273. */
  28274. cacheStencilState(): void;
  28275. /**
  28276. * Restores the state of the stencil buffer
  28277. */
  28278. restoreStencilState(): void;
  28279. /**
  28280. * Sets the current depth function to LEQUAL
  28281. */
  28282. setDepthFunctionToLessOrEqual(): void;
  28283. /**
  28284. * Gets a boolean indicating if stencil buffer is enabled
  28285. * @returns the current stencil buffer state
  28286. */
  28287. getStencilBuffer(): boolean;
  28288. /**
  28289. * Enable or disable the stencil buffer
  28290. * @param enable defines if the stencil buffer must be enabled or disabled
  28291. */
  28292. setStencilBuffer(enable: boolean): void;
  28293. /**
  28294. * Gets the current stencil mask
  28295. * @returns a number defining the new stencil mask to use
  28296. */
  28297. getStencilMask(): number;
  28298. /**
  28299. * Sets the current stencil mask
  28300. * @param mask defines the new stencil mask to use
  28301. */
  28302. setStencilMask(mask: number): void;
  28303. /**
  28304. * Gets the current stencil function
  28305. * @returns a number defining the stencil function to use
  28306. */
  28307. getStencilFunction(): number;
  28308. /**
  28309. * Gets the current stencil reference value
  28310. * @returns a number defining the stencil reference value to use
  28311. */
  28312. getStencilFunctionReference(): number;
  28313. /**
  28314. * Gets the current stencil mask
  28315. * @returns a number defining the stencil mask to use
  28316. */
  28317. getStencilFunctionMask(): number;
  28318. /**
  28319. * Sets the current stencil function
  28320. * @param stencilFunc defines the new stencil function to use
  28321. */
  28322. setStencilFunction(stencilFunc: number): void;
  28323. /**
  28324. * Sets the current stencil reference
  28325. * @param reference defines the new stencil reference to use
  28326. */
  28327. setStencilFunctionReference(reference: number): void;
  28328. /**
  28329. * Sets the current stencil mask
  28330. * @param mask defines the new stencil mask to use
  28331. */
  28332. setStencilFunctionMask(mask: number): void;
  28333. /**
  28334. * Gets the current stencil operation when stencil fails
  28335. * @returns a number defining stencil operation to use when stencil fails
  28336. */
  28337. getStencilOperationFail(): number;
  28338. /**
  28339. * Gets the current stencil operation when depth fails
  28340. * @returns a number defining stencil operation to use when depth fails
  28341. */
  28342. getStencilOperationDepthFail(): number;
  28343. /**
  28344. * Gets the current stencil operation when stencil passes
  28345. * @returns a number defining stencil operation to use when stencil passes
  28346. */
  28347. getStencilOperationPass(): number;
  28348. /**
  28349. * Sets the stencil operation to use when stencil fails
  28350. * @param operation defines the stencil operation to use when stencil fails
  28351. */
  28352. setStencilOperationFail(operation: number): void;
  28353. /**
  28354. * Sets the stencil operation to use when depth fails
  28355. * @param operation defines the stencil operation to use when depth fails
  28356. */
  28357. setStencilOperationDepthFail(operation: number): void;
  28358. /**
  28359. * Sets the stencil operation to use when stencil passes
  28360. * @param operation defines the stencil operation to use when stencil passes
  28361. */
  28362. setStencilOperationPass(operation: number): void;
  28363. /**
  28364. * Sets a boolean indicating if the dithering state is enabled or disabled
  28365. * @param value defines the dithering state
  28366. */
  28367. setDitheringState(value: boolean): void;
  28368. /**
  28369. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  28370. * @param value defines the rasterizer state
  28371. */
  28372. setRasterizerState(value: boolean): void;
  28373. /**
  28374. * stop executing a render loop function and remove it from the execution array
  28375. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  28376. */
  28377. stopRenderLoop(renderFunction?: () => void): void;
  28378. /** @hidden */
  28379. _renderLoop(): void;
  28380. /**
  28381. * Register and execute a render loop. The engine can have more than one render function
  28382. * @param renderFunction defines the function to continuously execute
  28383. */
  28384. runRenderLoop(renderFunction: () => void): void;
  28385. /**
  28386. * Toggle full screen mode
  28387. * @param requestPointerLock defines if a pointer lock should be requested from the user
  28388. */
  28389. switchFullscreen(requestPointerLock: boolean): void;
  28390. /**
  28391. * Enters full screen mode
  28392. * @param requestPointerLock defines if a pointer lock should be requested from the user
  28393. */
  28394. enterFullscreen(requestPointerLock: boolean): void;
  28395. /**
  28396. * Exits full screen mode
  28397. */
  28398. exitFullscreen(): void;
  28399. /**
  28400. * Clear the current render buffer or the current render target (if any is set up)
  28401. * @param color defines the color to use
  28402. * @param backBuffer defines if the back buffer must be cleared
  28403. * @param depth defines if the depth buffer must be cleared
  28404. * @param stencil defines if the stencil buffer must be cleared
  28405. */
  28406. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  28407. /**
  28408. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  28409. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  28410. * @param y defines the y-coordinate of the corner of the clear rectangle
  28411. * @param width defines the width of the clear rectangle
  28412. * @param height defines the height of the clear rectangle
  28413. * @param clearColor defines the clear color
  28414. */
  28415. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  28416. /**
  28417. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  28418. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  28419. * @param y defines the y-coordinate of the corner of the clear rectangle
  28420. * @param width defines the width of the clear rectangle
  28421. * @param height defines the height of the clear rectangle
  28422. */
  28423. enableScissor(x: number, y: number, width: number, height: number): void;
  28424. /**
  28425. * Disable previously set scissor test rectangle
  28426. */
  28427. disableScissor(): void;
  28428. private _viewportCached;
  28429. /** @hidden */
  28430. _viewport(x: number, y: number, width: number, height: number): void;
  28431. /**
  28432. * Set the WebGL's viewport
  28433. * @param viewport defines the viewport element to be used
  28434. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  28435. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  28436. */
  28437. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  28438. /**
  28439. * Directly set the WebGL Viewport
  28440. * @param x defines the x coordinate of the viewport (in screen space)
  28441. * @param y defines the y coordinate of the viewport (in screen space)
  28442. * @param width defines the width of the viewport (in screen space)
  28443. * @param height defines the height of the viewport (in screen space)
  28444. * @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
  28445. */
  28446. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  28447. /**
  28448. * Begin a new frame
  28449. */
  28450. beginFrame(): void;
  28451. /**
  28452. * Enf the current frame
  28453. */
  28454. endFrame(): void;
  28455. /**
  28456. * Resize the view according to the canvas' size
  28457. */
  28458. resize(): void;
  28459. /**
  28460. * Force a specific size of the canvas
  28461. * @param width defines the new canvas' width
  28462. * @param height defines the new canvas' height
  28463. */
  28464. setSize(width: number, height: number): void;
  28465. /**
  28466. * Gets a boolean indicating if a webVR device was detected
  28467. * @returns true if a webVR device was detected
  28468. */
  28469. isVRDevicePresent(): boolean;
  28470. /**
  28471. * Gets the current webVR device
  28472. * @returns the current webVR device (or null)
  28473. */
  28474. getVRDevice(): any;
  28475. /**
  28476. * Initializes a webVR display and starts listening to display change events
  28477. * The onVRDisplayChangedObservable will be notified upon these changes
  28478. * @returns The onVRDisplayChangedObservable
  28479. */
  28480. initWebVR(): Observable<IDisplayChangedEventArgs>;
  28481. /**
  28482. * Initializes a webVR display and starts listening to display change events
  28483. * The onVRDisplayChangedObservable will be notified upon these changes
  28484. * @returns A promise containing a VRDisplay and if vr is supported
  28485. */
  28486. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  28487. /**
  28488. * Call this function to switch to webVR mode
  28489. * Will do nothing if webVR is not supported or if there is no webVR device
  28490. * @see http://doc.babylonjs.com/how_to/webvr_camera
  28491. */
  28492. enableVR(): void;
  28493. /**
  28494. * Call this function to leave webVR mode
  28495. * Will do nothing if webVR is not supported or if there is no webVR device
  28496. * @see http://doc.babylonjs.com/how_to/webvr_camera
  28497. */
  28498. disableVR(): void;
  28499. private _onVRFullScreenTriggered;
  28500. private _getVRDisplaysAsync;
  28501. /**
  28502. * Binds the frame buffer to the specified texture.
  28503. * @param texture The texture to render to or null for the default canvas
  28504. * @param faceIndex The face of the texture to render to in case of cube texture
  28505. * @param requiredWidth The width of the target to render to
  28506. * @param requiredHeight The height of the target to render to
  28507. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  28508. * @param depthStencilTexture The depth stencil texture to use to render
  28509. * @param lodLevel defines le lod level to bind to the frame buffer
  28510. */
  28511. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  28512. private bindUnboundFramebuffer;
  28513. /**
  28514. * Unbind the current render target texture from the webGL context
  28515. * @param texture defines the render target texture to unbind
  28516. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  28517. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  28518. */
  28519. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  28520. /**
  28521. * Unbind a list of render target textures from the webGL context
  28522. * This is used only when drawBuffer extension or webGL2 are active
  28523. * @param textures defines the render target textures to unbind
  28524. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  28525. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  28526. */
  28527. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  28528. /**
  28529. * Force the mipmap generation for the given render target texture
  28530. * @param texture defines the render target texture to use
  28531. */
  28532. generateMipMapsForCubemap(texture: InternalTexture): void;
  28533. /**
  28534. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  28535. */
  28536. flushFramebuffer(): void;
  28537. /**
  28538. * Unbind the current render target and bind the default framebuffer
  28539. */
  28540. restoreDefaultFramebuffer(): void;
  28541. /**
  28542. * Create an uniform buffer
  28543. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28544. * @param elements defines the content of the uniform buffer
  28545. * @returns the webGL uniform buffer
  28546. */
  28547. createUniformBuffer(elements: FloatArray): WebGLBuffer;
  28548. /**
  28549. * Create a dynamic uniform buffer
  28550. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28551. * @param elements defines the content of the uniform buffer
  28552. * @returns the webGL uniform buffer
  28553. */
  28554. createDynamicUniformBuffer(elements: FloatArray): WebGLBuffer;
  28555. /**
  28556. * Update an existing uniform buffer
  28557. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28558. * @param uniformBuffer defines the target uniform buffer
  28559. * @param elements defines the content to update
  28560. * @param offset defines the offset in the uniform buffer where update should start
  28561. * @param count defines the size of the data to update
  28562. */
  28563. updateUniformBuffer(uniformBuffer: WebGLBuffer, elements: FloatArray, offset?: number, count?: number): void;
  28564. private _resetVertexBufferBinding;
  28565. /**
  28566. * Creates a vertex buffer
  28567. * @param data the data for the vertex buffer
  28568. * @returns the new WebGL static buffer
  28569. */
  28570. createVertexBuffer(data: DataArray): WebGLBuffer;
  28571. /**
  28572. * Creates a dynamic vertex buffer
  28573. * @param data the data for the dynamic vertex buffer
  28574. * @returns the new WebGL dynamic buffer
  28575. */
  28576. createDynamicVertexBuffer(data: DataArray): WebGLBuffer;
  28577. /**
  28578. * Update a dynamic index buffer
  28579. * @param indexBuffer defines the target index buffer
  28580. * @param indices defines the data to update
  28581. * @param offset defines the offset in the target index buffer where update should start
  28582. */
  28583. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  28584. /**
  28585. * Updates a dynamic vertex buffer.
  28586. * @param vertexBuffer the vertex buffer to update
  28587. * @param data the data used to update the vertex buffer
  28588. * @param byteOffset the byte offset of the data
  28589. * @param byteLength the byte length of the data
  28590. */
  28591. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  28592. private _resetIndexBufferBinding;
  28593. /**
  28594. * Creates a new index buffer
  28595. * @param indices defines the content of the index buffer
  28596. * @param updatable defines if the index buffer must be updatable
  28597. * @returns a new webGL buffer
  28598. */
  28599. createIndexBuffer(indices: IndicesArray, updatable?: boolean): WebGLBuffer;
  28600. /**
  28601. * Bind a webGL buffer to the webGL context
  28602. * @param buffer defines the buffer to bind
  28603. */
  28604. bindArrayBuffer(buffer: Nullable<WebGLBuffer>): void;
  28605. /**
  28606. * Bind an uniform buffer to the current webGL context
  28607. * @param buffer defines the buffer to bind
  28608. */
  28609. bindUniformBuffer(buffer: Nullable<WebGLBuffer>): void;
  28610. /**
  28611. * Bind a buffer to the current webGL context at a given location
  28612. * @param buffer defines the buffer to bind
  28613. * @param location defines the index where to bind the buffer
  28614. */
  28615. bindUniformBufferBase(buffer: WebGLBuffer, location: number): void;
  28616. /**
  28617. * Bind a specific block at a given index in a specific shader program
  28618. * @param shaderProgram defines the shader program
  28619. * @param blockName defines the block name
  28620. * @param index defines the index where to bind the block
  28621. */
  28622. bindUniformBlock(shaderProgram: WebGLProgram, blockName: string, index: number): void;
  28623. private bindIndexBuffer;
  28624. private bindBuffer;
  28625. /**
  28626. * update the bound buffer with the given data
  28627. * @param data defines the data to update
  28628. */
  28629. updateArrayBuffer(data: Float32Array): void;
  28630. private _vertexAttribPointer;
  28631. private _bindIndexBufferWithCache;
  28632. private _bindVertexBuffersAttributes;
  28633. /**
  28634. * Records a vertex array object
  28635. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  28636. * @param vertexBuffers defines the list of vertex buffers to store
  28637. * @param indexBuffer defines the index buffer to store
  28638. * @param effect defines the effect to store
  28639. * @returns the new vertex array object
  28640. */
  28641. recordVertexArrayObject(vertexBuffers: {
  28642. [key: string]: VertexBuffer;
  28643. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): WebGLVertexArrayObject;
  28644. /**
  28645. * Bind a specific vertex array object
  28646. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  28647. * @param vertexArrayObject defines the vertex array object to bind
  28648. * @param indexBuffer defines the index buffer to bind
  28649. */
  28650. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<WebGLBuffer>): void;
  28651. /**
  28652. * Bind webGl buffers directly to the webGL context
  28653. * @param vertexBuffer defines the vertex buffer to bind
  28654. * @param indexBuffer defines the index buffer to bind
  28655. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  28656. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  28657. * @param effect defines the effect associated with the vertex buffer
  28658. */
  28659. bindBuffersDirectly(vertexBuffer: WebGLBuffer, indexBuffer: WebGLBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  28660. private _unbindVertexArrayObject;
  28661. /**
  28662. * Bind a list of vertex buffers to the webGL context
  28663. * @param vertexBuffers defines the list of vertex buffers to bind
  28664. * @param indexBuffer defines the index buffer to bind
  28665. * @param effect defines the effect associated with the vertex buffers
  28666. */
  28667. bindBuffers(vertexBuffers: {
  28668. [key: string]: Nullable<VertexBuffer>;
  28669. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): void;
  28670. /**
  28671. * Unbind all instance attributes
  28672. */
  28673. unbindInstanceAttributes(): void;
  28674. /**
  28675. * Release and free the memory of a vertex array object
  28676. * @param vao defines the vertex array object to delete
  28677. */
  28678. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  28679. /** @hidden */
  28680. _releaseBuffer(buffer: WebGLBuffer): boolean;
  28681. /**
  28682. * Creates a webGL buffer to use with instanciation
  28683. * @param capacity defines the size of the buffer
  28684. * @returns the webGL buffer
  28685. */
  28686. createInstancesBuffer(capacity: number): WebGLBuffer;
  28687. /**
  28688. * Delete a webGL buffer used with instanciation
  28689. * @param buffer defines the webGL buffer to delete
  28690. */
  28691. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  28692. /**
  28693. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  28694. * @param instancesBuffer defines the webGL buffer to update and bind
  28695. * @param data defines the data to store in the buffer
  28696. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  28697. */
  28698. updateAndBindInstancesBuffer(instancesBuffer: WebGLBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  28699. /**
  28700. * Apply all cached states (depth, culling, stencil and alpha)
  28701. */
  28702. applyStates(): void;
  28703. /**
  28704. * Send a draw order
  28705. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  28706. * @param indexStart defines the starting index
  28707. * @param indexCount defines the number of index to draw
  28708. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28709. */
  28710. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  28711. /**
  28712. * Draw a list of points
  28713. * @param verticesStart defines the index of first vertex to draw
  28714. * @param verticesCount defines the count of vertices to draw
  28715. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28716. */
  28717. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  28718. /**
  28719. * Draw a list of unindexed primitives
  28720. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  28721. * @param verticesStart defines the index of first vertex to draw
  28722. * @param verticesCount defines the count of vertices to draw
  28723. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28724. */
  28725. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  28726. /**
  28727. * Draw a list of indexed primitives
  28728. * @param fillMode defines the primitive to use
  28729. * @param indexStart defines the starting index
  28730. * @param indexCount defines the number of index to draw
  28731. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28732. */
  28733. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  28734. /**
  28735. * Draw a list of unindexed primitives
  28736. * @param fillMode defines the primitive to use
  28737. * @param verticesStart defines the index of first vertex to draw
  28738. * @param verticesCount defines the count of vertices to draw
  28739. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28740. */
  28741. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  28742. private _drawMode;
  28743. /** @hidden */
  28744. _releaseEffect(effect: Effect): void;
  28745. /** @hidden */
  28746. _deleteProgram(program: WebGLProgram): void;
  28747. /**
  28748. * Create a new effect (used to store vertex/fragment shaders)
  28749. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  28750. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  28751. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  28752. * @param samplers defines an array of string used to represent textures
  28753. * @param defines defines the string containing the defines to use to compile the shaders
  28754. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  28755. * @param onCompiled defines a function to call when the effect creation is successful
  28756. * @param onError defines a function to call when the effect creation has failed
  28757. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  28758. * @returns the new Effect
  28759. */
  28760. createEffect(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | Engine, samplers?: string[], defines?: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, indexParameters?: any): Effect;
  28761. private _compileShader;
  28762. private _compileRawShader;
  28763. /**
  28764. * Directly creates a webGL program
  28765. * @param vertexCode defines the vertex shader code to use
  28766. * @param fragmentCode defines the fragment shader code to use
  28767. * @param context defines the webGL context to use (if not set, the current one will be used)
  28768. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  28769. * @returns the new webGL program
  28770. */
  28771. createRawShaderProgram(vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  28772. /**
  28773. * Creates a webGL program
  28774. * @param vertexCode defines the vertex shader code to use
  28775. * @param fragmentCode defines the fragment shader code to use
  28776. * @param defines defines the string containing the defines to use to compile the shaders
  28777. * @param context defines the webGL context to use (if not set, the current one will be used)
  28778. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  28779. * @returns the new webGL program
  28780. */
  28781. createShaderProgram(vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  28782. private _createShaderProgram;
  28783. private _finalizeProgram;
  28784. /** @hidden */
  28785. _isProgramCompiled(shaderProgram: WebGLProgram): boolean;
  28786. /** @hidden */
  28787. _executeWhenProgramIsCompiled(shaderProgram: WebGLProgram, action: () => void): void;
  28788. /**
  28789. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  28790. * @param shaderProgram defines the webGL program to use
  28791. * @param uniformsNames defines the list of uniform names
  28792. * @returns an array of webGL uniform locations
  28793. */
  28794. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  28795. /**
  28796. * Gets the lsit of active attributes for a given webGL program
  28797. * @param shaderProgram defines the webGL program to use
  28798. * @param attributesNames defines the list of attribute names to get
  28799. * @returns an array of indices indicating the offset of each attribute
  28800. */
  28801. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  28802. /**
  28803. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  28804. * @param effect defines the effect to activate
  28805. */
  28806. enableEffect(effect: Nullable<Effect>): void;
  28807. /**
  28808. * Set the value of an uniform to an array of int32
  28809. * @param uniform defines the webGL uniform location where to store the value
  28810. * @param array defines the array of int32 to store
  28811. */
  28812. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28813. /**
  28814. * Set the value of an uniform to an array of int32 (stored as vec2)
  28815. * @param uniform defines the webGL uniform location where to store the value
  28816. * @param array defines the array of int32 to store
  28817. */
  28818. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28819. /**
  28820. * Set the value of an uniform to an array of int32 (stored as vec3)
  28821. * @param uniform defines the webGL uniform location where to store the value
  28822. * @param array defines the array of int32 to store
  28823. */
  28824. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28825. /**
  28826. * Set the value of an uniform to an array of int32 (stored as vec4)
  28827. * @param uniform defines the webGL uniform location where to store the value
  28828. * @param array defines the array of int32 to store
  28829. */
  28830. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28831. /**
  28832. * Set the value of an uniform to an array of float32
  28833. * @param uniform defines the webGL uniform location where to store the value
  28834. * @param array defines the array of float32 to store
  28835. */
  28836. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28837. /**
  28838. * Set the value of an uniform to an array of float32 (stored as vec2)
  28839. * @param uniform defines the webGL uniform location where to store the value
  28840. * @param array defines the array of float32 to store
  28841. */
  28842. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28843. /**
  28844. * Set the value of an uniform to an array of float32 (stored as vec3)
  28845. * @param uniform defines the webGL uniform location where to store the value
  28846. * @param array defines the array of float32 to store
  28847. */
  28848. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28849. /**
  28850. * Set the value of an uniform to an array of float32 (stored as vec4)
  28851. * @param uniform defines the webGL uniform location where to store the value
  28852. * @param array defines the array of float32 to store
  28853. */
  28854. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28855. /**
  28856. * Set the value of an uniform to an array of number
  28857. * @param uniform defines the webGL uniform location where to store the value
  28858. * @param array defines the array of number to store
  28859. */
  28860. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28861. /**
  28862. * Set the value of an uniform to an array of number (stored as vec2)
  28863. * @param uniform defines the webGL uniform location where to store the value
  28864. * @param array defines the array of number to store
  28865. */
  28866. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28867. /**
  28868. * Set the value of an uniform to an array of number (stored as vec3)
  28869. * @param uniform defines the webGL uniform location where to store the value
  28870. * @param array defines the array of number to store
  28871. */
  28872. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28873. /**
  28874. * Set the value of an uniform to an array of number (stored as vec4)
  28875. * @param uniform defines the webGL uniform location where to store the value
  28876. * @param array defines the array of number to store
  28877. */
  28878. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28879. /**
  28880. * Set the value of an uniform to an array of float32 (stored as matrices)
  28881. * @param uniform defines the webGL uniform location where to store the value
  28882. * @param matrices defines the array of float32 to store
  28883. */
  28884. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  28885. /**
  28886. * Set the value of an uniform to a matrix
  28887. * @param uniform defines the webGL uniform location where to store the value
  28888. * @param matrix defines the matrix to store
  28889. */
  28890. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  28891. /**
  28892. * Set the value of an uniform to a matrix (3x3)
  28893. * @param uniform defines the webGL uniform location where to store the value
  28894. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  28895. */
  28896. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  28897. /**
  28898. * Set the value of an uniform to a matrix (2x2)
  28899. * @param uniform defines the webGL uniform location where to store the value
  28900. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  28901. */
  28902. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  28903. /**
  28904. * Set the value of an uniform to a number (int)
  28905. * @param uniform defines the webGL uniform location where to store the value
  28906. * @param value defines the int number to store
  28907. */
  28908. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  28909. /**
  28910. * Set the value of an uniform to a number (float)
  28911. * @param uniform defines the webGL uniform location where to store the value
  28912. * @param value defines the float number to store
  28913. */
  28914. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  28915. /**
  28916. * Set the value of an uniform to a vec2
  28917. * @param uniform defines the webGL uniform location where to store the value
  28918. * @param x defines the 1st component of the value
  28919. * @param y defines the 2nd component of the value
  28920. */
  28921. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  28922. /**
  28923. * Set the value of an uniform to a vec3
  28924. * @param uniform defines the webGL uniform location where to store the value
  28925. * @param x defines the 1st component of the value
  28926. * @param y defines the 2nd component of the value
  28927. * @param z defines the 3rd component of the value
  28928. */
  28929. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  28930. /**
  28931. * Set the value of an uniform to a boolean
  28932. * @param uniform defines the webGL uniform location where to store the value
  28933. * @param bool defines the boolean to store
  28934. */
  28935. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  28936. /**
  28937. * Set the value of an uniform to a vec4
  28938. * @param uniform defines the webGL uniform location where to store the value
  28939. * @param x defines the 1st component of the value
  28940. * @param y defines the 2nd component of the value
  28941. * @param z defines the 3rd component of the value
  28942. * @param w defines the 4th component of the value
  28943. */
  28944. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  28945. /**
  28946. * Set the value of an uniform to a Color3
  28947. * @param uniform defines the webGL uniform location where to store the value
  28948. * @param color3 defines the color to store
  28949. */
  28950. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  28951. /**
  28952. * Set the value of an uniform to a Color3 and an alpha value
  28953. * @param uniform defines the webGL uniform location where to store the value
  28954. * @param color3 defines the color to store
  28955. * @param alpha defines the alpha component to store
  28956. */
  28957. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  28958. /**
  28959. * Sets a Color4 on a uniform variable
  28960. * @param uniform defines the uniform location
  28961. * @param color4 defines the value to be set
  28962. */
  28963. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  28964. /**
  28965. * Set various states to the webGL context
  28966. * @param culling defines backface culling state
  28967. * @param zOffset defines the value to apply to zOffset (0 by default)
  28968. * @param force defines if states must be applied even if cache is up to date
  28969. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  28970. */
  28971. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  28972. /**
  28973. * Set the z offset to apply to current rendering
  28974. * @param value defines the offset to apply
  28975. */
  28976. setZOffset(value: number): void;
  28977. /**
  28978. * Gets the current value of the zOffset
  28979. * @returns the current zOffset state
  28980. */
  28981. getZOffset(): number;
  28982. /**
  28983. * Enable or disable depth buffering
  28984. * @param enable defines the state to set
  28985. */
  28986. setDepthBuffer(enable: boolean): void;
  28987. /**
  28988. * Gets a boolean indicating if depth writing is enabled
  28989. * @returns the current depth writing state
  28990. */
  28991. getDepthWrite(): boolean;
  28992. /**
  28993. * Enable or disable depth writing
  28994. * @param enable defines the state to set
  28995. */
  28996. setDepthWrite(enable: boolean): void;
  28997. /**
  28998. * Enable or disable color writing
  28999. * @param enable defines the state to set
  29000. */
  29001. setColorWrite(enable: boolean): void;
  29002. /**
  29003. * Gets a boolean indicating if color writing is enabled
  29004. * @returns the current color writing state
  29005. */
  29006. getColorWrite(): boolean;
  29007. /**
  29008. * Sets alpha constants used by some alpha blending modes
  29009. * @param r defines the red component
  29010. * @param g defines the green component
  29011. * @param b defines the blue component
  29012. * @param a defines the alpha component
  29013. */
  29014. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  29015. /**
  29016. * Sets the current alpha mode
  29017. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  29018. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  29019. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  29020. */
  29021. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  29022. /**
  29023. * Gets the current alpha mode
  29024. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  29025. * @returns the current alpha mode
  29026. */
  29027. getAlphaMode(): number;
  29028. /**
  29029. * Clears the list of texture accessible through engine.
  29030. * This can help preventing texture load conflict due to name collision.
  29031. */
  29032. clearInternalTexturesCache(): void;
  29033. /**
  29034. * Force the entire cache to be cleared
  29035. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  29036. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  29037. */
  29038. wipeCaches(bruteForce?: boolean): void;
  29039. /**
  29040. * Set the compressed texture format to use, based on the formats you have, and the formats
  29041. * supported by the hardware / browser.
  29042. *
  29043. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  29044. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  29045. * to API arguments needed to compressed textures. This puts the burden on the container
  29046. * generator to house the arcane code for determining these for current & future formats.
  29047. *
  29048. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  29049. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  29050. *
  29051. * Note: The result of this call is not taken into account when a texture is base64.
  29052. *
  29053. * @param formatsAvailable defines the list of those format families you have created
  29054. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  29055. *
  29056. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  29057. * @returns The extension selected.
  29058. */
  29059. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  29060. private _getSamplingParameters;
  29061. private _partialLoadImg;
  29062. private _cascadeLoadImgs;
  29063. /** @hidden */
  29064. _createTexture(): WebGLTexture;
  29065. /**
  29066. * Usually called from Texture.ts.
  29067. * Passed information to create a WebGLTexture
  29068. * @param urlArg defines a value which contains one of the following:
  29069. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  29070. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  29071. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  29072. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  29073. * @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)
  29074. * @param scene needed for loading to the correct scene
  29075. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  29076. * @param onLoad optional callback to be called upon successful completion
  29077. * @param onError optional callback to be called upon failure
  29078. * @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
  29079. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  29080. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  29081. * @param forcedExtension defines the extension to use to pick the right loader
  29082. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  29083. * @returns a InternalTexture for assignment back into BABYLON.Texture
  29084. */
  29085. 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;
  29086. private _rescaleTexture;
  29087. /**
  29088. * Update a raw texture
  29089. * @param texture defines the texture to update
  29090. * @param data defines the data to store in the texture
  29091. * @param format defines the format of the data
  29092. * @param invertY defines if data must be stored with Y axis inverted
  29093. * @param compression defines the compression used (null by default)
  29094. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  29095. */
  29096. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, type?: number): void;
  29097. /**
  29098. * Creates a raw texture
  29099. * @param data defines the data to store in the texture
  29100. * @param width defines the width of the texture
  29101. * @param height defines the height of the texture
  29102. * @param format defines the format of the data
  29103. * @param generateMipMaps defines if the engine should generate the mip levels
  29104. * @param invertY defines if data must be stored with Y axis inverted
  29105. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  29106. * @param compression defines the compression used (null by default)
  29107. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  29108. * @returns the raw texture inside an InternalTexture
  29109. */
  29110. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  29111. private _unpackFlipYCached;
  29112. /**
  29113. * In case you are sharing the context with other applications, it might
  29114. * be interested to not cache the unpack flip y state to ensure a consistent
  29115. * value would be set.
  29116. */
  29117. enableUnpackFlipYCached: boolean;
  29118. /** @hidden */
  29119. _unpackFlipY(value: boolean): void;
  29120. /** @hidden */
  29121. _getUnpackAlignement(): number;
  29122. /**
  29123. * Creates a dynamic texture
  29124. * @param width defines the width of the texture
  29125. * @param height defines the height of the texture
  29126. * @param generateMipMaps defines if the engine should generate the mip levels
  29127. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  29128. * @returns the dynamic texture inside an InternalTexture
  29129. */
  29130. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  29131. /**
  29132. * Update the sampling mode of a given texture
  29133. * @param samplingMode defines the required sampling mode
  29134. * @param texture defines the texture to update
  29135. */
  29136. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  29137. /**
  29138. * Update the content of a dynamic texture
  29139. * @param texture defines the texture to update
  29140. * @param canvas defines the canvas containing the source
  29141. * @param invertY defines if data must be stored with Y axis inverted
  29142. * @param premulAlpha defines if alpha is stored as premultiplied
  29143. * @param format defines the format of the data
  29144. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  29145. */
  29146. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  29147. /**
  29148. * Update a video texture
  29149. * @param texture defines the texture to update
  29150. * @param video defines the video element to use
  29151. * @param invertY defines if data must be stored with Y axis inverted
  29152. */
  29153. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  29154. /**
  29155. * Updates a depth texture Comparison Mode and Function.
  29156. * If the comparison Function is equal to 0, the mode will be set to none.
  29157. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  29158. * @param texture The texture to set the comparison function for
  29159. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  29160. */
  29161. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  29162. private _setupDepthStencilTexture;
  29163. /**
  29164. * Creates a depth stencil texture.
  29165. * This is only available in WebGL 2 or with the depth texture extension available.
  29166. * @param size The size of face edge in the texture.
  29167. * @param options The options defining the texture.
  29168. * @returns The texture
  29169. */
  29170. createDepthStencilTexture(size: number | {
  29171. width: number;
  29172. height: number;
  29173. }, options: DepthTextureCreationOptions): InternalTexture;
  29174. /**
  29175. * Creates a depth stencil texture.
  29176. * This is only available in WebGL 2 or with the depth texture extension available.
  29177. * @param size The size of face edge in the texture.
  29178. * @param options The options defining the texture.
  29179. * @returns The texture
  29180. */
  29181. private _createDepthStencilTexture;
  29182. /**
  29183. * Creates a depth stencil cube texture.
  29184. * This is only available in WebGL 2.
  29185. * @param size The size of face edge in the cube texture.
  29186. * @param options The options defining the cube texture.
  29187. * @returns The cube texture
  29188. */
  29189. private _createDepthStencilCubeTexture;
  29190. /**
  29191. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  29192. * @param renderTarget The render target to set the frame buffer for
  29193. */
  29194. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  29195. /**
  29196. * Creates a new render target texture
  29197. * @param size defines the size of the texture
  29198. * @param options defines the options used to create the texture
  29199. * @returns a new render target texture stored in an InternalTexture
  29200. */
  29201. createRenderTargetTexture(size: number | {
  29202. width: number;
  29203. height: number;
  29204. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  29205. /**
  29206. * Create a multi render target texture
  29207. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  29208. * @param size defines the size of the texture
  29209. * @param options defines the creation options
  29210. * @returns the cube texture as an InternalTexture
  29211. */
  29212. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  29213. private _setupFramebufferDepthAttachments;
  29214. /**
  29215. * Updates the sample count of a render target texture
  29216. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  29217. * @param texture defines the texture to update
  29218. * @param samples defines the sample count to set
  29219. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  29220. */
  29221. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  29222. /**
  29223. * Update the sample count for a given multiple render target texture
  29224. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  29225. * @param textures defines the textures to update
  29226. * @param samples defines the sample count to set
  29227. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  29228. */
  29229. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  29230. /** @hidden */
  29231. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  29232. /** @hidden */
  29233. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  29234. /** @hidden */
  29235. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  29236. /** @hidden */
  29237. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  29238. /**
  29239. * Creates a new render target cube texture
  29240. * @param size defines the size of the texture
  29241. * @param options defines the options used to create the texture
  29242. * @returns a new render target cube texture stored in an InternalTexture
  29243. */
  29244. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  29245. /**
  29246. * Creates a cube texture
  29247. * @param rootUrl defines the url where the files to load is located
  29248. * @param scene defines the current scene
  29249. * @param files defines the list of files to load (1 per face)
  29250. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  29251. * @param onLoad defines an optional callback raised when the texture is loaded
  29252. * @param onError defines an optional callback raised if there is an issue to load the texture
  29253. * @param format defines the format of the data
  29254. * @param forcedExtension defines the extension to use to pick the right loader
  29255. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  29256. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  29257. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  29258. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  29259. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  29260. * @returns the cube texture as an InternalTexture
  29261. */
  29262. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap?: boolean, onLoad?: Nullable<(data?: any) => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, forcedExtension?: any, createPolynomials?: boolean, lodScale?: number, lodOffset?: number, fallback?: Nullable<InternalTexture>, excludeLoaders?: Array<IInternalTextureLoader>): InternalTexture;
  29263. /**
  29264. * @hidden
  29265. */
  29266. _setCubeMapTextureParams(loadMipmap: boolean): void;
  29267. /**
  29268. * Update a raw cube texture
  29269. * @param texture defines the texture to udpdate
  29270. * @param data defines the data to store
  29271. * @param format defines the data format
  29272. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  29273. * @param invertY defines if data must be stored with Y axis inverted
  29274. * @param compression defines the compression used (null by default)
  29275. * @param level defines which level of the texture to update
  29276. */
  29277. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  29278. /**
  29279. * Creates a new raw cube texture
  29280. * @param data defines the array of data to use to create each face
  29281. * @param size defines the size of the textures
  29282. * @param format defines the format of the data
  29283. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  29284. * @param generateMipMaps defines if the engine should generate the mip levels
  29285. * @param invertY defines if data must be stored with Y axis inverted
  29286. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  29287. * @param compression defines the compression used (null by default)
  29288. * @returns the cube texture as an InternalTexture
  29289. */
  29290. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  29291. /**
  29292. * Creates a new raw cube texture from a specified url
  29293. * @param url defines the url where the data is located
  29294. * @param scene defines the current scene
  29295. * @param size defines the size of the textures
  29296. * @param format defines the format of the data
  29297. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  29298. * @param noMipmap defines if the engine should avoid generating the mip levels
  29299. * @param callback defines a callback used to extract texture data from loaded data
  29300. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  29301. * @param onLoad defines a callback called when texture is loaded
  29302. * @param onError defines a callback called if there is an error
  29303. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  29304. * @param invertY defines if data must be stored with Y axis inverted
  29305. * @returns the cube texture as an InternalTexture
  29306. */
  29307. 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;
  29308. /**
  29309. * Update a raw 3D texture
  29310. * @param texture defines the texture to update
  29311. * @param data defines the data to store
  29312. * @param format defines the data format
  29313. * @param invertY defines if data must be stored with Y axis inverted
  29314. * @param compression defines the used compression (can be null)
  29315. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  29316. */
  29317. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, textureType?: number): void;
  29318. /**
  29319. * Creates a new raw 3D texture
  29320. * @param data defines the data used to create the texture
  29321. * @param width defines the width of the texture
  29322. * @param height defines the height of the texture
  29323. * @param depth defines the depth of the texture
  29324. * @param format defines the format of the texture
  29325. * @param generateMipMaps defines if the engine must generate mip levels
  29326. * @param invertY defines if data must be stored with Y axis inverted
  29327. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  29328. * @param compression defines the compressed used (can be null)
  29329. * @param textureType defines the compressed used (can be null)
  29330. * @returns a new raw 3D texture (stored in an InternalTexture)
  29331. */
  29332. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  29333. private _prepareWebGLTextureContinuation;
  29334. private _prepareWebGLTexture;
  29335. private _convertRGBtoRGBATextureData;
  29336. /** @hidden */
  29337. _releaseFramebufferObjects(texture: InternalTexture): void;
  29338. /** @hidden */
  29339. _releaseTexture(texture: InternalTexture): void;
  29340. private setProgram;
  29341. private _boundUniforms;
  29342. /**
  29343. * Binds an effect to the webGL context
  29344. * @param effect defines the effect to bind
  29345. */
  29346. bindSamplers(effect: Effect): void;
  29347. private _activateCurrentTexture;
  29348. /** @hidden */
  29349. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  29350. /** @hidden */
  29351. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  29352. /**
  29353. * Sets a texture to the webGL context from a postprocess
  29354. * @param channel defines the channel to use
  29355. * @param postProcess defines the source postprocess
  29356. */
  29357. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  29358. /**
  29359. * Binds the output of the passed in post process to the texture channel specified
  29360. * @param channel The channel the texture should be bound to
  29361. * @param postProcess The post process which's output should be bound
  29362. */
  29363. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  29364. /**
  29365. * Unbind all textures from the webGL context
  29366. */
  29367. unbindAllTextures(): void;
  29368. /**
  29369. * Sets a texture to the according uniform.
  29370. * @param channel The texture channel
  29371. * @param uniform The uniform to set
  29372. * @param texture The texture to apply
  29373. */
  29374. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  29375. /**
  29376. * Sets a depth stencil texture from a render target to the according uniform.
  29377. * @param channel The texture channel
  29378. * @param uniform The uniform to set
  29379. * @param texture The render target texture containing the depth stencil texture to apply
  29380. */
  29381. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  29382. private _bindSamplerUniformToChannel;
  29383. private _getTextureWrapMode;
  29384. private _setTexture;
  29385. /**
  29386. * Sets an array of texture to the webGL context
  29387. * @param channel defines the channel where the texture array must be set
  29388. * @param uniform defines the associated uniform location
  29389. * @param textures defines the array of textures to bind
  29390. */
  29391. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  29392. /** @hidden */
  29393. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  29394. private _setTextureParameterFloat;
  29395. private _setTextureParameterInteger;
  29396. /**
  29397. * Reads pixels from the current frame buffer. Please note that this function can be slow
  29398. * @param x defines the x coordinate of the rectangle where pixels must be read
  29399. * @param y defines the y coordinate of the rectangle where pixels must be read
  29400. * @param width defines the width of the rectangle where pixels must be read
  29401. * @param height defines the height of the rectangle where pixels must be read
  29402. * @returns a Uint8Array containing RGBA colors
  29403. */
  29404. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  29405. /**
  29406. * Add an externaly attached data from its key.
  29407. * This method call will fail and return false, if such key already exists.
  29408. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  29409. * @param key the unique key that identifies the data
  29410. * @param data the data object to associate to the key for this Engine instance
  29411. * @return true if no such key were already present and the data was added successfully, false otherwise
  29412. */
  29413. addExternalData<T>(key: string, data: T): boolean;
  29414. /**
  29415. * Get an externaly attached data from its key
  29416. * @param key the unique key that identifies the data
  29417. * @return the associated data, if present (can be null), or undefined if not present
  29418. */
  29419. getExternalData<T>(key: string): T;
  29420. /**
  29421. * Get an externaly attached data from its key, create it using a factory if it's not already present
  29422. * @param key the unique key that identifies the data
  29423. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  29424. * @return the associated data, can be null if the factory returned null.
  29425. */
  29426. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  29427. /**
  29428. * Remove an externaly attached data from the Engine instance
  29429. * @param key the unique key that identifies the data
  29430. * @return true if the data was successfully removed, false if it doesn't exist
  29431. */
  29432. removeExternalData(key: string): boolean;
  29433. /**
  29434. * Unbind all vertex attributes from the webGL context
  29435. */
  29436. unbindAllAttributes(): void;
  29437. /**
  29438. * 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
  29439. */
  29440. releaseEffects(): void;
  29441. /**
  29442. * Dispose and release all associated resources
  29443. */
  29444. dispose(): void;
  29445. /**
  29446. * Display the loading screen
  29447. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29448. */
  29449. displayLoadingUI(): void;
  29450. /**
  29451. * Hide the loading screen
  29452. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29453. */
  29454. hideLoadingUI(): void;
  29455. /**
  29456. * Gets the current loading screen object
  29457. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29458. */
  29459. /**
  29460. * Sets the current loading screen object
  29461. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29462. */
  29463. loadingScreen: ILoadingScreen;
  29464. /**
  29465. * Sets the current loading screen text
  29466. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29467. */
  29468. loadingUIText: string;
  29469. /**
  29470. * Sets the current loading screen background color
  29471. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29472. */
  29473. loadingUIBackgroundColor: string;
  29474. /**
  29475. * Attach a new callback raised when context lost event is fired
  29476. * @param callback defines the callback to call
  29477. */
  29478. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  29479. /**
  29480. * Attach a new callback raised when context restored event is fired
  29481. * @param callback defines the callback to call
  29482. */
  29483. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  29484. /**
  29485. * Gets the source code of the vertex shader associated with a specific webGL program
  29486. * @param program defines the program to use
  29487. * @returns a string containing the source code of the vertex shader associated with the program
  29488. */
  29489. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  29490. /**
  29491. * Gets the source code of the fragment shader associated with a specific webGL program
  29492. * @param program defines the program to use
  29493. * @returns a string containing the source code of the fragment shader associated with the program
  29494. */
  29495. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  29496. /**
  29497. * Get the current error code of the webGL context
  29498. * @returns the error code
  29499. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  29500. */
  29501. getError(): number;
  29502. /**
  29503. * Gets the current framerate
  29504. * @returns a number representing the framerate
  29505. */
  29506. getFps(): number;
  29507. /**
  29508. * Gets the time spent between current and previous frame
  29509. * @returns a number representing the delta time in ms
  29510. */
  29511. getDeltaTime(): number;
  29512. private _measureFps;
  29513. /** @hidden */
  29514. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  29515. private _canRenderToFloatFramebuffer;
  29516. private _canRenderToHalfFloatFramebuffer;
  29517. private _canRenderToFramebuffer;
  29518. /** @hidden */
  29519. _getWebGLTextureType(type: number): number;
  29520. private _getInternalFormat;
  29521. /** @hidden */
  29522. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  29523. /** @hidden */
  29524. _getRGBAMultiSampleBufferFormat(type: number): number;
  29525. /** @hidden */
  29526. _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;
  29527. /** @hidden */
  29528. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  29529. private _partialLoadFile;
  29530. private _cascadeLoadFiles;
  29531. /**
  29532. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  29533. * @returns true if the engine can be created
  29534. * @ignorenaming
  29535. */
  29536. static isSupported(): boolean;
  29537. }
  29538. }
  29539. declare module "babylonjs/Materials/effect" {
  29540. import { Observable } from "babylonjs/Misc/observable";
  29541. import { Nullable } from "babylonjs/types";
  29542. import { Matrix, Vector3, Vector2, Color3, Color4, Vector4 } from "babylonjs/Maths/math";
  29543. import { Engine } from "babylonjs/Engines/engine";
  29544. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  29545. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  29546. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  29547. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  29548. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  29549. /**
  29550. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  29551. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  29552. */
  29553. export class EffectFallbacks {
  29554. private _defines;
  29555. private _currentRank;
  29556. private _maxRank;
  29557. private _mesh;
  29558. /**
  29559. * Removes the fallback from the bound mesh.
  29560. */
  29561. unBindMesh(): void;
  29562. /**
  29563. * Adds a fallback on the specified property.
  29564. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  29565. * @param define The name of the define in the shader
  29566. */
  29567. addFallback(rank: number, define: string): void;
  29568. /**
  29569. * Sets the mesh to use CPU skinning when needing to fallback.
  29570. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  29571. * @param mesh The mesh to use the fallbacks.
  29572. */
  29573. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  29574. /**
  29575. * Checks to see if more fallbacks are still availible.
  29576. */
  29577. readonly isMoreFallbacks: boolean;
  29578. /**
  29579. * Removes the defines that shoould be removed when falling back.
  29580. * @param currentDefines defines the current define statements for the shader.
  29581. * @param effect defines the current effect we try to compile
  29582. * @returns The resulting defines with defines of the current rank removed.
  29583. */
  29584. reduce(currentDefines: string, effect: Effect): string;
  29585. }
  29586. /**
  29587. * Options to be used when creating an effect.
  29588. */
  29589. export class EffectCreationOptions {
  29590. /**
  29591. * Atrributes that will be used in the shader.
  29592. */
  29593. attributes: string[];
  29594. /**
  29595. * Uniform varible names that will be set in the shader.
  29596. */
  29597. uniformsNames: string[];
  29598. /**
  29599. * Uniform buffer varible names that will be set in the shader.
  29600. */
  29601. uniformBuffersNames: string[];
  29602. /**
  29603. * Sampler texture variable names that will be set in the shader.
  29604. */
  29605. samplers: string[];
  29606. /**
  29607. * Define statements that will be set in the shader.
  29608. */
  29609. defines: any;
  29610. /**
  29611. * Possible fallbacks for this effect to improve performance when needed.
  29612. */
  29613. fallbacks: Nullable<EffectFallbacks>;
  29614. /**
  29615. * Callback that will be called when the shader is compiled.
  29616. */
  29617. onCompiled: Nullable<(effect: Effect) => void>;
  29618. /**
  29619. * Callback that will be called if an error occurs during shader compilation.
  29620. */
  29621. onError: Nullable<(effect: Effect, errors: string) => void>;
  29622. /**
  29623. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29624. */
  29625. indexParameters: any;
  29626. /**
  29627. * Max number of lights that can be used in the shader.
  29628. */
  29629. maxSimultaneousLights: number;
  29630. /**
  29631. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  29632. */
  29633. transformFeedbackVaryings: Nullable<string[]>;
  29634. }
  29635. /**
  29636. * Effect containing vertex and fragment shader that can be executed on an object.
  29637. */
  29638. export class Effect {
  29639. /**
  29640. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  29641. */
  29642. static ShadersRepository: string;
  29643. /**
  29644. * Name of the effect.
  29645. */
  29646. name: any;
  29647. /**
  29648. * String container all the define statements that should be set on the shader.
  29649. */
  29650. defines: string;
  29651. /**
  29652. * Callback that will be called when the shader is compiled.
  29653. */
  29654. onCompiled: Nullable<(effect: Effect) => void>;
  29655. /**
  29656. * Callback that will be called if an error occurs during shader compilation.
  29657. */
  29658. onError: Nullable<(effect: Effect, errors: string) => void>;
  29659. /**
  29660. * Callback that will be called when effect is bound.
  29661. */
  29662. onBind: Nullable<(effect: Effect) => void>;
  29663. /**
  29664. * Unique ID of the effect.
  29665. */
  29666. uniqueId: number;
  29667. /**
  29668. * Observable that will be called when the shader is compiled.
  29669. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  29670. */
  29671. onCompileObservable: Observable<Effect>;
  29672. /**
  29673. * Observable that will be called if an error occurs during shader compilation.
  29674. */
  29675. onErrorObservable: Observable<Effect>;
  29676. /** @hidden */
  29677. _onBindObservable: Nullable<Observable<Effect>>;
  29678. /**
  29679. * Observable that will be called when effect is bound.
  29680. */
  29681. readonly onBindObservable: Observable<Effect>;
  29682. /** @hidden */
  29683. _bonesComputationForcedToCPU: boolean;
  29684. private static _uniqueIdSeed;
  29685. private _engine;
  29686. private _uniformBuffersNames;
  29687. private _uniformsNames;
  29688. private _samplers;
  29689. private _isReady;
  29690. private _compilationError;
  29691. private _attributesNames;
  29692. private _attributes;
  29693. private _uniforms;
  29694. /**
  29695. * Key for the effect.
  29696. * @hidden
  29697. */
  29698. _key: string;
  29699. private _indexParameters;
  29700. private _fallbacks;
  29701. private _vertexSourceCode;
  29702. private _fragmentSourceCode;
  29703. private _vertexSourceCodeOverride;
  29704. private _fragmentSourceCodeOverride;
  29705. private _transformFeedbackVaryings;
  29706. /**
  29707. * Compiled shader to webGL program.
  29708. * @hidden
  29709. */
  29710. _program: WebGLProgram;
  29711. private _valueCache;
  29712. private static _baseCache;
  29713. /**
  29714. * Instantiates an effect.
  29715. * An effect can be used to create/manage/execute vertex and fragment shaders.
  29716. * @param baseName Name of the effect.
  29717. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  29718. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  29719. * @param samplers List of sampler variables that will be passed to the shader.
  29720. * @param engine Engine to be used to render the effect
  29721. * @param defines Define statements to be added to the shader.
  29722. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  29723. * @param onCompiled Callback that will be called when the shader is compiled.
  29724. * @param onError Callback that will be called if an error occurs during shader compilation.
  29725. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29726. */
  29727. 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);
  29728. /**
  29729. * Unique key for this effect
  29730. */
  29731. readonly key: string;
  29732. /**
  29733. * If the effect has been compiled and prepared.
  29734. * @returns if the effect is compiled and prepared.
  29735. */
  29736. isReady(): boolean;
  29737. /**
  29738. * The engine the effect was initialized with.
  29739. * @returns the engine.
  29740. */
  29741. getEngine(): Engine;
  29742. /**
  29743. * The compiled webGL program for the effect
  29744. * @returns the webGL program.
  29745. */
  29746. getProgram(): WebGLProgram;
  29747. /**
  29748. * The set of names of attribute variables for the shader.
  29749. * @returns An array of attribute names.
  29750. */
  29751. getAttributesNames(): string[];
  29752. /**
  29753. * Returns the attribute at the given index.
  29754. * @param index The index of the attribute.
  29755. * @returns The location of the attribute.
  29756. */
  29757. getAttributeLocation(index: number): number;
  29758. /**
  29759. * Returns the attribute based on the name of the variable.
  29760. * @param name of the attribute to look up.
  29761. * @returns the attribute location.
  29762. */
  29763. getAttributeLocationByName(name: string): number;
  29764. /**
  29765. * The number of attributes.
  29766. * @returns the numnber of attributes.
  29767. */
  29768. getAttributesCount(): number;
  29769. /**
  29770. * Gets the index of a uniform variable.
  29771. * @param uniformName of the uniform to look up.
  29772. * @returns the index.
  29773. */
  29774. getUniformIndex(uniformName: string): number;
  29775. /**
  29776. * Returns the attribute based on the name of the variable.
  29777. * @param uniformName of the uniform to look up.
  29778. * @returns the location of the uniform.
  29779. */
  29780. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  29781. /**
  29782. * Returns an array of sampler variable names
  29783. * @returns The array of sampler variable neames.
  29784. */
  29785. getSamplers(): string[];
  29786. /**
  29787. * The error from the last compilation.
  29788. * @returns the error string.
  29789. */
  29790. getCompilationError(): string;
  29791. /**
  29792. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  29793. * @param func The callback to be used.
  29794. */
  29795. executeWhenCompiled(func: (effect: Effect) => void): void;
  29796. private _checkIsReady;
  29797. /** @hidden */
  29798. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  29799. /** @hidden */
  29800. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  29801. /** @hidden */
  29802. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  29803. private _processShaderConversion;
  29804. private _processIncludes;
  29805. private _processPrecision;
  29806. /**
  29807. * Recompiles the webGL program
  29808. * @param vertexSourceCode The source code for the vertex shader.
  29809. * @param fragmentSourceCode The source code for the fragment shader.
  29810. * @param onCompiled Callback called when completed.
  29811. * @param onError Callback called on error.
  29812. * @hidden
  29813. */
  29814. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void): void;
  29815. /**
  29816. * Gets the uniform locations of the the specified variable names
  29817. * @param names THe names of the variables to lookup.
  29818. * @returns Array of locations in the same order as variable names.
  29819. */
  29820. getSpecificUniformLocations(names: string[]): Nullable<WebGLUniformLocation>[];
  29821. /**
  29822. * Prepares the effect
  29823. * @hidden
  29824. */
  29825. _prepareEffect(): void;
  29826. /**
  29827. * Checks if the effect is supported. (Must be called after compilation)
  29828. */
  29829. readonly isSupported: boolean;
  29830. /**
  29831. * Binds a texture to the engine to be used as output of the shader.
  29832. * @param channel Name of the output variable.
  29833. * @param texture Texture to bind.
  29834. * @hidden
  29835. */
  29836. _bindTexture(channel: string, texture: InternalTexture): void;
  29837. /**
  29838. * Sets a texture on the engine to be used in the shader.
  29839. * @param channel Name of the sampler variable.
  29840. * @param texture Texture to set.
  29841. */
  29842. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  29843. /**
  29844. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  29845. * @param channel Name of the sampler variable.
  29846. * @param texture Texture to set.
  29847. */
  29848. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  29849. /**
  29850. * Sets an array of textures on the engine to be used in the shader.
  29851. * @param channel Name of the variable.
  29852. * @param textures Textures to set.
  29853. */
  29854. setTextureArray(channel: string, textures: BaseTexture[]): void;
  29855. /**
  29856. * 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)
  29857. * @param channel Name of the sampler variable.
  29858. * @param postProcess Post process to get the input texture from.
  29859. */
  29860. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  29861. /**
  29862. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  29863. * 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)
  29864. * @param channel Name of the sampler variable.
  29865. * @param postProcess Post process to get the output texture from.
  29866. */
  29867. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  29868. /** @hidden */
  29869. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  29870. /** @hidden */
  29871. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  29872. /** @hidden */
  29873. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  29874. /** @hidden */
  29875. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  29876. /**
  29877. * Binds a buffer to a uniform.
  29878. * @param buffer Buffer to bind.
  29879. * @param name Name of the uniform variable to bind to.
  29880. */
  29881. bindUniformBuffer(buffer: WebGLBuffer, name: string): void;
  29882. /**
  29883. * Binds block to a uniform.
  29884. * @param blockName Name of the block to bind.
  29885. * @param index Index to bind.
  29886. */
  29887. bindUniformBlock(blockName: string, index: number): void;
  29888. /**
  29889. * Sets an interger value on a uniform variable.
  29890. * @param uniformName Name of the variable.
  29891. * @param value Value to be set.
  29892. * @returns this effect.
  29893. */
  29894. setInt(uniformName: string, value: number): Effect;
  29895. /**
  29896. * Sets an int array on a uniform variable.
  29897. * @param uniformName Name of the variable.
  29898. * @param array array to be set.
  29899. * @returns this effect.
  29900. */
  29901. setIntArray(uniformName: string, array: Int32Array): Effect;
  29902. /**
  29903. * 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)
  29904. * @param uniformName Name of the variable.
  29905. * @param array array to be set.
  29906. * @returns this effect.
  29907. */
  29908. setIntArray2(uniformName: string, array: Int32Array): Effect;
  29909. /**
  29910. * 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)
  29911. * @param uniformName Name of the variable.
  29912. * @param array array to be set.
  29913. * @returns this effect.
  29914. */
  29915. setIntArray3(uniformName: string, array: Int32Array): Effect;
  29916. /**
  29917. * 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)
  29918. * @param uniformName Name of the variable.
  29919. * @param array array to be set.
  29920. * @returns this effect.
  29921. */
  29922. setIntArray4(uniformName: string, array: Int32Array): Effect;
  29923. /**
  29924. * Sets an float array on a uniform variable.
  29925. * @param uniformName Name of the variable.
  29926. * @param array array to be set.
  29927. * @returns this effect.
  29928. */
  29929. setFloatArray(uniformName: string, array: Float32Array): Effect;
  29930. /**
  29931. * 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)
  29932. * @param uniformName Name of the variable.
  29933. * @param array array to be set.
  29934. * @returns this effect.
  29935. */
  29936. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  29937. /**
  29938. * 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)
  29939. * @param uniformName Name of the variable.
  29940. * @param array array to be set.
  29941. * @returns this effect.
  29942. */
  29943. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  29944. /**
  29945. * 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)
  29946. * @param uniformName Name of the variable.
  29947. * @param array array to be set.
  29948. * @returns this effect.
  29949. */
  29950. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  29951. /**
  29952. * Sets an array on a uniform variable.
  29953. * @param uniformName Name of the variable.
  29954. * @param array array to be set.
  29955. * @returns this effect.
  29956. */
  29957. setArray(uniformName: string, array: number[]): Effect;
  29958. /**
  29959. * 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)
  29960. * @param uniformName Name of the variable.
  29961. * @param array array to be set.
  29962. * @returns this effect.
  29963. */
  29964. setArray2(uniformName: string, array: number[]): Effect;
  29965. /**
  29966. * 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)
  29967. * @param uniformName Name of the variable.
  29968. * @param array array to be set.
  29969. * @returns this effect.
  29970. */
  29971. setArray3(uniformName: string, array: number[]): Effect;
  29972. /**
  29973. * 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)
  29974. * @param uniformName Name of the variable.
  29975. * @param array array to be set.
  29976. * @returns this effect.
  29977. */
  29978. setArray4(uniformName: string, array: number[]): Effect;
  29979. /**
  29980. * Sets matrices on a uniform variable.
  29981. * @param uniformName Name of the variable.
  29982. * @param matrices matrices to be set.
  29983. * @returns this effect.
  29984. */
  29985. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  29986. /**
  29987. * Sets matrix on a uniform variable.
  29988. * @param uniformName Name of the variable.
  29989. * @param matrix matrix to be set.
  29990. * @returns this effect.
  29991. */
  29992. setMatrix(uniformName: string, matrix: Matrix): Effect;
  29993. /**
  29994. * 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)
  29995. * @param uniformName Name of the variable.
  29996. * @param matrix matrix to be set.
  29997. * @returns this effect.
  29998. */
  29999. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  30000. /**
  30001. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  30002. * @param uniformName Name of the variable.
  30003. * @param matrix matrix to be set.
  30004. * @returns this effect.
  30005. */
  30006. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  30007. /**
  30008. * Sets a float on a uniform variable.
  30009. * @param uniformName Name of the variable.
  30010. * @param value value to be set.
  30011. * @returns this effect.
  30012. */
  30013. setFloat(uniformName: string, value: number): Effect;
  30014. /**
  30015. * Sets a boolean on a uniform variable.
  30016. * @param uniformName Name of the variable.
  30017. * @param bool value to be set.
  30018. * @returns this effect.
  30019. */
  30020. setBool(uniformName: string, bool: boolean): Effect;
  30021. /**
  30022. * Sets a Vector2 on a uniform variable.
  30023. * @param uniformName Name of the variable.
  30024. * @param vector2 vector2 to be set.
  30025. * @returns this effect.
  30026. */
  30027. setVector2(uniformName: string, vector2: Vector2): Effect;
  30028. /**
  30029. * Sets a float2 on a uniform variable.
  30030. * @param uniformName Name of the variable.
  30031. * @param x First float in float2.
  30032. * @param y Second float in float2.
  30033. * @returns this effect.
  30034. */
  30035. setFloat2(uniformName: string, x: number, y: number): Effect;
  30036. /**
  30037. * Sets a Vector3 on a uniform variable.
  30038. * @param uniformName Name of the variable.
  30039. * @param vector3 Value to be set.
  30040. * @returns this effect.
  30041. */
  30042. setVector3(uniformName: string, vector3: Vector3): Effect;
  30043. /**
  30044. * Sets a float3 on a uniform variable.
  30045. * @param uniformName Name of the variable.
  30046. * @param x First float in float3.
  30047. * @param y Second float in float3.
  30048. * @param z Third float in float3.
  30049. * @returns this effect.
  30050. */
  30051. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  30052. /**
  30053. * Sets a Vector4 on a uniform variable.
  30054. * @param uniformName Name of the variable.
  30055. * @param vector4 Value to be set.
  30056. * @returns this effect.
  30057. */
  30058. setVector4(uniformName: string, vector4: Vector4): Effect;
  30059. /**
  30060. * Sets a float4 on a uniform variable.
  30061. * @param uniformName Name of the variable.
  30062. * @param x First float in float4.
  30063. * @param y Second float in float4.
  30064. * @param z Third float in float4.
  30065. * @param w Fourth float in float4.
  30066. * @returns this effect.
  30067. */
  30068. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  30069. /**
  30070. * Sets a Color3 on a uniform variable.
  30071. * @param uniformName Name of the variable.
  30072. * @param color3 Value to be set.
  30073. * @returns this effect.
  30074. */
  30075. setColor3(uniformName: string, color3: Color3): Effect;
  30076. /**
  30077. * Sets a Color4 on a uniform variable.
  30078. * @param uniformName Name of the variable.
  30079. * @param color3 Value to be set.
  30080. * @param alpha Alpha value to be set.
  30081. * @returns this effect.
  30082. */
  30083. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  30084. /**
  30085. * Sets a Color4 on a uniform variable
  30086. * @param uniformName defines the name of the variable
  30087. * @param color4 defines the value to be set
  30088. * @returns this effect.
  30089. */
  30090. setDirectColor4(uniformName: string, color4: Color4): Effect;
  30091. /**
  30092. * This function will add a new shader to the shader store
  30093. * @param name the name of the shader
  30094. * @param pixelShader optional pixel shader content
  30095. * @param vertexShader optional vertex shader content
  30096. */
  30097. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  30098. /**
  30099. * Store of each shader (The can be looked up using effect.key)
  30100. */
  30101. static ShadersStore: {
  30102. [key: string]: string;
  30103. };
  30104. /**
  30105. * Store of each included file for a shader (The can be looked up using effect.key)
  30106. */
  30107. static IncludesShadersStore: {
  30108. [key: string]: string;
  30109. };
  30110. /**
  30111. * Resets the cache of effects.
  30112. */
  30113. static ResetCache(): void;
  30114. }
  30115. }
  30116. declare module "babylonjs/Materials/colorCurves" {
  30117. import { Effect } from "babylonjs/Materials/effect";
  30118. /**
  30119. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  30120. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  30121. * 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;
  30122. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  30123. */
  30124. export class ColorCurves {
  30125. private _dirty;
  30126. private _tempColor;
  30127. private _globalCurve;
  30128. private _highlightsCurve;
  30129. private _midtonesCurve;
  30130. private _shadowsCurve;
  30131. private _positiveCurve;
  30132. private _negativeCurve;
  30133. private _globalHue;
  30134. private _globalDensity;
  30135. private _globalSaturation;
  30136. private _globalExposure;
  30137. /**
  30138. * Gets the global Hue value.
  30139. * 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).
  30140. */
  30141. /**
  30142. * Sets the global Hue value.
  30143. * 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).
  30144. */
  30145. globalHue: number;
  30146. /**
  30147. * Gets the global Density value.
  30148. * 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.
  30149. * Values less than zero provide a filter of opposite hue.
  30150. */
  30151. /**
  30152. * Sets the global Density value.
  30153. * 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.
  30154. * Values less than zero provide a filter of opposite hue.
  30155. */
  30156. globalDensity: number;
  30157. /**
  30158. * Gets the global Saturation value.
  30159. * 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.
  30160. */
  30161. /**
  30162. * Sets the global Saturation value.
  30163. * 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.
  30164. */
  30165. globalSaturation: number;
  30166. /**
  30167. * Gets the global Exposure value.
  30168. * 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.
  30169. */
  30170. /**
  30171. * Sets the global Exposure value.
  30172. * 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.
  30173. */
  30174. globalExposure: number;
  30175. private _highlightsHue;
  30176. private _highlightsDensity;
  30177. private _highlightsSaturation;
  30178. private _highlightsExposure;
  30179. /**
  30180. * Gets the highlights Hue value.
  30181. * 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).
  30182. */
  30183. /**
  30184. * Sets the highlights Hue value.
  30185. * 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).
  30186. */
  30187. highlightsHue: number;
  30188. /**
  30189. * Gets the highlights Density value.
  30190. * 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.
  30191. * Values less than zero provide a filter of opposite hue.
  30192. */
  30193. /**
  30194. * Sets the highlights Density value.
  30195. * 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.
  30196. * Values less than zero provide a filter of opposite hue.
  30197. */
  30198. highlightsDensity: number;
  30199. /**
  30200. * Gets the highlights Saturation value.
  30201. * 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.
  30202. */
  30203. /**
  30204. * Sets the highlights Saturation value.
  30205. * 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.
  30206. */
  30207. highlightsSaturation: number;
  30208. /**
  30209. * Gets the highlights Exposure value.
  30210. * 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.
  30211. */
  30212. /**
  30213. * Sets the highlights Exposure value.
  30214. * 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.
  30215. */
  30216. highlightsExposure: number;
  30217. private _midtonesHue;
  30218. private _midtonesDensity;
  30219. private _midtonesSaturation;
  30220. private _midtonesExposure;
  30221. /**
  30222. * Gets the midtones Hue value.
  30223. * 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).
  30224. */
  30225. /**
  30226. * Sets the midtones Hue value.
  30227. * 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).
  30228. */
  30229. midtonesHue: number;
  30230. /**
  30231. * Gets the midtones Density value.
  30232. * 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.
  30233. * Values less than zero provide a filter of opposite hue.
  30234. */
  30235. /**
  30236. * Sets the midtones Density value.
  30237. * 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.
  30238. * Values less than zero provide a filter of opposite hue.
  30239. */
  30240. midtonesDensity: number;
  30241. /**
  30242. * Gets the midtones Saturation value.
  30243. * 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.
  30244. */
  30245. /**
  30246. * Sets the midtones Saturation value.
  30247. * 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.
  30248. */
  30249. midtonesSaturation: number;
  30250. /**
  30251. * Gets the midtones Exposure value.
  30252. * 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.
  30253. */
  30254. /**
  30255. * Sets the midtones Exposure value.
  30256. * 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.
  30257. */
  30258. midtonesExposure: number;
  30259. private _shadowsHue;
  30260. private _shadowsDensity;
  30261. private _shadowsSaturation;
  30262. private _shadowsExposure;
  30263. /**
  30264. * Gets the shadows Hue value.
  30265. * 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).
  30266. */
  30267. /**
  30268. * Sets the shadows Hue value.
  30269. * 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).
  30270. */
  30271. shadowsHue: number;
  30272. /**
  30273. * Gets the shadows Density value.
  30274. * 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.
  30275. * Values less than zero provide a filter of opposite hue.
  30276. */
  30277. /**
  30278. * Sets the shadows Density value.
  30279. * 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.
  30280. * Values less than zero provide a filter of opposite hue.
  30281. */
  30282. shadowsDensity: number;
  30283. /**
  30284. * Gets the shadows Saturation value.
  30285. * 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.
  30286. */
  30287. /**
  30288. * Sets the shadows Saturation value.
  30289. * 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.
  30290. */
  30291. shadowsSaturation: number;
  30292. /**
  30293. * Gets the shadows Exposure value.
  30294. * 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.
  30295. */
  30296. /**
  30297. * Sets the shadows Exposure value.
  30298. * 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.
  30299. */
  30300. shadowsExposure: number;
  30301. /**
  30302. * Returns the class name
  30303. * @returns The class name
  30304. */
  30305. getClassName(): string;
  30306. /**
  30307. * Binds the color curves to the shader.
  30308. * @param colorCurves The color curve to bind
  30309. * @param effect The effect to bind to
  30310. * @param positiveUniform The positive uniform shader parameter
  30311. * @param neutralUniform The neutral uniform shader parameter
  30312. * @param negativeUniform The negative uniform shader parameter
  30313. */
  30314. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  30315. /**
  30316. * Prepare the list of uniforms associated with the ColorCurves effects.
  30317. * @param uniformsList The list of uniforms used in the effect
  30318. */
  30319. static PrepareUniforms(uniformsList: string[]): void;
  30320. /**
  30321. * Returns color grading data based on a hue, density, saturation and exposure value.
  30322. * @param filterHue The hue of the color filter.
  30323. * @param filterDensity The density of the color filter.
  30324. * @param saturation The saturation.
  30325. * @param exposure The exposure.
  30326. * @param result The result data container.
  30327. */
  30328. private getColorGradingDataToRef;
  30329. /**
  30330. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  30331. * @param value The input slider value in range [-100,100].
  30332. * @returns Adjusted value.
  30333. */
  30334. private static applyColorGradingSliderNonlinear;
  30335. /**
  30336. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  30337. * @param hue The hue (H) input.
  30338. * @param saturation The saturation (S) input.
  30339. * @param brightness The brightness (B) input.
  30340. * @result An RGBA color represented as Vector4.
  30341. */
  30342. private static fromHSBToRef;
  30343. /**
  30344. * Returns a value clamped between min and max
  30345. * @param value The value to clamp
  30346. * @param min The minimum of value
  30347. * @param max The maximum of value
  30348. * @returns The clamped value.
  30349. */
  30350. private static clamp;
  30351. /**
  30352. * Clones the current color curve instance.
  30353. * @return The cloned curves
  30354. */
  30355. clone(): ColorCurves;
  30356. /**
  30357. * Serializes the current color curve instance to a json representation.
  30358. * @return a JSON representation
  30359. */
  30360. serialize(): any;
  30361. /**
  30362. * Parses the color curve from a json representation.
  30363. * @param source the JSON source to parse
  30364. * @return The parsed curves
  30365. */
  30366. static Parse(source: any): ColorCurves;
  30367. }
  30368. }
  30369. declare module "babylonjs/Materials/imageProcessingConfiguration" {
  30370. import { Observable } from "babylonjs/Misc/observable";
  30371. import { Nullable } from "babylonjs/types";
  30372. import { Color4 } from "babylonjs/Maths/math";
  30373. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  30374. import { Effect } from "babylonjs/Materials/effect";
  30375. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  30376. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  30377. /**
  30378. * Interface to follow in your material defines to integrate easily the
  30379. * Image proccessing functions.
  30380. * @hidden
  30381. */
  30382. export interface IImageProcessingConfigurationDefines {
  30383. IMAGEPROCESSING: boolean;
  30384. VIGNETTE: boolean;
  30385. VIGNETTEBLENDMODEMULTIPLY: boolean;
  30386. VIGNETTEBLENDMODEOPAQUE: boolean;
  30387. TONEMAPPING: boolean;
  30388. TONEMAPPING_ACES: boolean;
  30389. CONTRAST: boolean;
  30390. EXPOSURE: boolean;
  30391. COLORCURVES: boolean;
  30392. COLORGRADING: boolean;
  30393. COLORGRADING3D: boolean;
  30394. SAMPLER3DGREENDEPTH: boolean;
  30395. SAMPLER3DBGRMAP: boolean;
  30396. IMAGEPROCESSINGPOSTPROCESS: boolean;
  30397. }
  30398. /**
  30399. * @hidden
  30400. */
  30401. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  30402. IMAGEPROCESSING: boolean;
  30403. VIGNETTE: boolean;
  30404. VIGNETTEBLENDMODEMULTIPLY: boolean;
  30405. VIGNETTEBLENDMODEOPAQUE: boolean;
  30406. TONEMAPPING: boolean;
  30407. TONEMAPPING_ACES: boolean;
  30408. CONTRAST: boolean;
  30409. COLORCURVES: boolean;
  30410. COLORGRADING: boolean;
  30411. COLORGRADING3D: boolean;
  30412. SAMPLER3DGREENDEPTH: boolean;
  30413. SAMPLER3DBGRMAP: boolean;
  30414. IMAGEPROCESSINGPOSTPROCESS: boolean;
  30415. EXPOSURE: boolean;
  30416. constructor();
  30417. }
  30418. /**
  30419. * This groups together the common properties used for image processing either in direct forward pass
  30420. * or through post processing effect depending on the use of the image processing pipeline in your scene
  30421. * or not.
  30422. */
  30423. export class ImageProcessingConfiguration {
  30424. /**
  30425. * Default tone mapping applied in BabylonJS.
  30426. */
  30427. static readonly TONEMAPPING_STANDARD: number;
  30428. /**
  30429. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  30430. * to other engines rendering to increase portability.
  30431. */
  30432. static readonly TONEMAPPING_ACES: number;
  30433. /**
  30434. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  30435. */
  30436. colorCurves: Nullable<ColorCurves>;
  30437. private _colorCurvesEnabled;
  30438. /**
  30439. * Gets wether the color curves effect is enabled.
  30440. */
  30441. /**
  30442. * Sets wether the color curves effect is enabled.
  30443. */
  30444. colorCurvesEnabled: boolean;
  30445. private _colorGradingTexture;
  30446. /**
  30447. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  30448. */
  30449. /**
  30450. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  30451. */
  30452. colorGradingTexture: Nullable<BaseTexture>;
  30453. private _colorGradingEnabled;
  30454. /**
  30455. * Gets wether the color grading effect is enabled.
  30456. */
  30457. /**
  30458. * Sets wether the color grading effect is enabled.
  30459. */
  30460. colorGradingEnabled: boolean;
  30461. private _colorGradingWithGreenDepth;
  30462. /**
  30463. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  30464. */
  30465. /**
  30466. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  30467. */
  30468. colorGradingWithGreenDepth: boolean;
  30469. private _colorGradingBGR;
  30470. /**
  30471. * Gets wether the color grading texture contains BGR values.
  30472. */
  30473. /**
  30474. * Sets wether the color grading texture contains BGR values.
  30475. */
  30476. colorGradingBGR: boolean;
  30477. /** @hidden */
  30478. _exposure: number;
  30479. /**
  30480. * Gets the Exposure used in the effect.
  30481. */
  30482. /**
  30483. * Sets the Exposure used in the effect.
  30484. */
  30485. exposure: number;
  30486. private _toneMappingEnabled;
  30487. /**
  30488. * Gets wether the tone mapping effect is enabled.
  30489. */
  30490. /**
  30491. * Sets wether the tone mapping effect is enabled.
  30492. */
  30493. toneMappingEnabled: boolean;
  30494. private _toneMappingType;
  30495. /**
  30496. * Gets the type of tone mapping effect.
  30497. */
  30498. /**
  30499. * Sets the type of tone mapping effect used in BabylonJS.
  30500. */
  30501. toneMappingType: number;
  30502. protected _contrast: number;
  30503. /**
  30504. * Gets the contrast used in the effect.
  30505. */
  30506. /**
  30507. * Sets the contrast used in the effect.
  30508. */
  30509. contrast: number;
  30510. /**
  30511. * Vignette stretch size.
  30512. */
  30513. vignetteStretch: number;
  30514. /**
  30515. * Vignette centre X Offset.
  30516. */
  30517. vignetteCentreX: number;
  30518. /**
  30519. * Vignette centre Y Offset.
  30520. */
  30521. vignetteCentreY: number;
  30522. /**
  30523. * Vignette weight or intensity of the vignette effect.
  30524. */
  30525. vignetteWeight: number;
  30526. /**
  30527. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  30528. * if vignetteEnabled is set to true.
  30529. */
  30530. vignetteColor: Color4;
  30531. /**
  30532. * Camera field of view used by the Vignette effect.
  30533. */
  30534. vignetteCameraFov: number;
  30535. private _vignetteBlendMode;
  30536. /**
  30537. * Gets the vignette blend mode allowing different kind of effect.
  30538. */
  30539. /**
  30540. * Sets the vignette blend mode allowing different kind of effect.
  30541. */
  30542. vignetteBlendMode: number;
  30543. private _vignetteEnabled;
  30544. /**
  30545. * Gets wether the vignette effect is enabled.
  30546. */
  30547. /**
  30548. * Sets wether the vignette effect is enabled.
  30549. */
  30550. vignetteEnabled: boolean;
  30551. private _applyByPostProcess;
  30552. /**
  30553. * Gets wether the image processing is applied through a post process or not.
  30554. */
  30555. /**
  30556. * Sets wether the image processing is applied through a post process or not.
  30557. */
  30558. applyByPostProcess: boolean;
  30559. private _isEnabled;
  30560. /**
  30561. * Gets wether the image processing is enabled or not.
  30562. */
  30563. /**
  30564. * Sets wether the image processing is enabled or not.
  30565. */
  30566. isEnabled: boolean;
  30567. /**
  30568. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  30569. */
  30570. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  30571. /**
  30572. * Method called each time the image processing information changes requires to recompile the effect.
  30573. */
  30574. protected _updateParameters(): void;
  30575. /**
  30576. * Gets the current class name.
  30577. * @return "ImageProcessingConfiguration"
  30578. */
  30579. getClassName(): string;
  30580. /**
  30581. * Prepare the list of uniforms associated with the Image Processing effects.
  30582. * @param uniforms The list of uniforms used in the effect
  30583. * @param defines the list of defines currently in use
  30584. */
  30585. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  30586. /**
  30587. * Prepare the list of samplers associated with the Image Processing effects.
  30588. * @param samplersList The list of uniforms used in the effect
  30589. * @param defines the list of defines currently in use
  30590. */
  30591. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  30592. /**
  30593. * Prepare the list of defines associated to the shader.
  30594. * @param defines the list of defines to complete
  30595. * @param forPostProcess Define if we are currently in post process mode or not
  30596. */
  30597. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  30598. /**
  30599. * Returns true if all the image processing information are ready.
  30600. * @returns True if ready, otherwise, false
  30601. */
  30602. isReady(): boolean;
  30603. /**
  30604. * Binds the image processing to the shader.
  30605. * @param effect The effect to bind to
  30606. * @param aspectRatio Define the current aspect ratio of the effect
  30607. */
  30608. bind(effect: Effect, aspectRatio?: number): void;
  30609. /**
  30610. * Clones the current image processing instance.
  30611. * @return The cloned image processing
  30612. */
  30613. clone(): ImageProcessingConfiguration;
  30614. /**
  30615. * Serializes the current image processing instance to a json representation.
  30616. * @return a JSON representation
  30617. */
  30618. serialize(): any;
  30619. /**
  30620. * Parses the image processing from a json representation.
  30621. * @param source the JSON source to parse
  30622. * @return The parsed image processing
  30623. */
  30624. static Parse(source: any): ImageProcessingConfiguration;
  30625. private static _VIGNETTEMODE_MULTIPLY;
  30626. private static _VIGNETTEMODE_OPAQUE;
  30627. /**
  30628. * Used to apply the vignette as a mix with the pixel color.
  30629. */
  30630. static readonly VIGNETTEMODE_MULTIPLY: number;
  30631. /**
  30632. * Used to apply the vignette as a replacement of the pixel color.
  30633. */
  30634. static readonly VIGNETTEMODE_OPAQUE: number;
  30635. }
  30636. }
  30637. declare module "babylonjs/Materials/fresnelParameters" {
  30638. import { Color3 } from "babylonjs/Maths/math";
  30639. /**
  30640. * This represents all the required information to add a fresnel effect on a material:
  30641. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30642. */
  30643. export class FresnelParameters {
  30644. private _isEnabled;
  30645. /**
  30646. * Define if the fresnel effect is enable or not.
  30647. */
  30648. isEnabled: boolean;
  30649. /**
  30650. * Define the color used on edges (grazing angle)
  30651. */
  30652. leftColor: Color3;
  30653. /**
  30654. * Define the color used on center
  30655. */
  30656. rightColor: Color3;
  30657. /**
  30658. * Define bias applied to computed fresnel term
  30659. */
  30660. bias: number;
  30661. /**
  30662. * Defined the power exponent applied to fresnel term
  30663. */
  30664. power: number;
  30665. /**
  30666. * Clones the current fresnel and its valuues
  30667. * @returns a clone fresnel configuration
  30668. */
  30669. clone(): FresnelParameters;
  30670. /**
  30671. * Serializes the current fresnel parameters to a JSON representation.
  30672. * @return the JSON serialization
  30673. */
  30674. serialize(): any;
  30675. /**
  30676. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  30677. * @param parsedFresnelParameters Define the JSON representation
  30678. * @returns the parsed parameters
  30679. */
  30680. static Parse(parsedFresnelParameters: any): FresnelParameters;
  30681. }
  30682. }
  30683. declare module "babylonjs/Misc/decorators" {
  30684. import { Nullable } from "babylonjs/types";
  30685. import { Scene } from "babylonjs/scene";
  30686. import { IAnimatable } from "babylonjs/Misc/tools";
  30687. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  30688. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30689. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30690. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30691. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30692. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30693. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30694. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30695. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30696. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30697. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30698. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30699. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30700. /**
  30701. * Decorator used to define property that can be serialized as reference to a camera
  30702. * @param sourceName defines the name of the property to decorate
  30703. */
  30704. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30705. /**
  30706. * Class used to help serialization objects
  30707. */
  30708. export class SerializationHelper {
  30709. /** hidden */
  30710. static _ImageProcessingConfigurationParser: (sourceProperty: any) => import("babylonjs/Materials/imageProcessingConfiguration").ImageProcessingConfiguration;
  30711. /** hidden */
  30712. static _FresnelParametersParser: (sourceProperty: any) => import("babylonjs/Materials/fresnelParameters").FresnelParameters;
  30713. /** hidden */
  30714. static _ColorCurvesParser: (sourceProperty: any) => import("babylonjs/Materials/colorCurves").ColorCurves;
  30715. /** hidden */
  30716. static _TextureParser: (sourceProperty: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => Nullable<import("babylonjs/Materials/Textures/baseTexture").BaseTexture>;
  30717. /**
  30718. * Appends the serialized animations from the source animations
  30719. * @param source Source containing the animations
  30720. * @param destination Target to store the animations
  30721. */
  30722. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  30723. /**
  30724. * Static function used to serialized a specific entity
  30725. * @param entity defines the entity to serialize
  30726. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  30727. * @returns a JSON compatible object representing the serialization of the entity
  30728. */
  30729. static Serialize<T>(entity: T, serializationObject?: any): any;
  30730. /**
  30731. * Creates a new entity from a serialization data object
  30732. * @param creationFunction defines a function used to instanciated the new entity
  30733. * @param source defines the source serialization data
  30734. * @param scene defines the hosting scene
  30735. * @param rootUrl defines the root url for resources
  30736. * @returns a new entity
  30737. */
  30738. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  30739. /**
  30740. * Clones an object
  30741. * @param creationFunction defines the function used to instanciate the new object
  30742. * @param source defines the source object
  30743. * @returns the cloned object
  30744. */
  30745. static Clone<T>(creationFunction: () => T, source: T): T;
  30746. /**
  30747. * Instanciates a new object based on a source one (some data will be shared between both object)
  30748. * @param creationFunction defines the function used to instanciate the new object
  30749. * @param source defines the source object
  30750. * @returns the new object
  30751. */
  30752. static Instanciate<T>(creationFunction: () => T, source: T): T;
  30753. }
  30754. }
  30755. declare module "babylonjs/Cameras/camera" {
  30756. import { SmartArray } from "babylonjs/Misc/smartArray";
  30757. import { Observable } from "babylonjs/Misc/observable";
  30758. import { Nullable } from "babylonjs/types";
  30759. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  30760. import { Scene } from "babylonjs/scene";
  30761. import { Matrix, Vector3, Viewport } from "babylonjs/Maths/math";
  30762. import { Node } from "babylonjs/node";
  30763. import { Mesh } from "babylonjs/Meshes/mesh";
  30764. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  30765. import { ICullable } from "babylonjs/Culling/boundingInfo";
  30766. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  30767. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  30768. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  30769. import { Ray } from "babylonjs/Culling/ray";
  30770. /**
  30771. * This is the base class of all the camera used in the application.
  30772. * @see http://doc.babylonjs.com/features/cameras
  30773. */
  30774. export class Camera extends Node {
  30775. /** @hidden */
  30776. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  30777. /**
  30778. * This is the default projection mode used by the cameras.
  30779. * It helps recreating a feeling of perspective and better appreciate depth.
  30780. * This is the best way to simulate real life cameras.
  30781. */
  30782. static readonly PERSPECTIVE_CAMERA: number;
  30783. /**
  30784. * This helps creating camera with an orthographic mode.
  30785. * 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.
  30786. */
  30787. static readonly ORTHOGRAPHIC_CAMERA: number;
  30788. /**
  30789. * This is the default FOV mode for perspective cameras.
  30790. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  30791. */
  30792. static readonly FOVMODE_VERTICAL_FIXED: number;
  30793. /**
  30794. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  30795. */
  30796. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  30797. /**
  30798. * This specifies ther is no need for a camera rig.
  30799. * Basically only one eye is rendered corresponding to the camera.
  30800. */
  30801. static readonly RIG_MODE_NONE: number;
  30802. /**
  30803. * Simulates a camera Rig with one blue eye and one red eye.
  30804. * This can be use with 3d blue and red glasses.
  30805. */
  30806. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  30807. /**
  30808. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  30809. */
  30810. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  30811. /**
  30812. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  30813. */
  30814. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  30815. /**
  30816. * Defines that both eyes of the camera will be rendered over under each other.
  30817. */
  30818. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  30819. /**
  30820. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  30821. */
  30822. static readonly RIG_MODE_VR: number;
  30823. /**
  30824. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  30825. */
  30826. static readonly RIG_MODE_WEBVR: number;
  30827. /**
  30828. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  30829. */
  30830. static readonly RIG_MODE_CUSTOM: number;
  30831. /**
  30832. * Defines if by default attaching controls should prevent the default javascript event to continue.
  30833. */
  30834. static ForceAttachControlToAlwaysPreventDefault: boolean;
  30835. /**
  30836. * Define the input manager associated with the camera.
  30837. */
  30838. inputs: CameraInputsManager<Camera>;
  30839. /** @hidden */
  30840. _position: Vector3;
  30841. /**
  30842. * Define the current local position of the camera in the scene
  30843. */
  30844. position: Vector3;
  30845. /**
  30846. * The vector the camera should consider as up.
  30847. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  30848. */
  30849. upVector: Vector3;
  30850. /**
  30851. * Define the current limit on the left side for an orthographic camera
  30852. * In scene unit
  30853. */
  30854. orthoLeft: Nullable<number>;
  30855. /**
  30856. * Define the current limit on the right side for an orthographic camera
  30857. * In scene unit
  30858. */
  30859. orthoRight: Nullable<number>;
  30860. /**
  30861. * Define the current limit on the bottom side for an orthographic camera
  30862. * In scene unit
  30863. */
  30864. orthoBottom: Nullable<number>;
  30865. /**
  30866. * Define the current limit on the top side for an orthographic camera
  30867. * In scene unit
  30868. */
  30869. orthoTop: Nullable<number>;
  30870. /**
  30871. * Field Of View is set in Radians. (default is 0.8)
  30872. */
  30873. fov: number;
  30874. /**
  30875. * Define the minimum distance the camera can see from.
  30876. * This is important to note that the depth buffer are not infinite and the closer it starts
  30877. * the more your scene might encounter depth fighting issue.
  30878. */
  30879. minZ: number;
  30880. /**
  30881. * Define the maximum distance the camera can see to.
  30882. * This is important to note that the depth buffer are not infinite and the further it end
  30883. * the more your scene might encounter depth fighting issue.
  30884. */
  30885. maxZ: number;
  30886. /**
  30887. * Define the default inertia of the camera.
  30888. * This helps giving a smooth feeling to the camera movement.
  30889. */
  30890. inertia: number;
  30891. /**
  30892. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.PERSPECTIVE_ORTHOGRAPHIC)
  30893. */
  30894. mode: number;
  30895. /**
  30896. * Define wether the camera is intermediate.
  30897. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  30898. */
  30899. isIntermediate: boolean;
  30900. /**
  30901. * Define the viewport of the camera.
  30902. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  30903. */
  30904. viewport: Viewport;
  30905. /**
  30906. * Restricts the camera to viewing objects with the same layerMask.
  30907. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  30908. */
  30909. layerMask: number;
  30910. /**
  30911. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  30912. */
  30913. fovMode: number;
  30914. /**
  30915. * Rig mode of the camera.
  30916. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  30917. * This is normally controlled byt the camera themselves as internal use.
  30918. */
  30919. cameraRigMode: number;
  30920. /**
  30921. * Defines the distance between both "eyes" in case of a RIG
  30922. */
  30923. interaxialDistance: number;
  30924. /**
  30925. * Defines if stereoscopic rendering is done side by side or over under.
  30926. */
  30927. isStereoscopicSideBySide: boolean;
  30928. /**
  30929. * 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
  30930. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  30931. * else in the scene.
  30932. */
  30933. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  30934. /**
  30935. * When set, the camera will render to this render target instead of the default canvas
  30936. */
  30937. outputRenderTarget: Nullable<RenderTargetTexture>;
  30938. /**
  30939. * Observable triggered when the camera view matrix has changed.
  30940. */
  30941. onViewMatrixChangedObservable: Observable<Camera>;
  30942. /**
  30943. * Observable triggered when the camera Projection matrix has changed.
  30944. */
  30945. onProjectionMatrixChangedObservable: Observable<Camera>;
  30946. /**
  30947. * Observable triggered when the inputs have been processed.
  30948. */
  30949. onAfterCheckInputsObservable: Observable<Camera>;
  30950. /**
  30951. * Observable triggered when reset has been called and applied to the camera.
  30952. */
  30953. onRestoreStateObservable: Observable<Camera>;
  30954. /** @hidden */
  30955. _cameraRigParams: any;
  30956. /** @hidden */
  30957. _rigCameras: Camera[];
  30958. /** @hidden */
  30959. _rigPostProcess: Nullable<PostProcess>;
  30960. protected _webvrViewMatrix: Matrix;
  30961. /** @hidden */
  30962. _skipRendering: boolean;
  30963. /** @hidden */
  30964. _projectionMatrix: Matrix;
  30965. /** @hidden */
  30966. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  30967. /** @hidden */
  30968. _activeMeshes: SmartArray<AbstractMesh>;
  30969. protected _globalPosition: Vector3;
  30970. /** hidden */
  30971. _computedViewMatrix: Matrix;
  30972. private _doNotComputeProjectionMatrix;
  30973. private _transformMatrix;
  30974. private _frustumPlanes;
  30975. private _refreshFrustumPlanes;
  30976. private _storedFov;
  30977. private _stateStored;
  30978. /**
  30979. * Instantiates a new camera object.
  30980. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  30981. * @see http://doc.babylonjs.com/features/cameras
  30982. * @param name Defines the name of the camera in the scene
  30983. * @param position Defines the position of the camera
  30984. * @param scene Defines the scene the camera belongs too
  30985. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  30986. */
  30987. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  30988. /**
  30989. * Store current camera state (fov, position, etc..)
  30990. * @returns the camera
  30991. */
  30992. storeState(): Camera;
  30993. /**
  30994. * Restores the camera state values if it has been stored. You must call storeState() first
  30995. */
  30996. protected _restoreStateValues(): boolean;
  30997. /**
  30998. * Restored camera state. You must call storeState() first.
  30999. * @returns true if restored and false otherwise
  31000. */
  31001. restoreState(): boolean;
  31002. /**
  31003. * Gets the class name of the camera.
  31004. * @returns the class name
  31005. */
  31006. getClassName(): string;
  31007. /** @hidden */
  31008. readonly _isCamera: boolean;
  31009. /**
  31010. * Gets a string representation of the camera useful for debug purpose.
  31011. * @param fullDetails Defines that a more verboe level of logging is required
  31012. * @returns the string representation
  31013. */
  31014. toString(fullDetails?: boolean): string;
  31015. /**
  31016. * Gets the current world space position of the camera.
  31017. */
  31018. readonly globalPosition: Vector3;
  31019. /**
  31020. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  31021. * @returns the active meshe list
  31022. */
  31023. getActiveMeshes(): SmartArray<AbstractMesh>;
  31024. /**
  31025. * Check wether a mesh is part of the current active mesh list of the camera
  31026. * @param mesh Defines the mesh to check
  31027. * @returns true if active, false otherwise
  31028. */
  31029. isActiveMesh(mesh: Mesh): boolean;
  31030. /**
  31031. * Is this camera ready to be used/rendered
  31032. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  31033. * @return true if the camera is ready
  31034. */
  31035. isReady(completeCheck?: boolean): boolean;
  31036. /** @hidden */
  31037. _initCache(): void;
  31038. /** @hidden */
  31039. _updateCache(ignoreParentClass?: boolean): void;
  31040. /** @hidden */
  31041. _isSynchronized(): boolean;
  31042. /** @hidden */
  31043. _isSynchronizedViewMatrix(): boolean;
  31044. /** @hidden */
  31045. _isSynchronizedProjectionMatrix(): boolean;
  31046. /**
  31047. * Attach the input controls to a specific dom element to get the input from.
  31048. * @param element Defines the element the controls should be listened from
  31049. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  31050. */
  31051. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  31052. /**
  31053. * Detach the current controls from the specified dom element.
  31054. * @param element Defines the element to stop listening the inputs from
  31055. */
  31056. detachControl(element: HTMLElement): void;
  31057. /**
  31058. * Update the camera state according to the different inputs gathered during the frame.
  31059. */
  31060. update(): void;
  31061. /** @hidden */
  31062. _checkInputs(): void;
  31063. /** @hidden */
  31064. readonly rigCameras: Camera[];
  31065. /**
  31066. * Gets the post process used by the rig cameras
  31067. */
  31068. readonly rigPostProcess: Nullable<PostProcess>;
  31069. /**
  31070. * Internal, gets the first post proces.
  31071. * @returns the first post process to be run on this camera.
  31072. */
  31073. _getFirstPostProcess(): Nullable<PostProcess>;
  31074. private _cascadePostProcessesToRigCams;
  31075. /**
  31076. * Attach a post process to the camera.
  31077. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  31078. * @param postProcess The post process to attach to the camera
  31079. * @param insertAt The position of the post process in case several of them are in use in the scene
  31080. * @returns the position the post process has been inserted at
  31081. */
  31082. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  31083. /**
  31084. * Detach a post process to the camera.
  31085. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  31086. * @param postProcess The post process to detach from the camera
  31087. */
  31088. detachPostProcess(postProcess: PostProcess): void;
  31089. /**
  31090. * Gets the current world matrix of the camera
  31091. */
  31092. getWorldMatrix(): Matrix;
  31093. /** @hidden */
  31094. _getViewMatrix(): Matrix;
  31095. /**
  31096. * Gets the current view matrix of the camera.
  31097. * @param force forces the camera to recompute the matrix without looking at the cached state
  31098. * @returns the view matrix
  31099. */
  31100. getViewMatrix(force?: boolean): Matrix;
  31101. /**
  31102. * Freeze the projection matrix.
  31103. * It will prevent the cache check of the camera projection compute and can speed up perf
  31104. * if no parameter of the camera are meant to change
  31105. * @param projection Defines manually a projection if necessary
  31106. */
  31107. freezeProjectionMatrix(projection?: Matrix): void;
  31108. /**
  31109. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  31110. */
  31111. unfreezeProjectionMatrix(): void;
  31112. /**
  31113. * Gets the current projection matrix of the camera.
  31114. * @param force forces the camera to recompute the matrix without looking at the cached state
  31115. * @returns the projection matrix
  31116. */
  31117. getProjectionMatrix(force?: boolean): Matrix;
  31118. /**
  31119. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  31120. * @returns a Matrix
  31121. */
  31122. getTransformationMatrix(): Matrix;
  31123. private _updateFrustumPlanes;
  31124. /**
  31125. * Checks if a cullable object (mesh...) is in the camera frustum
  31126. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  31127. * @param target The object to check
  31128. * @returns true if the object is in frustum otherwise false
  31129. */
  31130. isInFrustum(target: ICullable): boolean;
  31131. /**
  31132. * Checks if a cullable object (mesh...) is in the camera frustum
  31133. * Unlike isInFrustum this cheks the full bounding box
  31134. * @param target The object to check
  31135. * @returns true if the object is in frustum otherwise false
  31136. */
  31137. isCompletelyInFrustum(target: ICullable): boolean;
  31138. /**
  31139. * Gets a ray in the forward direction from the camera.
  31140. * @param length Defines the length of the ray to create
  31141. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  31142. * @param origin Defines the start point of the ray which defaults to the camera position
  31143. * @returns the forward ray
  31144. */
  31145. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  31146. /**
  31147. * Releases resources associated with this node.
  31148. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  31149. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  31150. */
  31151. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  31152. /** @hidden */
  31153. _isLeftCamera: boolean;
  31154. /**
  31155. * Gets the left camera of a rig setup in case of Rigged Camera
  31156. */
  31157. readonly isLeftCamera: boolean;
  31158. /** @hidden */
  31159. _isRightCamera: boolean;
  31160. /**
  31161. * Gets the right camera of a rig setup in case of Rigged Camera
  31162. */
  31163. readonly isRightCamera: boolean;
  31164. /**
  31165. * Gets the left camera of a rig setup in case of Rigged Camera
  31166. */
  31167. readonly leftCamera: Nullable<FreeCamera>;
  31168. /**
  31169. * Gets the right camera of a rig setup in case of Rigged Camera
  31170. */
  31171. readonly rightCamera: Nullable<FreeCamera>;
  31172. /**
  31173. * Gets the left camera target of a rig setup in case of Rigged Camera
  31174. * @returns the target position
  31175. */
  31176. getLeftTarget(): Nullable<Vector3>;
  31177. /**
  31178. * Gets the right camera target of a rig setup in case of Rigged Camera
  31179. * @returns the target position
  31180. */
  31181. getRightTarget(): Nullable<Vector3>;
  31182. /**
  31183. * @hidden
  31184. */
  31185. setCameraRigMode(mode: number, rigParams: any): void;
  31186. /** @hidden */
  31187. static _setStereoscopicRigMode(camera: Camera): void;
  31188. /** @hidden */
  31189. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  31190. /** @hidden */
  31191. static _setVRRigMode(camera: Camera, rigParams: any): void;
  31192. /** @hidden */
  31193. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  31194. /** @hidden */
  31195. _getVRProjectionMatrix(): Matrix;
  31196. protected _updateCameraRotationMatrix(): void;
  31197. protected _updateWebVRCameraRotationMatrix(): void;
  31198. /**
  31199. * This function MUST be overwritten by the different WebVR cameras available.
  31200. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  31201. * @hidden
  31202. */
  31203. _getWebVRProjectionMatrix(): Matrix;
  31204. /**
  31205. * This function MUST be overwritten by the different WebVR cameras available.
  31206. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  31207. * @hidden
  31208. */
  31209. _getWebVRViewMatrix(): Matrix;
  31210. /** @hidden */
  31211. setCameraRigParameter(name: string, value: any): void;
  31212. /**
  31213. * needs to be overridden by children so sub has required properties to be copied
  31214. * @hidden
  31215. */
  31216. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  31217. /**
  31218. * May need to be overridden by children
  31219. * @hidden
  31220. */
  31221. _updateRigCameras(): void;
  31222. /** @hidden */
  31223. _setupInputs(): void;
  31224. /**
  31225. * Serialiaze the camera setup to a json represention
  31226. * @returns the JSON representation
  31227. */
  31228. serialize(): any;
  31229. /**
  31230. * Clones the current camera.
  31231. * @param name The cloned camera name
  31232. * @returns the cloned camera
  31233. */
  31234. clone(name: string): Camera;
  31235. /**
  31236. * Gets the direction of the camera relative to a given local axis.
  31237. * @param localAxis Defines the reference axis to provide a relative direction.
  31238. * @return the direction
  31239. */
  31240. getDirection(localAxis: Vector3): Vector3;
  31241. /**
  31242. * Gets the direction of the camera relative to a given local axis into a passed vector.
  31243. * @param localAxis Defines the reference axis to provide a relative direction.
  31244. * @param result Defines the vector to store the result in
  31245. */
  31246. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  31247. /**
  31248. * Gets a camera constructor for a given camera type
  31249. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  31250. * @param name The name of the camera the result will be able to instantiate
  31251. * @param scene The scene the result will construct the camera in
  31252. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  31253. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  31254. * @returns a factory method to construc the camera
  31255. */
  31256. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  31257. /**
  31258. * Compute the world matrix of the camera.
  31259. * @returns the camera workd matrix
  31260. */
  31261. computeWorldMatrix(): Matrix;
  31262. /**
  31263. * Parse a JSON and creates the camera from the parsed information
  31264. * @param parsedCamera The JSON to parse
  31265. * @param scene The scene to instantiate the camera in
  31266. * @returns the newly constructed camera
  31267. */
  31268. static Parse(parsedCamera: any, scene: Scene): Camera;
  31269. }
  31270. }
  31271. declare module "babylonjs/Misc/tools" {
  31272. import { FloatArray, IndicesArray, Nullable } from "babylonjs/types";
  31273. import { Color4, Color3, Vector2, Vector3 } from "babylonjs/Maths/math";
  31274. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  31275. import { Observable } from "babylonjs/Misc/observable";
  31276. import { DomManagement } from "babylonjs/Misc/domManagement";
  31277. import { WebRequest } from "babylonjs/Misc/webRequest";
  31278. import { Camera } from "babylonjs/Cameras/camera";
  31279. import { Engine } from "babylonjs/Engines/engine";
  31280. import { Animation } from "babylonjs/Animations/animation";
  31281. /**
  31282. * Interface for any object that can request an animation frame
  31283. */
  31284. export interface ICustomAnimationFrameRequester {
  31285. /**
  31286. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  31287. */
  31288. renderFunction?: Function;
  31289. /**
  31290. * Called to request the next frame to render to
  31291. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  31292. */
  31293. requestAnimationFrame: Function;
  31294. /**
  31295. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  31296. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  31297. */
  31298. requestID?: number;
  31299. }
  31300. /**
  31301. * Interface containing an array of animations
  31302. */
  31303. export interface IAnimatable {
  31304. /**
  31305. * Array of animations
  31306. */
  31307. animations: Array<Animation>;
  31308. }
  31309. /** Interface used by value gradients (color, factor, ...) */
  31310. export interface IValueGradient {
  31311. /**
  31312. * Gets or sets the gradient value (between 0 and 1)
  31313. */
  31314. gradient: number;
  31315. }
  31316. /** Class used to store color4 gradient */
  31317. export class ColorGradient implements IValueGradient {
  31318. /**
  31319. * Gets or sets the gradient value (between 0 and 1)
  31320. */
  31321. gradient: number;
  31322. /**
  31323. * Gets or sets first associated color
  31324. */
  31325. color1: Color4;
  31326. /**
  31327. * Gets or sets second associated color
  31328. */
  31329. color2?: Color4;
  31330. /**
  31331. * Will get a color picked randomly between color1 and color2.
  31332. * If color2 is undefined then color1 will be used
  31333. * @param result defines the target Color4 to store the result in
  31334. */
  31335. getColorToRef(result: Color4): void;
  31336. }
  31337. /** Class used to store color 3 gradient */
  31338. export class Color3Gradient implements IValueGradient {
  31339. /**
  31340. * Gets or sets the gradient value (between 0 and 1)
  31341. */
  31342. gradient: number;
  31343. /**
  31344. * Gets or sets the associated color
  31345. */
  31346. color: Color3;
  31347. }
  31348. /** Class used to store factor gradient */
  31349. export class FactorGradient implements IValueGradient {
  31350. /**
  31351. * Gets or sets the gradient value (between 0 and 1)
  31352. */
  31353. gradient: number;
  31354. /**
  31355. * Gets or sets first associated factor
  31356. */
  31357. factor1: number;
  31358. /**
  31359. * Gets or sets second associated factor
  31360. */
  31361. factor2?: number;
  31362. /**
  31363. * Will get a number picked randomly between factor1 and factor2.
  31364. * If factor2 is undefined then factor1 will be used
  31365. * @returns the picked number
  31366. */
  31367. getFactor(): number;
  31368. }
  31369. /**
  31370. * @ignore
  31371. * Application error to support additional information when loading a file
  31372. */
  31373. export class LoadFileError extends Error {
  31374. /** defines the optional web request */
  31375. request?: WebRequest | undefined;
  31376. private static _setPrototypeOf;
  31377. /**
  31378. * Creates a new LoadFileError
  31379. * @param message defines the message of the error
  31380. * @param request defines the optional web request
  31381. */
  31382. constructor(message: string,
  31383. /** defines the optional web request */
  31384. request?: WebRequest | undefined);
  31385. }
  31386. /**
  31387. * Class used to define a retry strategy when error happens while loading assets
  31388. */
  31389. export class RetryStrategy {
  31390. /**
  31391. * Function used to defines an exponential back off strategy
  31392. * @param maxRetries defines the maximum number of retries (3 by default)
  31393. * @param baseInterval defines the interval between retries
  31394. * @returns the strategy function to use
  31395. */
  31396. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  31397. }
  31398. /**
  31399. * File request interface
  31400. */
  31401. export interface IFileRequest {
  31402. /**
  31403. * Raised when the request is complete (success or error).
  31404. */
  31405. onCompleteObservable: Observable<IFileRequest>;
  31406. /**
  31407. * Aborts the request for a file.
  31408. */
  31409. abort: () => void;
  31410. }
  31411. /**
  31412. * Class containing a set of static utilities functions
  31413. */
  31414. export class Tools {
  31415. /**
  31416. * Gets or sets the base URL to use to load assets
  31417. */
  31418. static BaseUrl: string;
  31419. /**
  31420. * Enable/Disable Custom HTTP Request Headers globally.
  31421. * default = false
  31422. * @see CustomRequestHeaders
  31423. */
  31424. static UseCustomRequestHeaders: boolean;
  31425. /**
  31426. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  31427. * i.e. when loading files, where the server/service expects an Authorization header
  31428. */
  31429. static CustomRequestHeaders: {
  31430. [key: string]: string;
  31431. };
  31432. /**
  31433. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  31434. */
  31435. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  31436. /**
  31437. * Default behaviour for cors in the application.
  31438. * It can be a string if the expected behavior is identical in the entire app.
  31439. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  31440. */
  31441. static CorsBehavior: string | ((url: string | string[]) => string);
  31442. /**
  31443. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  31444. * @ignorenaming
  31445. */
  31446. static UseFallbackTexture: boolean;
  31447. /**
  31448. * Use this object to register external classes like custom textures or material
  31449. * to allow the laoders to instantiate them
  31450. */
  31451. static RegisteredExternalClasses: {
  31452. [key: string]: Object;
  31453. };
  31454. /**
  31455. * Texture content used if a texture cannot loaded
  31456. * @ignorenaming
  31457. */
  31458. static fallbackTexture: string;
  31459. /**
  31460. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  31461. * @param u defines the coordinate on X axis
  31462. * @param v defines the coordinate on Y axis
  31463. * @param width defines the width of the source data
  31464. * @param height defines the height of the source data
  31465. * @param pixels defines the source byte array
  31466. * @param color defines the output color
  31467. */
  31468. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  31469. /**
  31470. * Interpolates between a and b via alpha
  31471. * @param a The lower value (returned when alpha = 0)
  31472. * @param b The upper value (returned when alpha = 1)
  31473. * @param alpha The interpolation-factor
  31474. * @return The mixed value
  31475. */
  31476. static Mix(a: number, b: number, alpha: number): number;
  31477. /**
  31478. * Tries to instantiate a new object from a given class name
  31479. * @param className defines the class name to instantiate
  31480. * @returns the new object or null if the system was not able to do the instantiation
  31481. */
  31482. static Instantiate(className: string): any;
  31483. /**
  31484. * Provides a slice function that will work even on IE
  31485. * @param data defines the array to slice
  31486. * @param start defines the start of the data (optional)
  31487. * @param end defines the end of the data (optional)
  31488. * @returns the new sliced array
  31489. */
  31490. static Slice<T>(data: T, start?: number, end?: number): T;
  31491. /**
  31492. * Polyfill for setImmediate
  31493. * @param action defines the action to execute after the current execution block
  31494. */
  31495. static SetImmediate(action: () => void): void;
  31496. /**
  31497. * Function indicating if a number is an exponent of 2
  31498. * @param value defines the value to test
  31499. * @returns true if the value is an exponent of 2
  31500. */
  31501. static IsExponentOfTwo(value: number): boolean;
  31502. private static _tmpFloatArray;
  31503. /**
  31504. * Returns the nearest 32-bit single precision float representation of a Number
  31505. * @param value A Number. If the parameter is of a different type, it will get converted
  31506. * to a number or to NaN if it cannot be converted
  31507. * @returns number
  31508. */
  31509. static FloatRound(value: number): number;
  31510. /**
  31511. * Find the next highest power of two.
  31512. * @param x Number to start search from.
  31513. * @return Next highest power of two.
  31514. */
  31515. static CeilingPOT(x: number): number;
  31516. /**
  31517. * Find the next lowest power of two.
  31518. * @param x Number to start search from.
  31519. * @return Next lowest power of two.
  31520. */
  31521. static FloorPOT(x: number): number;
  31522. /**
  31523. * Find the nearest power of two.
  31524. * @param x Number to start search from.
  31525. * @return Next nearest power of two.
  31526. */
  31527. static NearestPOT(x: number): number;
  31528. /**
  31529. * Get the closest exponent of two
  31530. * @param value defines the value to approximate
  31531. * @param max defines the maximum value to return
  31532. * @param mode defines how to define the closest value
  31533. * @returns closest exponent of two of the given value
  31534. */
  31535. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  31536. /**
  31537. * Extracts the filename from a path
  31538. * @param path defines the path to use
  31539. * @returns the filename
  31540. */
  31541. static GetFilename(path: string): string;
  31542. /**
  31543. * Extracts the "folder" part of a path (everything before the filename).
  31544. * @param uri The URI to extract the info from
  31545. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  31546. * @returns The "folder" part of the path
  31547. */
  31548. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  31549. /**
  31550. * Extracts text content from a DOM element hierarchy
  31551. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  31552. */
  31553. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  31554. /**
  31555. * Convert an angle in radians to degrees
  31556. * @param angle defines the angle to convert
  31557. * @returns the angle in degrees
  31558. */
  31559. static ToDegrees(angle: number): number;
  31560. /**
  31561. * Convert an angle in degrees to radians
  31562. * @param angle defines the angle to convert
  31563. * @returns the angle in radians
  31564. */
  31565. static ToRadians(angle: number): number;
  31566. /**
  31567. * Encode a buffer to a base64 string
  31568. * @param buffer defines the buffer to encode
  31569. * @returns the encoded string
  31570. */
  31571. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  31572. /**
  31573. * Extracts minimum and maximum values from a list of indexed positions
  31574. * @param positions defines the positions to use
  31575. * @param indices defines the indices to the positions
  31576. * @param indexStart defines the start index
  31577. * @param indexCount defines the end index
  31578. * @param bias defines bias value to add to the result
  31579. * @return minimum and maximum values
  31580. */
  31581. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  31582. minimum: Vector3;
  31583. maximum: Vector3;
  31584. };
  31585. /**
  31586. * Extracts minimum and maximum values from a list of positions
  31587. * @param positions defines the positions to use
  31588. * @param start defines the start index in the positions array
  31589. * @param count defines the number of positions to handle
  31590. * @param bias defines bias value to add to the result
  31591. * @param stride defines the stride size to use (distance between two positions in the positions array)
  31592. * @return minimum and maximum values
  31593. */
  31594. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  31595. minimum: Vector3;
  31596. maximum: Vector3;
  31597. };
  31598. /**
  31599. * Returns an array if obj is not an array
  31600. * @param obj defines the object to evaluate as an array
  31601. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  31602. * @returns either obj directly if obj is an array or a new array containing obj
  31603. */
  31604. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  31605. /**
  31606. * Gets the pointer prefix to use
  31607. * @returns "pointer" if touch is enabled. Else returns "mouse"
  31608. */
  31609. static GetPointerPrefix(): string;
  31610. /**
  31611. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  31612. * @param func - the function to be called
  31613. * @param requester - the object that will request the next frame. Falls back to window.
  31614. * @returns frame number
  31615. */
  31616. static QueueNewFrame(func: () => void, requester?: any): number;
  31617. /**
  31618. * Ask the browser to promote the current element to fullscreen rendering mode
  31619. * @param element defines the DOM element to promote
  31620. */
  31621. static RequestFullscreen(element: HTMLElement): void;
  31622. /**
  31623. * Asks the browser to exit fullscreen mode
  31624. */
  31625. static ExitFullscreen(): void;
  31626. /**
  31627. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  31628. * @param url define the url we are trying
  31629. * @param element define the dom element where to configure the cors policy
  31630. */
  31631. static SetCorsBehavior(url: string | string[], element: {
  31632. crossOrigin: string | null;
  31633. }): void;
  31634. /**
  31635. * Removes unwanted characters from an url
  31636. * @param url defines the url to clean
  31637. * @returns the cleaned url
  31638. */
  31639. static CleanUrl(url: string): string;
  31640. /**
  31641. * Gets or sets a function used to pre-process url before using them to load assets
  31642. */
  31643. static PreprocessUrl: (url: string) => string;
  31644. /**
  31645. * Loads an image as an HTMLImageElement.
  31646. * @param input url string, ArrayBuffer, or Blob to load
  31647. * @param onLoad callback called when the image successfully loads
  31648. * @param onError callback called when the image fails to load
  31649. * @param offlineProvider offline provider for caching
  31650. * @returns the HTMLImageElement of the loaded image
  31651. */
  31652. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  31653. /**
  31654. * Loads a file
  31655. * @param url url string, ArrayBuffer, or Blob to load
  31656. * @param onSuccess callback called when the file successfully loads
  31657. * @param onProgress callback called while file is loading (if the server supports this mode)
  31658. * @param offlineProvider defines the offline provider for caching
  31659. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  31660. * @param onError callback called when the file fails to load
  31661. * @returns a file request object
  31662. */
  31663. 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;
  31664. /**
  31665. * Load a script (identified by an url). When the url returns, the
  31666. * content of this file is added into a new script element, attached to the DOM (body element)
  31667. * @param scriptUrl defines the url of the script to laod
  31668. * @param onSuccess defines the callback called when the script is loaded
  31669. * @param onError defines the callback to call if an error occurs
  31670. * @param scriptId defines the id of the script element
  31671. */
  31672. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  31673. /**
  31674. * Load an asynchronous script (identified by an url). When the url returns, the
  31675. * content of this file is added into a new script element, attached to the DOM (body element)
  31676. * @param scriptUrl defines the url of the script to laod
  31677. * @param scriptId defines the id of the script element
  31678. * @returns a promise request object
  31679. */
  31680. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Nullable<Promise<boolean>>;
  31681. /**
  31682. * Loads a file from a blob
  31683. * @param fileToLoad defines the blob to use
  31684. * @param callback defines the callback to call when data is loaded
  31685. * @param progressCallback defines the callback to call during loading process
  31686. * @returns a file request object
  31687. */
  31688. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  31689. /**
  31690. * Loads a file
  31691. * @param fileToLoad defines the file to load
  31692. * @param callback defines the callback to call when data is loaded
  31693. * @param progressCallBack defines the callback to call during loading process
  31694. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  31695. * @returns a file request object
  31696. */
  31697. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  31698. /**
  31699. * Creates a data url from a given string content
  31700. * @param content defines the content to convert
  31701. * @returns the new data url link
  31702. */
  31703. static FileAsURL(content: string): string;
  31704. /**
  31705. * Format the given number to a specific decimal format
  31706. * @param value defines the number to format
  31707. * @param decimals defines the number of decimals to use
  31708. * @returns the formatted string
  31709. */
  31710. static Format(value: number, decimals?: number): string;
  31711. /**
  31712. * Checks if a given vector is inside a specific range
  31713. * @param v defines the vector to test
  31714. * @param min defines the minimum range
  31715. * @param max defines the maximum range
  31716. */
  31717. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  31718. /**
  31719. * Tries to copy an object by duplicating every property
  31720. * @param source defines the source object
  31721. * @param destination defines the target object
  31722. * @param doNotCopyList defines a list of properties to avoid
  31723. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  31724. */
  31725. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  31726. /**
  31727. * Gets a boolean indicating if the given object has no own property
  31728. * @param obj defines the object to test
  31729. * @returns true if object has no own property
  31730. */
  31731. static IsEmpty(obj: any): boolean;
  31732. /**
  31733. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  31734. * @param str Source string
  31735. * @param suffix Suffix to search for in the source string
  31736. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  31737. */
  31738. static EndsWith(str: string, suffix: string): boolean;
  31739. /**
  31740. * Function used to register events at window level
  31741. * @param events defines the events to register
  31742. */
  31743. static RegisterTopRootEvents(events: {
  31744. name: string;
  31745. handler: Nullable<(e: FocusEvent) => any>;
  31746. }[]): void;
  31747. /**
  31748. * Function used to unregister events from window level
  31749. * @param events defines the events to unregister
  31750. */
  31751. static UnregisterTopRootEvents(events: {
  31752. name: string;
  31753. handler: Nullable<(e: FocusEvent) => any>;
  31754. }[]): void;
  31755. /**
  31756. * @ignore
  31757. */
  31758. static _ScreenshotCanvas: HTMLCanvasElement;
  31759. /**
  31760. * Dumps the current bound framebuffer
  31761. * @param width defines the rendering width
  31762. * @param height defines the rendering height
  31763. * @param engine defines the hosting engine
  31764. * @param successCallback defines the callback triggered once the data are available
  31765. * @param mimeType defines the mime type of the result
  31766. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  31767. */
  31768. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  31769. /**
  31770. * Converts the canvas data to blob.
  31771. * This acts as a polyfill for browsers not supporting the to blob function.
  31772. * @param canvas Defines the canvas to extract the data from
  31773. * @param successCallback Defines the callback triggered once the data are available
  31774. * @param mimeType Defines the mime type of the result
  31775. */
  31776. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  31777. /**
  31778. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  31779. * @param successCallback defines the callback triggered once the data are available
  31780. * @param mimeType defines the mime type of the result
  31781. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  31782. */
  31783. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  31784. /**
  31785. * Downloads a blob in the browser
  31786. * @param blob defines the blob to download
  31787. * @param fileName defines the name of the downloaded file
  31788. */
  31789. static Download(blob: Blob, fileName: string): void;
  31790. /**
  31791. * Captures a screenshot of the current rendering
  31792. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  31793. * @param engine defines the rendering engine
  31794. * @param camera defines the source camera
  31795. * @param size This parameter can be set to a single number or to an object with the
  31796. * following (optional) properties: precision, width, height. If a single number is passed,
  31797. * it will be used for both width and height. If an object is passed, the screenshot size
  31798. * will be derived from the parameters. The precision property is a multiplier allowing
  31799. * rendering at a higher or lower resolution
  31800. * @param successCallback defines the callback receives a single parameter which contains the
  31801. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  31802. * src parameter of an <img> to display it
  31803. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  31804. * Check your browser for supported MIME types
  31805. */
  31806. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  31807. /**
  31808. * Generates an image screenshot from the specified camera.
  31809. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  31810. * @param engine The engine to use for rendering
  31811. * @param camera The camera to use for rendering
  31812. * @param size This parameter can be set to a single number or to an object with the
  31813. * following (optional) properties: precision, width, height. If a single number is passed,
  31814. * it will be used for both width and height. If an object is passed, the screenshot size
  31815. * will be derived from the parameters. The precision property is a multiplier allowing
  31816. * rendering at a higher or lower resolution
  31817. * @param successCallback The callback receives a single parameter which contains the
  31818. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  31819. * src parameter of an <img> to display it
  31820. * @param mimeType The MIME type of the screenshot image (default: image/png).
  31821. * Check your browser for supported MIME types
  31822. * @param samples Texture samples (default: 1)
  31823. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  31824. * @param fileName A name for for the downloaded file.
  31825. */
  31826. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  31827. /**
  31828. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  31829. * Be aware Math.random() could cause collisions, but:
  31830. * "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"
  31831. * @returns a pseudo random id
  31832. */
  31833. static RandomId(): string;
  31834. /**
  31835. * Test if the given uri is a base64 string
  31836. * @param uri The uri to test
  31837. * @return True if the uri is a base64 string or false otherwise
  31838. */
  31839. static IsBase64(uri: string): boolean;
  31840. /**
  31841. * Decode the given base64 uri.
  31842. * @param uri The uri to decode
  31843. * @return The decoded base64 data.
  31844. */
  31845. static DecodeBase64(uri: string): ArrayBuffer;
  31846. /**
  31847. * Gets the absolute url.
  31848. * @param url the input url
  31849. * @return the absolute url
  31850. */
  31851. static GetAbsoluteUrl(url: string): string;
  31852. /**
  31853. * No log
  31854. */
  31855. static readonly NoneLogLevel: number;
  31856. /**
  31857. * Only message logs
  31858. */
  31859. static readonly MessageLogLevel: number;
  31860. /**
  31861. * Only warning logs
  31862. */
  31863. static readonly WarningLogLevel: number;
  31864. /**
  31865. * Only error logs
  31866. */
  31867. static readonly ErrorLogLevel: number;
  31868. /**
  31869. * All logs
  31870. */
  31871. static readonly AllLogLevel: number;
  31872. /**
  31873. * Gets a value indicating the number of loading errors
  31874. * @ignorenaming
  31875. */
  31876. static readonly errorsCount: number;
  31877. /**
  31878. * Callback called when a new log is added
  31879. */
  31880. static OnNewCacheEntry: (entry: string) => void;
  31881. /**
  31882. * Log a message to the console
  31883. * @param message defines the message to log
  31884. */
  31885. static Log(message: string): void;
  31886. /**
  31887. * Write a warning message to the console
  31888. * @param message defines the message to log
  31889. */
  31890. static Warn(message: string): void;
  31891. /**
  31892. * Write an error message to the console
  31893. * @param message defines the message to log
  31894. */
  31895. static Error(message: string): void;
  31896. /**
  31897. * Gets current log cache (list of logs)
  31898. */
  31899. static readonly LogCache: string;
  31900. /**
  31901. * Clears the log cache
  31902. */
  31903. static ClearLogCache(): void;
  31904. /**
  31905. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  31906. */
  31907. static LogLevels: number;
  31908. /**
  31909. * Checks if the loaded document was accessed via `file:`-Protocol.
  31910. * @returns boolean
  31911. */
  31912. static IsFileURL(): boolean;
  31913. /**
  31914. * Checks if the window object exists
  31915. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  31916. */
  31917. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  31918. /**
  31919. * No performance log
  31920. */
  31921. static readonly PerformanceNoneLogLevel: number;
  31922. /**
  31923. * Use user marks to log performance
  31924. */
  31925. static readonly PerformanceUserMarkLogLevel: number;
  31926. /**
  31927. * Log performance to the console
  31928. */
  31929. static readonly PerformanceConsoleLogLevel: number;
  31930. private static _performance;
  31931. /**
  31932. * Sets the current performance log level
  31933. */
  31934. static PerformanceLogLevel: number;
  31935. private static _StartPerformanceCounterDisabled;
  31936. private static _EndPerformanceCounterDisabled;
  31937. private static _StartUserMark;
  31938. private static _EndUserMark;
  31939. private static _StartPerformanceConsole;
  31940. private static _EndPerformanceConsole;
  31941. /**
  31942. * Starts a performance counter
  31943. */
  31944. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  31945. /**
  31946. * Ends a specific performance coutner
  31947. */
  31948. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  31949. /**
  31950. * Gets either window.performance.now() if supported or Date.now() else
  31951. */
  31952. static readonly Now: number;
  31953. /**
  31954. * This method will return the name of the class used to create the instance of the given object.
  31955. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  31956. * @param object the object to get the class name from
  31957. * @param isType defines if the object is actually a type
  31958. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  31959. */
  31960. static GetClassName(object: any, isType?: boolean): string;
  31961. /**
  31962. * Gets the first element of an array satisfying a given predicate
  31963. * @param array defines the array to browse
  31964. * @param predicate defines the predicate to use
  31965. * @returns null if not found or the element
  31966. */
  31967. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  31968. /**
  31969. * This method will return the name of the full name of the class, including its owning module (if any).
  31970. * 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).
  31971. * @param object the object to get the class name from
  31972. * @param isType defines if the object is actually a type
  31973. * @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.
  31974. * @ignorenaming
  31975. */
  31976. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  31977. /**
  31978. * Returns a promise that resolves after the given amount of time.
  31979. * @param delay Number of milliseconds to delay
  31980. * @returns Promise that resolves after the given amount of time
  31981. */
  31982. static DelayAsync(delay: number): Promise<void>;
  31983. /**
  31984. * Gets the current gradient from an array of IValueGradient
  31985. * @param ratio defines the current ratio to get
  31986. * @param gradients defines the array of IValueGradient
  31987. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  31988. */
  31989. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  31990. }
  31991. /**
  31992. * This class is used to track a performance counter which is number based.
  31993. * The user has access to many properties which give statistics of different nature.
  31994. *
  31995. * The implementer can track two kinds of Performance Counter: time and count.
  31996. * 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.
  31997. * 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.
  31998. */
  31999. export class PerfCounter {
  32000. /**
  32001. * Gets or sets a global boolean to turn on and off all the counters
  32002. */
  32003. static Enabled: boolean;
  32004. /**
  32005. * Returns the smallest value ever
  32006. */
  32007. readonly min: number;
  32008. /**
  32009. * Returns the biggest value ever
  32010. */
  32011. readonly max: number;
  32012. /**
  32013. * Returns the average value since the performance counter is running
  32014. */
  32015. readonly average: number;
  32016. /**
  32017. * Returns the average value of the last second the counter was monitored
  32018. */
  32019. readonly lastSecAverage: number;
  32020. /**
  32021. * Returns the current value
  32022. */
  32023. readonly current: number;
  32024. /**
  32025. * Gets the accumulated total
  32026. */
  32027. readonly total: number;
  32028. /**
  32029. * Gets the total value count
  32030. */
  32031. readonly count: number;
  32032. /**
  32033. * Creates a new counter
  32034. */
  32035. constructor();
  32036. /**
  32037. * Call this method to start monitoring a new frame.
  32038. * 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.
  32039. */
  32040. fetchNewFrame(): void;
  32041. /**
  32042. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  32043. * @param newCount the count value to add to the monitored count
  32044. * @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.
  32045. */
  32046. addCount(newCount: number, fetchResult: boolean): void;
  32047. /**
  32048. * Start monitoring this performance counter
  32049. */
  32050. beginMonitoring(): void;
  32051. /**
  32052. * Compute the time lapsed since the previous beginMonitoring() call.
  32053. * @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
  32054. */
  32055. endMonitoring(newFrame?: boolean): void;
  32056. private _fetchResult;
  32057. private _startMonitoringTime;
  32058. private _min;
  32059. private _max;
  32060. private _average;
  32061. private _current;
  32062. private _totalValueCount;
  32063. private _totalAccumulated;
  32064. private _lastSecAverage;
  32065. private _lastSecAccumulated;
  32066. private _lastSecTime;
  32067. private _lastSecValueCount;
  32068. }
  32069. /**
  32070. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  32071. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  32072. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  32073. * @param name The name of the class, case should be preserved
  32074. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  32075. */
  32076. export function className(name: string, module?: string): (target: Object) => void;
  32077. /**
  32078. * An implementation of a loop for asynchronous functions.
  32079. */
  32080. export class AsyncLoop {
  32081. /**
  32082. * Defines the number of iterations for the loop
  32083. */
  32084. iterations: number;
  32085. /**
  32086. * Defines the current index of the loop.
  32087. */
  32088. index: number;
  32089. private _done;
  32090. private _fn;
  32091. private _successCallback;
  32092. /**
  32093. * Constructor.
  32094. * @param iterations the number of iterations.
  32095. * @param func the function to run each iteration
  32096. * @param successCallback the callback that will be called upon succesful execution
  32097. * @param offset starting offset.
  32098. */
  32099. constructor(
  32100. /**
  32101. * Defines the number of iterations for the loop
  32102. */
  32103. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  32104. /**
  32105. * Execute the next iteration. Must be called after the last iteration was finished.
  32106. */
  32107. executeNext(): void;
  32108. /**
  32109. * Break the loop and run the success callback.
  32110. */
  32111. breakLoop(): void;
  32112. /**
  32113. * Create and run an async loop.
  32114. * @param iterations the number of iterations.
  32115. * @param fn the function to run each iteration
  32116. * @param successCallback the callback that will be called upon succesful execution
  32117. * @param offset starting offset.
  32118. * @returns the created async loop object
  32119. */
  32120. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  32121. /**
  32122. * A for-loop that will run a given number of iterations synchronous and the rest async.
  32123. * @param iterations total number of iterations
  32124. * @param syncedIterations number of synchronous iterations in each async iteration.
  32125. * @param fn the function to call each iteration.
  32126. * @param callback a success call back that will be called when iterating stops.
  32127. * @param breakFunction a break condition (optional)
  32128. * @param timeout timeout settings for the setTimeout function. default - 0.
  32129. * @returns the created async loop object
  32130. */
  32131. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  32132. }
  32133. }
  32134. declare module "babylonjs/Collisions/collisionCoordinator" {
  32135. import { Nullable } from "babylonjs/types";
  32136. import { Scene } from "babylonjs/scene";
  32137. import { Vector3 } from "babylonjs/Maths/math";
  32138. import { Collider } from "babylonjs/Collisions/collider";
  32139. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  32140. /** @hidden */
  32141. export interface ICollisionCoordinator {
  32142. createCollider(): Collider;
  32143. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  32144. init(scene: Scene): void;
  32145. }
  32146. /** @hidden */
  32147. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  32148. private _scene;
  32149. private _scaledPosition;
  32150. private _scaledVelocity;
  32151. private _finalPosition;
  32152. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  32153. createCollider(): Collider;
  32154. init(scene: Scene): void;
  32155. private _collideWithWorld;
  32156. }
  32157. }
  32158. declare module "babylonjs/Animations/animationGroup" {
  32159. import { Animatable } from "babylonjs/Animations/animatable";
  32160. import { Animation } from "babylonjs/Animations/animation";
  32161. import { Scene, IDisposable } from "babylonjs/scene";
  32162. import { Observable } from "babylonjs/Misc/observable";
  32163. import { Nullable } from "babylonjs/types";
  32164. /**
  32165. * This class defines the direct association between an animation and a target
  32166. */
  32167. export class TargetedAnimation {
  32168. /**
  32169. * Animation to perform
  32170. */
  32171. animation: Animation;
  32172. /**
  32173. * Target to animate
  32174. */
  32175. target: any;
  32176. }
  32177. /**
  32178. * Use this class to create coordinated animations on multiple targets
  32179. */
  32180. export class AnimationGroup implements IDisposable {
  32181. /** The name of the animation group */
  32182. name: string;
  32183. private _scene;
  32184. private _targetedAnimations;
  32185. private _animatables;
  32186. private _from;
  32187. private _to;
  32188. private _isStarted;
  32189. private _isPaused;
  32190. private _speedRatio;
  32191. /**
  32192. * Gets or sets the unique id of the node
  32193. */
  32194. uniqueId: number;
  32195. /**
  32196. * This observable will notify when one animation have ended
  32197. */
  32198. onAnimationEndObservable: Observable<TargetedAnimation>;
  32199. /**
  32200. * Observer raised when one animation loops
  32201. */
  32202. onAnimationLoopObservable: Observable<TargetedAnimation>;
  32203. /**
  32204. * This observable will notify when all animations have ended.
  32205. */
  32206. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  32207. /**
  32208. * This observable will notify when all animations have paused.
  32209. */
  32210. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  32211. /**
  32212. * This observable will notify when all animations are playing.
  32213. */
  32214. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  32215. /**
  32216. * Gets the first frame
  32217. */
  32218. readonly from: number;
  32219. /**
  32220. * Gets the last frame
  32221. */
  32222. readonly to: number;
  32223. /**
  32224. * Define if the animations are started
  32225. */
  32226. readonly isStarted: boolean;
  32227. /**
  32228. * Gets a value indicating that the current group is playing
  32229. */
  32230. readonly isPlaying: boolean;
  32231. /**
  32232. * Gets or sets the speed ratio to use for all animations
  32233. */
  32234. /**
  32235. * Gets or sets the speed ratio to use for all animations
  32236. */
  32237. speedRatio: number;
  32238. /**
  32239. * Gets the targeted animations for this animation group
  32240. */
  32241. readonly targetedAnimations: Array<TargetedAnimation>;
  32242. /**
  32243. * returning the list of animatables controlled by this animation group.
  32244. */
  32245. readonly animatables: Array<Animatable>;
  32246. /**
  32247. * Instantiates a new Animation Group.
  32248. * This helps managing several animations at once.
  32249. * @see http://doc.babylonjs.com/how_to/group
  32250. * @param name Defines the name of the group
  32251. * @param scene Defines the scene the group belongs to
  32252. */
  32253. constructor(
  32254. /** The name of the animation group */
  32255. name: string, scene?: Nullable<Scene>);
  32256. /**
  32257. * Add an animation (with its target) in the group
  32258. * @param animation defines the animation we want to add
  32259. * @param target defines the target of the animation
  32260. * @returns the TargetedAnimation object
  32261. */
  32262. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  32263. /**
  32264. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  32265. * It can add constant keys at begin or end
  32266. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  32267. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  32268. * @returns the animation group
  32269. */
  32270. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  32271. /**
  32272. * Start all animations on given targets
  32273. * @param loop defines if animations must loop
  32274. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  32275. * @param from defines the from key (optional)
  32276. * @param to defines the to key (optional)
  32277. * @returns the current animation group
  32278. */
  32279. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  32280. /**
  32281. * Pause all animations
  32282. * @returns the animation group
  32283. */
  32284. pause(): AnimationGroup;
  32285. /**
  32286. * Play all animations to initial state
  32287. * This function will start() the animations if they were not started or will restart() them if they were paused
  32288. * @param loop defines if animations must loop
  32289. * @returns the animation group
  32290. */
  32291. play(loop?: boolean): AnimationGroup;
  32292. /**
  32293. * Reset all animations to initial state
  32294. * @returns the animation group
  32295. */
  32296. reset(): AnimationGroup;
  32297. /**
  32298. * Restart animations from key 0
  32299. * @returns the animation group
  32300. */
  32301. restart(): AnimationGroup;
  32302. /**
  32303. * Stop all animations
  32304. * @returns the animation group
  32305. */
  32306. stop(): AnimationGroup;
  32307. /**
  32308. * Set animation weight for all animatables
  32309. * @param weight defines the weight to use
  32310. * @return the animationGroup
  32311. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  32312. */
  32313. setWeightForAllAnimatables(weight: number): AnimationGroup;
  32314. /**
  32315. * Synchronize and normalize all animatables with a source animatable
  32316. * @param root defines the root animatable to synchronize with
  32317. * @return the animationGroup
  32318. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  32319. */
  32320. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  32321. /**
  32322. * Goes to a specific frame in this animation group
  32323. * @param frame the frame number to go to
  32324. * @return the animationGroup
  32325. */
  32326. goToFrame(frame: number): AnimationGroup;
  32327. /**
  32328. * Dispose all associated resources
  32329. */
  32330. dispose(): void;
  32331. private _checkAnimationGroupEnded;
  32332. /**
  32333. * Clone the current animation group and returns a copy
  32334. * @param newName defines the name of the new group
  32335. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  32336. * @returns the new aniamtion group
  32337. */
  32338. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  32339. /**
  32340. * Returns a new AnimationGroup object parsed from the source provided.
  32341. * @param parsedAnimationGroup defines the source
  32342. * @param scene defines the scene that will receive the animationGroup
  32343. * @returns a new AnimationGroup
  32344. */
  32345. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  32346. /**
  32347. * Returns the string "AnimationGroup"
  32348. * @returns "AnimationGroup"
  32349. */
  32350. getClassName(): string;
  32351. /**
  32352. * Creates a detailled string about the object
  32353. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  32354. * @returns a string representing the object
  32355. */
  32356. toString(fullDetails?: boolean): string;
  32357. }
  32358. }
  32359. declare module "babylonjs/scene" {
  32360. import { Nullable } from "babylonjs/types";
  32361. import { IAnimatable, IFileRequest, PerfCounter } from "babylonjs/Misc/tools";
  32362. import { Observable } from "babylonjs/Misc/observable";
  32363. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  32364. import { Color4, Color3, Plane, Vector2, Vector3, Matrix } from "babylonjs/Maths/math";
  32365. import { Geometry } from "babylonjs/Meshes/geometry";
  32366. import { TransformNode } from "babylonjs/Meshes/transformNode";
  32367. import { SubMesh } from "babylonjs/Meshes/subMesh";
  32368. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  32369. import { Mesh } from "babylonjs/Meshes/mesh";
  32370. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  32371. import { Bone } from "babylonjs/Bones/bone";
  32372. import { Skeleton } from "babylonjs/Bones/skeleton";
  32373. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  32374. import { Camera } from "babylonjs/Cameras/camera";
  32375. import { AbstractScene } from "babylonjs/abstractScene";
  32376. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  32377. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  32378. import { Material } from "babylonjs/Materials/material";
  32379. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  32380. import { Effect } from "babylonjs/Materials/effect";
  32381. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  32382. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  32383. import { Light } from "babylonjs/Lights/light";
  32384. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  32385. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  32386. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  32387. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  32388. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  32389. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  32390. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  32391. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  32392. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction } from "babylonjs/sceneComponent";
  32393. import { Engine } from "babylonjs/Engines/engine";
  32394. import { Node } from "babylonjs/node";
  32395. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  32396. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  32397. import { WebRequest } from "babylonjs/Misc/webRequest";
  32398. import { Ray } from "babylonjs/Culling/ray";
  32399. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  32400. import { Animation } from "babylonjs/Animations/animation";
  32401. import { Animatable } from "babylonjs/Animations/animatable";
  32402. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  32403. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  32404. import { Collider } from "babylonjs/Collisions/collider";
  32405. /**
  32406. * Define an interface for all classes that will hold resources
  32407. */
  32408. export interface IDisposable {
  32409. /**
  32410. * Releases all held resources
  32411. */
  32412. dispose(): void;
  32413. }
  32414. /** Interface defining initialization parameters for Scene class */
  32415. export interface SceneOptions {
  32416. /**
  32417. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  32418. * It will improve performance when the number of geometries becomes important.
  32419. */
  32420. useGeometryUniqueIdsMap?: boolean;
  32421. /**
  32422. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  32423. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  32424. */
  32425. useMaterialMeshMap?: boolean;
  32426. /**
  32427. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  32428. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  32429. */
  32430. useClonedMeshhMap?: boolean;
  32431. }
  32432. /**
  32433. * Represents a scene to be rendered by the engine.
  32434. * @see http://doc.babylonjs.com/features/scene
  32435. */
  32436. export class Scene extends AbstractScene implements IAnimatable {
  32437. private static _uniqueIdCounter;
  32438. /** The fog is deactivated */
  32439. static readonly FOGMODE_NONE: number;
  32440. /** The fog density is following an exponential function */
  32441. static readonly FOGMODE_EXP: number;
  32442. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  32443. static readonly FOGMODE_EXP2: number;
  32444. /** The fog density is following a linear function. */
  32445. static readonly FOGMODE_LINEAR: number;
  32446. /**
  32447. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  32448. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32449. */
  32450. static MinDeltaTime: number;
  32451. /**
  32452. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  32453. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32454. */
  32455. static MaxDeltaTime: number;
  32456. /**
  32457. * Factory used to create the default material.
  32458. * @param name The name of the material to create
  32459. * @param scene The scene to create the material for
  32460. * @returns The default material
  32461. */
  32462. static DefaultMaterialFactory(scene: Scene): Material;
  32463. /**
  32464. * Factory used to create the a collision coordinator.
  32465. * @returns The collision coordinator
  32466. */
  32467. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  32468. /** @hidden */
  32469. readonly _isScene: boolean;
  32470. /**
  32471. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  32472. */
  32473. autoClear: boolean;
  32474. /**
  32475. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  32476. */
  32477. autoClearDepthAndStencil: boolean;
  32478. /**
  32479. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  32480. */
  32481. clearColor: Color4;
  32482. /**
  32483. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  32484. */
  32485. ambientColor: Color3;
  32486. /**
  32487. * This is use to store the default BRDF lookup for PBR materials in your scene.
  32488. * It should only be one of the following (if not the default embedded one):
  32489. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  32490. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  32491. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  32492. * The material properties need to be setup according to the type of texture in use.
  32493. */
  32494. environmentBRDFTexture: BaseTexture;
  32495. /** @hidden */
  32496. protected _environmentTexture: Nullable<BaseTexture>;
  32497. /**
  32498. * Texture used in all pbr material as the reflection texture.
  32499. * As in the majority of the scene they are the same (exception for multi room and so on),
  32500. * this is easier to reference from here than from all the materials.
  32501. */
  32502. /**
  32503. * Texture used in all pbr material as the reflection texture.
  32504. * As in the majority of the scene they are the same (exception for multi room and so on),
  32505. * this is easier to set here than in all the materials.
  32506. */
  32507. environmentTexture: Nullable<BaseTexture>;
  32508. /** @hidden */
  32509. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  32510. /**
  32511. * Default image processing configuration used either in the rendering
  32512. * Forward main pass or through the imageProcessingPostProcess if present.
  32513. * As in the majority of the scene they are the same (exception for multi camera),
  32514. * this is easier to reference from here than from all the materials and post process.
  32515. *
  32516. * No setter as we it is a shared configuration, you can set the values instead.
  32517. */
  32518. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  32519. private _forceWireframe;
  32520. /**
  32521. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  32522. */
  32523. forceWireframe: boolean;
  32524. private _forcePointsCloud;
  32525. /**
  32526. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  32527. */
  32528. forcePointsCloud: boolean;
  32529. /**
  32530. * Gets or sets the active clipplane 1
  32531. */
  32532. clipPlane: Nullable<Plane>;
  32533. /**
  32534. * Gets or sets the active clipplane 2
  32535. */
  32536. clipPlane2: Nullable<Plane>;
  32537. /**
  32538. * Gets or sets the active clipplane 3
  32539. */
  32540. clipPlane3: Nullable<Plane>;
  32541. /**
  32542. * Gets or sets the active clipplane 4
  32543. */
  32544. clipPlane4: Nullable<Plane>;
  32545. /**
  32546. * Gets or sets a boolean indicating if animations are enabled
  32547. */
  32548. animationsEnabled: boolean;
  32549. private _animationPropertiesOverride;
  32550. /**
  32551. * Gets or sets the animation properties override
  32552. */
  32553. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  32554. /**
  32555. * Gets or sets a boolean indicating if a constant deltatime has to be used
  32556. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  32557. */
  32558. useConstantAnimationDeltaTime: boolean;
  32559. /**
  32560. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  32561. * Please note that it requires to run a ray cast through the scene on every frame
  32562. */
  32563. constantlyUpdateMeshUnderPointer: boolean;
  32564. /**
  32565. * Defines the HTML cursor to use when hovering over interactive elements
  32566. */
  32567. hoverCursor: string;
  32568. /**
  32569. * Defines the HTML default cursor to use (empty by default)
  32570. */
  32571. defaultCursor: string;
  32572. /**
  32573. * This is used to call preventDefault() on pointer down
  32574. * in order to block unwanted artifacts like system double clicks
  32575. */
  32576. preventDefaultOnPointerDown: boolean;
  32577. /**
  32578. * This is used to call preventDefault() on pointer up
  32579. * in order to block unwanted artifacts like system double clicks
  32580. */
  32581. preventDefaultOnPointerUp: boolean;
  32582. /**
  32583. * Gets or sets user defined metadata
  32584. */
  32585. metadata: any;
  32586. /**
  32587. * For internal use only. Please do not use.
  32588. */
  32589. reservedDataStore: any;
  32590. /**
  32591. * Gets the name of the plugin used to load this scene (null by default)
  32592. */
  32593. loadingPluginName: string;
  32594. /**
  32595. * Use this array to add regular expressions used to disable offline support for specific urls
  32596. */
  32597. disableOfflineSupportExceptionRules: RegExp[];
  32598. /**
  32599. * An event triggered when the scene is disposed.
  32600. */
  32601. onDisposeObservable: Observable<Scene>;
  32602. private _onDisposeObserver;
  32603. /** Sets a function to be executed when this scene is disposed. */
  32604. onDispose: () => void;
  32605. /**
  32606. * An event triggered before rendering the scene (right after animations and physics)
  32607. */
  32608. onBeforeRenderObservable: Observable<Scene>;
  32609. private _onBeforeRenderObserver;
  32610. /** Sets a function to be executed before rendering this scene */
  32611. beforeRender: Nullable<() => void>;
  32612. /**
  32613. * An event triggered after rendering the scene
  32614. */
  32615. onAfterRenderObservable: Observable<Scene>;
  32616. private _onAfterRenderObserver;
  32617. /** Sets a function to be executed after rendering this scene */
  32618. afterRender: Nullable<() => void>;
  32619. /**
  32620. * An event triggered before animating the scene
  32621. */
  32622. onBeforeAnimationsObservable: Observable<Scene>;
  32623. /**
  32624. * An event triggered after animations processing
  32625. */
  32626. onAfterAnimationsObservable: Observable<Scene>;
  32627. /**
  32628. * An event triggered before draw calls are ready to be sent
  32629. */
  32630. onBeforeDrawPhaseObservable: Observable<Scene>;
  32631. /**
  32632. * An event triggered after draw calls have been sent
  32633. */
  32634. onAfterDrawPhaseObservable: Observable<Scene>;
  32635. /**
  32636. * An event triggered when the scene is ready
  32637. */
  32638. onReadyObservable: Observable<Scene>;
  32639. /**
  32640. * An event triggered before rendering a camera
  32641. */
  32642. onBeforeCameraRenderObservable: Observable<Camera>;
  32643. private _onBeforeCameraRenderObserver;
  32644. /** Sets a function to be executed before rendering a camera*/
  32645. beforeCameraRender: () => void;
  32646. /**
  32647. * An event triggered after rendering a camera
  32648. */
  32649. onAfterCameraRenderObservable: Observable<Camera>;
  32650. private _onAfterCameraRenderObserver;
  32651. /** Sets a function to be executed after rendering a camera*/
  32652. afterCameraRender: () => void;
  32653. /**
  32654. * An event triggered when active meshes evaluation is about to start
  32655. */
  32656. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  32657. /**
  32658. * An event triggered when active meshes evaluation is done
  32659. */
  32660. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  32661. /**
  32662. * An event triggered when particles rendering is about to start
  32663. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  32664. */
  32665. onBeforeParticlesRenderingObservable: Observable<Scene>;
  32666. /**
  32667. * An event triggered when particles rendering is done
  32668. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  32669. */
  32670. onAfterParticlesRenderingObservable: Observable<Scene>;
  32671. /**
  32672. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  32673. */
  32674. onDataLoadedObservable: Observable<Scene>;
  32675. /**
  32676. * An event triggered when a camera is created
  32677. */
  32678. onNewCameraAddedObservable: Observable<Camera>;
  32679. /**
  32680. * An event triggered when a camera is removed
  32681. */
  32682. onCameraRemovedObservable: Observable<Camera>;
  32683. /**
  32684. * An event triggered when a light is created
  32685. */
  32686. onNewLightAddedObservable: Observable<Light>;
  32687. /**
  32688. * An event triggered when a light is removed
  32689. */
  32690. onLightRemovedObservable: Observable<Light>;
  32691. /**
  32692. * An event triggered when a geometry is created
  32693. */
  32694. onNewGeometryAddedObservable: Observable<Geometry>;
  32695. /**
  32696. * An event triggered when a geometry is removed
  32697. */
  32698. onGeometryRemovedObservable: Observable<Geometry>;
  32699. /**
  32700. * An event triggered when a transform node is created
  32701. */
  32702. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  32703. /**
  32704. * An event triggered when a transform node is removed
  32705. */
  32706. onTransformNodeRemovedObservable: Observable<TransformNode>;
  32707. /**
  32708. * An event triggered when a mesh is created
  32709. */
  32710. onNewMeshAddedObservable: Observable<AbstractMesh>;
  32711. /**
  32712. * An event triggered when a mesh is removed
  32713. */
  32714. onMeshRemovedObservable: Observable<AbstractMesh>;
  32715. /**
  32716. * An event triggered when a skeleton is created
  32717. */
  32718. onNewSkeletonAddedObservable: Observable<Skeleton>;
  32719. /**
  32720. * An event triggered when a skeleton is removed
  32721. */
  32722. onSkeletonRemovedObservable: Observable<Skeleton>;
  32723. /**
  32724. * An event triggered when a material is created
  32725. */
  32726. onNewMaterialAddedObservable: Observable<Material>;
  32727. /**
  32728. * An event triggered when a material is removed
  32729. */
  32730. onMaterialRemovedObservable: Observable<Material>;
  32731. /**
  32732. * An event triggered when a texture is created
  32733. */
  32734. onNewTextureAddedObservable: Observable<BaseTexture>;
  32735. /**
  32736. * An event triggered when a texture is removed
  32737. */
  32738. onTextureRemovedObservable: Observable<BaseTexture>;
  32739. /**
  32740. * An event triggered when render targets are about to be rendered
  32741. * Can happen multiple times per frame.
  32742. */
  32743. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  32744. /**
  32745. * An event triggered when render targets were rendered.
  32746. * Can happen multiple times per frame.
  32747. */
  32748. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  32749. /**
  32750. * An event triggered before calculating deterministic simulation step
  32751. */
  32752. onBeforeStepObservable: Observable<Scene>;
  32753. /**
  32754. * An event triggered after calculating deterministic simulation step
  32755. */
  32756. onAfterStepObservable: Observable<Scene>;
  32757. /**
  32758. * An event triggered when the activeCamera property is updated
  32759. */
  32760. onActiveCameraChanged: Observable<Scene>;
  32761. /**
  32762. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  32763. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  32764. * 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)
  32765. */
  32766. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  32767. /**
  32768. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  32769. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  32770. * 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)
  32771. */
  32772. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  32773. /**
  32774. * This Observable will when a mesh has been imported into the scene.
  32775. */
  32776. onMeshImportedObservable: Observable<AbstractMesh>;
  32777. /**
  32778. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  32779. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  32780. */
  32781. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  32782. /** @hidden */
  32783. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  32784. /**
  32785. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  32786. */
  32787. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  32788. /**
  32789. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  32790. */
  32791. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  32792. /**
  32793. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  32794. */
  32795. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  32796. private _onPointerMove;
  32797. private _onPointerDown;
  32798. private _onPointerUp;
  32799. /** Callback called when a pointer move is detected */
  32800. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  32801. /** Callback called when a pointer down is detected */
  32802. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  32803. /** Callback called when a pointer up is detected */
  32804. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  32805. /** Callback called when a pointer pick is detected */
  32806. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  32807. /**
  32808. * 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).
  32809. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  32810. */
  32811. onPrePointerObservable: Observable<PointerInfoPre>;
  32812. /**
  32813. * Observable event triggered each time an input event is received from the rendering canvas
  32814. */
  32815. onPointerObservable: Observable<PointerInfo>;
  32816. /**
  32817. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  32818. */
  32819. readonly unTranslatedPointer: Vector2;
  32820. /** The distance in pixel that you have to move to prevent some events */
  32821. static DragMovementThreshold: number;
  32822. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  32823. static LongPressDelay: number;
  32824. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  32825. static DoubleClickDelay: number;
  32826. /** If you need to check double click without raising a single click at first click, enable this flag */
  32827. static ExclusiveDoubleClickMode: boolean;
  32828. private _initClickEvent;
  32829. private _initActionManager;
  32830. private _delayedSimpleClick;
  32831. private _delayedSimpleClickTimeout;
  32832. private _previousDelayedSimpleClickTimeout;
  32833. private _meshPickProceed;
  32834. private _previousButtonPressed;
  32835. private _currentPickResult;
  32836. private _previousPickResult;
  32837. private _totalPointersPressed;
  32838. private _doubleClickOccured;
  32839. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  32840. cameraToUseForPointers: Nullable<Camera>;
  32841. private _pointerX;
  32842. private _pointerY;
  32843. private _unTranslatedPointerX;
  32844. private _unTranslatedPointerY;
  32845. private _startingPointerPosition;
  32846. private _previousStartingPointerPosition;
  32847. private _startingPointerTime;
  32848. private _previousStartingPointerTime;
  32849. private _pointerCaptures;
  32850. private _timeAccumulator;
  32851. private _currentStepId;
  32852. private _currentInternalStep;
  32853. /** @hidden */
  32854. _mirroredCameraPosition: Nullable<Vector3>;
  32855. /**
  32856. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  32857. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  32858. */
  32859. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  32860. /**
  32861. * Observable event triggered each time an keyboard event is received from the hosting window
  32862. */
  32863. onKeyboardObservable: Observable<KeyboardInfo>;
  32864. private _onKeyDown;
  32865. private _onKeyUp;
  32866. private _onCanvasFocusObserver;
  32867. private _onCanvasBlurObserver;
  32868. private _useRightHandedSystem;
  32869. /**
  32870. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  32871. */
  32872. useRightHandedSystem: boolean;
  32873. /**
  32874. * Sets the step Id used by deterministic lock step
  32875. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32876. * @param newStepId defines the step Id
  32877. */
  32878. setStepId(newStepId: number): void;
  32879. /**
  32880. * Gets the step Id used by deterministic lock step
  32881. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32882. * @returns the step Id
  32883. */
  32884. getStepId(): number;
  32885. /**
  32886. * Gets the internal step used by deterministic lock step
  32887. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32888. * @returns the internal step
  32889. */
  32890. getInternalStep(): number;
  32891. private _fogEnabled;
  32892. /**
  32893. * Gets or sets a boolean indicating if fog is enabled on this scene
  32894. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32895. * (Default is true)
  32896. */
  32897. fogEnabled: boolean;
  32898. private _fogMode;
  32899. /**
  32900. * Gets or sets the fog mode to use
  32901. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32902. * | mode | value |
  32903. * | --- | --- |
  32904. * | FOGMODE_NONE | 0 |
  32905. * | FOGMODE_EXP | 1 |
  32906. * | FOGMODE_EXP2 | 2 |
  32907. * | FOGMODE_LINEAR | 3 |
  32908. */
  32909. fogMode: number;
  32910. /**
  32911. * Gets or sets the fog color to use
  32912. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32913. * (Default is Color3(0.2, 0.2, 0.3))
  32914. */
  32915. fogColor: Color3;
  32916. /**
  32917. * Gets or sets the fog density to use
  32918. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32919. * (Default is 0.1)
  32920. */
  32921. fogDensity: number;
  32922. /**
  32923. * Gets or sets the fog start distance to use
  32924. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32925. * (Default is 0)
  32926. */
  32927. fogStart: number;
  32928. /**
  32929. * Gets or sets the fog end distance to use
  32930. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32931. * (Default is 1000)
  32932. */
  32933. fogEnd: number;
  32934. private _shadowsEnabled;
  32935. /**
  32936. * Gets or sets a boolean indicating if shadows are enabled on this scene
  32937. */
  32938. shadowsEnabled: boolean;
  32939. private _lightsEnabled;
  32940. /**
  32941. * Gets or sets a boolean indicating if lights are enabled on this scene
  32942. */
  32943. lightsEnabled: boolean;
  32944. /** All of the active cameras added to this scene. */
  32945. activeCameras: Camera[];
  32946. /** @hidden */
  32947. _activeCamera: Nullable<Camera>;
  32948. /** Gets or sets the current active camera */
  32949. activeCamera: Nullable<Camera>;
  32950. private _defaultMaterial;
  32951. /** The default material used on meshes when no material is affected */
  32952. /** The default material used on meshes when no material is affected */
  32953. defaultMaterial: Material;
  32954. private _texturesEnabled;
  32955. /**
  32956. * Gets or sets a boolean indicating if textures are enabled on this scene
  32957. */
  32958. texturesEnabled: boolean;
  32959. /**
  32960. * Gets or sets a boolean indicating if particles are enabled on this scene
  32961. */
  32962. particlesEnabled: boolean;
  32963. /**
  32964. * Gets or sets a boolean indicating if sprites are enabled on this scene
  32965. */
  32966. spritesEnabled: boolean;
  32967. private _skeletonsEnabled;
  32968. /**
  32969. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  32970. */
  32971. skeletonsEnabled: boolean;
  32972. /**
  32973. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  32974. */
  32975. lensFlaresEnabled: boolean;
  32976. /**
  32977. * Gets or sets a boolean indicating if collisions are enabled on this scene
  32978. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32979. */
  32980. collisionsEnabled: boolean;
  32981. private _collisionCoordinator;
  32982. /** @hidden */
  32983. readonly collisionCoordinator: ICollisionCoordinator;
  32984. /**
  32985. * Defines the gravity applied to this scene (used only for collisions)
  32986. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32987. */
  32988. gravity: Vector3;
  32989. /**
  32990. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  32991. */
  32992. postProcessesEnabled: boolean;
  32993. /**
  32994. * The list of postprocesses added to the scene
  32995. */
  32996. postProcesses: PostProcess[];
  32997. /**
  32998. * Gets the current postprocess manager
  32999. */
  33000. postProcessManager: PostProcessManager;
  33001. /**
  33002. * Gets or sets a boolean indicating if render targets are enabled on this scene
  33003. */
  33004. renderTargetsEnabled: boolean;
  33005. /**
  33006. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  33007. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  33008. */
  33009. dumpNextRenderTargets: boolean;
  33010. /**
  33011. * The list of user defined render targets added to the scene
  33012. */
  33013. customRenderTargets: RenderTargetTexture[];
  33014. /**
  33015. * Defines if texture loading must be delayed
  33016. * If true, textures will only be loaded when they need to be rendered
  33017. */
  33018. useDelayedTextureLoading: boolean;
  33019. /**
  33020. * Gets the list of meshes imported to the scene through SceneLoader
  33021. */
  33022. importedMeshesFiles: String[];
  33023. /**
  33024. * Gets or sets a boolean indicating if probes are enabled on this scene
  33025. */
  33026. probesEnabled: boolean;
  33027. /**
  33028. * Gets or sets the current offline provider to use to store scene data
  33029. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  33030. */
  33031. offlineProvider: IOfflineProvider;
  33032. /**
  33033. * Gets or sets the action manager associated with the scene
  33034. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  33035. */
  33036. actionManager: AbstractActionManager;
  33037. private _meshesForIntersections;
  33038. /**
  33039. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  33040. */
  33041. proceduralTexturesEnabled: boolean;
  33042. private _engine;
  33043. private _totalVertices;
  33044. /** @hidden */
  33045. _activeIndices: PerfCounter;
  33046. /** @hidden */
  33047. _activeParticles: PerfCounter;
  33048. /** @hidden */
  33049. _activeBones: PerfCounter;
  33050. private _animationRatio;
  33051. /** @hidden */
  33052. _animationTimeLast: number;
  33053. /** @hidden */
  33054. _animationTime: number;
  33055. /**
  33056. * Gets or sets a general scale for animation speed
  33057. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  33058. */
  33059. animationTimeScale: number;
  33060. /** @hidden */
  33061. _cachedMaterial: Nullable<Material>;
  33062. /** @hidden */
  33063. _cachedEffect: Nullable<Effect>;
  33064. /** @hidden */
  33065. _cachedVisibility: Nullable<number>;
  33066. private _renderId;
  33067. private _frameId;
  33068. private _executeWhenReadyTimeoutId;
  33069. private _intermediateRendering;
  33070. private _viewUpdateFlag;
  33071. private _projectionUpdateFlag;
  33072. /** @hidden */
  33073. _toBeDisposed: Nullable<IDisposable>[];
  33074. private _activeRequests;
  33075. /** @hidden */
  33076. _pendingData: any[];
  33077. private _isDisposed;
  33078. /**
  33079. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  33080. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  33081. */
  33082. dispatchAllSubMeshesOfActiveMeshes: boolean;
  33083. private _activeMeshes;
  33084. private _processedMaterials;
  33085. private _renderTargets;
  33086. /** @hidden */
  33087. _activeParticleSystems: SmartArray<IParticleSystem>;
  33088. private _activeSkeletons;
  33089. private _softwareSkinnedMeshes;
  33090. private _renderingManager;
  33091. /** @hidden */
  33092. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  33093. private _transformMatrix;
  33094. private _sceneUbo;
  33095. /** @hidden */
  33096. _viewMatrix: Matrix;
  33097. private _projectionMatrix;
  33098. private _wheelEventName;
  33099. /** @hidden */
  33100. _forcedViewPosition: Nullable<Vector3>;
  33101. /** @hidden */
  33102. _frustumPlanes: Plane[];
  33103. /**
  33104. * Gets the list of frustum planes (built from the active camera)
  33105. */
  33106. readonly frustumPlanes: Plane[];
  33107. /**
  33108. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  33109. * This is useful if there are more lights that the maximum simulteanous authorized
  33110. */
  33111. requireLightSorting: boolean;
  33112. /** @hidden */
  33113. readonly useMaterialMeshMap: boolean;
  33114. /** @hidden */
  33115. readonly useClonedMeshhMap: boolean;
  33116. private _pointerOverMesh;
  33117. private _pickedDownMesh;
  33118. private _pickedUpMesh;
  33119. private _externalData;
  33120. private _uid;
  33121. /**
  33122. * @hidden
  33123. * Backing store of defined scene components.
  33124. */
  33125. _components: ISceneComponent[];
  33126. /**
  33127. * @hidden
  33128. * Backing store of defined scene components.
  33129. */
  33130. _serializableComponents: ISceneSerializableComponent[];
  33131. /**
  33132. * List of components to register on the next registration step.
  33133. */
  33134. private _transientComponents;
  33135. /**
  33136. * Registers the transient components if needed.
  33137. */
  33138. private _registerTransientComponents;
  33139. /**
  33140. * @hidden
  33141. * Add a component to the scene.
  33142. * Note that the ccomponent could be registered on th next frame if this is called after
  33143. * the register component stage.
  33144. * @param component Defines the component to add to the scene
  33145. */
  33146. _addComponent(component: ISceneComponent): void;
  33147. /**
  33148. * @hidden
  33149. * Gets a component from the scene.
  33150. * @param name defines the name of the component to retrieve
  33151. * @returns the component or null if not present
  33152. */
  33153. _getComponent(name: string): Nullable<ISceneComponent>;
  33154. /**
  33155. * @hidden
  33156. * Defines the actions happening before camera updates.
  33157. */
  33158. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  33159. /**
  33160. * @hidden
  33161. * Defines the actions happening before clear the canvas.
  33162. */
  33163. _beforeClearStage: Stage<SimpleStageAction>;
  33164. /**
  33165. * @hidden
  33166. * Defines the actions when collecting render targets for the frame.
  33167. */
  33168. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  33169. /**
  33170. * @hidden
  33171. * Defines the actions happening for one camera in the frame.
  33172. */
  33173. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  33174. /**
  33175. * @hidden
  33176. * Defines the actions happening during the per mesh ready checks.
  33177. */
  33178. _isReadyForMeshStage: Stage<MeshStageAction>;
  33179. /**
  33180. * @hidden
  33181. * Defines the actions happening before evaluate active mesh checks.
  33182. */
  33183. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  33184. /**
  33185. * @hidden
  33186. * Defines the actions happening during the evaluate sub mesh checks.
  33187. */
  33188. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  33189. /**
  33190. * @hidden
  33191. * Defines the actions happening during the active mesh stage.
  33192. */
  33193. _activeMeshStage: Stage<ActiveMeshStageAction>;
  33194. /**
  33195. * @hidden
  33196. * Defines the actions happening during the per camera render target step.
  33197. */
  33198. _cameraDrawRenderTargetStage: Stage<CameraStageAction>;
  33199. /**
  33200. * @hidden
  33201. * Defines the actions happening just before the active camera is drawing.
  33202. */
  33203. _beforeCameraDrawStage: Stage<CameraStageAction>;
  33204. /**
  33205. * @hidden
  33206. * Defines the actions happening just before a render target is drawing.
  33207. */
  33208. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  33209. /**
  33210. * @hidden
  33211. * Defines the actions happening just before a rendering group is drawing.
  33212. */
  33213. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  33214. /**
  33215. * @hidden
  33216. * Defines the actions happening just before a mesh is drawing.
  33217. */
  33218. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  33219. /**
  33220. * @hidden
  33221. * Defines the actions happening just after a mesh has been drawn.
  33222. */
  33223. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  33224. /**
  33225. * @hidden
  33226. * Defines the actions happening just after a rendering group has been drawn.
  33227. */
  33228. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  33229. /**
  33230. * @hidden
  33231. * Defines the actions happening just after the active camera has been drawn.
  33232. */
  33233. _afterCameraDrawStage: Stage<CameraStageAction>;
  33234. /**
  33235. * @hidden
  33236. * Defines the actions happening just after a render target has been drawn.
  33237. */
  33238. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  33239. /**
  33240. * @hidden
  33241. * Defines the actions happening just after rendering all cameras and computing intersections.
  33242. */
  33243. _afterRenderStage: Stage<SimpleStageAction>;
  33244. /**
  33245. * @hidden
  33246. * Defines the actions happening when a pointer move event happens.
  33247. */
  33248. _pointerMoveStage: Stage<PointerMoveStageAction>;
  33249. /**
  33250. * @hidden
  33251. * Defines the actions happening when a pointer down event happens.
  33252. */
  33253. _pointerDownStage: Stage<PointerUpDownStageAction>;
  33254. /**
  33255. * @hidden
  33256. * Defines the actions happening when a pointer up event happens.
  33257. */
  33258. _pointerUpStage: Stage<PointerUpDownStageAction>;
  33259. /**
  33260. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  33261. */
  33262. private geometriesByUniqueId;
  33263. /**
  33264. * Creates a new Scene
  33265. * @param engine defines the engine to use to render this scene
  33266. * @param options defines the scene options
  33267. */
  33268. constructor(engine: Engine, options?: SceneOptions);
  33269. /**
  33270. * Gets a string idenfifying the name of the class
  33271. * @returns "Scene" string
  33272. */
  33273. getClassName(): string;
  33274. private _defaultMeshCandidates;
  33275. /**
  33276. * @hidden
  33277. */
  33278. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  33279. private _defaultSubMeshCandidates;
  33280. /**
  33281. * @hidden
  33282. */
  33283. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  33284. /**
  33285. * Sets the default candidate providers for the scene.
  33286. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  33287. * and getCollidingSubMeshCandidates to their default function
  33288. */
  33289. setDefaultCandidateProviders(): void;
  33290. /**
  33291. * Gets the mesh that is currently under the pointer
  33292. */
  33293. readonly meshUnderPointer: Nullable<AbstractMesh>;
  33294. /**
  33295. * Gets or sets the current on-screen X position of the pointer
  33296. */
  33297. pointerX: number;
  33298. /**
  33299. * Gets or sets the current on-screen Y position of the pointer
  33300. */
  33301. pointerY: number;
  33302. /**
  33303. * Gets the cached material (ie. the latest rendered one)
  33304. * @returns the cached material
  33305. */
  33306. getCachedMaterial(): Nullable<Material>;
  33307. /**
  33308. * Gets the cached effect (ie. the latest rendered one)
  33309. * @returns the cached effect
  33310. */
  33311. getCachedEffect(): Nullable<Effect>;
  33312. /**
  33313. * Gets the cached visibility state (ie. the latest rendered one)
  33314. * @returns the cached visibility state
  33315. */
  33316. getCachedVisibility(): Nullable<number>;
  33317. /**
  33318. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  33319. * @param material defines the current material
  33320. * @param effect defines the current effect
  33321. * @param visibility defines the current visibility state
  33322. * @returns true if one parameter is not cached
  33323. */
  33324. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  33325. /**
  33326. * Gets the engine associated with the scene
  33327. * @returns an Engine
  33328. */
  33329. getEngine(): Engine;
  33330. /**
  33331. * Gets the total number of vertices rendered per frame
  33332. * @returns the total number of vertices rendered per frame
  33333. */
  33334. getTotalVertices(): number;
  33335. /**
  33336. * Gets the performance counter for total vertices
  33337. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33338. */
  33339. readonly totalVerticesPerfCounter: PerfCounter;
  33340. /**
  33341. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  33342. * @returns the total number of active indices rendered per frame
  33343. */
  33344. getActiveIndices(): number;
  33345. /**
  33346. * Gets the performance counter for active indices
  33347. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33348. */
  33349. readonly totalActiveIndicesPerfCounter: PerfCounter;
  33350. /**
  33351. * Gets the total number of active particles rendered per frame
  33352. * @returns the total number of active particles rendered per frame
  33353. */
  33354. getActiveParticles(): number;
  33355. /**
  33356. * Gets the performance counter for active particles
  33357. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33358. */
  33359. readonly activeParticlesPerfCounter: PerfCounter;
  33360. /**
  33361. * Gets the total number of active bones rendered per frame
  33362. * @returns the total number of active bones rendered per frame
  33363. */
  33364. getActiveBones(): number;
  33365. /**
  33366. * Gets the performance counter for active bones
  33367. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33368. */
  33369. readonly activeBonesPerfCounter: PerfCounter;
  33370. /**
  33371. * Gets the array of active meshes
  33372. * @returns an array of AbstractMesh
  33373. */
  33374. getActiveMeshes(): SmartArray<AbstractMesh>;
  33375. /**
  33376. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  33377. * @returns a number
  33378. */
  33379. getAnimationRatio(): number;
  33380. /**
  33381. * Gets an unique Id for the current render phase
  33382. * @returns a number
  33383. */
  33384. getRenderId(): number;
  33385. /**
  33386. * Gets an unique Id for the current frame
  33387. * @returns a number
  33388. */
  33389. getFrameId(): number;
  33390. /** Call this function if you want to manually increment the render Id*/
  33391. incrementRenderId(): void;
  33392. private _updatePointerPosition;
  33393. private _createUbo;
  33394. private _setRayOnPointerInfo;
  33395. /**
  33396. * Use this method to simulate a pointer move on a mesh
  33397. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33398. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33399. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33400. * @returns the current scene
  33401. */
  33402. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  33403. private _processPointerMove;
  33404. private _checkPrePointerObservable;
  33405. /**
  33406. * Use this method to simulate a pointer down on a mesh
  33407. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33408. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33409. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33410. * @returns the current scene
  33411. */
  33412. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  33413. private _processPointerDown;
  33414. /**
  33415. * Use this method to simulate a pointer up on a mesh
  33416. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33417. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33418. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33419. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  33420. * @returns the current scene
  33421. */
  33422. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  33423. private _processPointerUp;
  33424. /**
  33425. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  33426. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  33427. * @returns true if the pointer was captured
  33428. */
  33429. isPointerCaptured(pointerId?: number): boolean;
  33430. /** @hidden */
  33431. _isPointerSwiping(): boolean;
  33432. /**
  33433. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  33434. * @param attachUp defines if you want to attach events to pointerup
  33435. * @param attachDown defines if you want to attach events to pointerdown
  33436. * @param attachMove defines if you want to attach events to pointermove
  33437. */
  33438. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  33439. /** Detaches all event handlers*/
  33440. detachControl(): void;
  33441. /**
  33442. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  33443. * Delay loaded resources are not taking in account
  33444. * @return true if all required resources are ready
  33445. */
  33446. isReady(): boolean;
  33447. /** Resets all cached information relative to material (including effect and visibility) */
  33448. resetCachedMaterial(): void;
  33449. /**
  33450. * Registers a function to be called before every frame render
  33451. * @param func defines the function to register
  33452. */
  33453. registerBeforeRender(func: () => void): void;
  33454. /**
  33455. * Unregisters a function called before every frame render
  33456. * @param func defines the function to unregister
  33457. */
  33458. unregisterBeforeRender(func: () => void): void;
  33459. /**
  33460. * Registers a function to be called after every frame render
  33461. * @param func defines the function to register
  33462. */
  33463. registerAfterRender(func: () => void): void;
  33464. /**
  33465. * Unregisters a function called after every frame render
  33466. * @param func defines the function to unregister
  33467. */
  33468. unregisterAfterRender(func: () => void): void;
  33469. private _executeOnceBeforeRender;
  33470. /**
  33471. * The provided function will run before render once and will be disposed afterwards.
  33472. * A timeout delay can be provided so that the function will be executed in N ms.
  33473. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  33474. * @param func The function to be executed.
  33475. * @param timeout optional delay in ms
  33476. */
  33477. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  33478. /** @hidden */
  33479. _addPendingData(data: any): void;
  33480. /** @hidden */
  33481. _removePendingData(data: any): void;
  33482. /**
  33483. * Returns the number of items waiting to be loaded
  33484. * @returns the number of items waiting to be loaded
  33485. */
  33486. getWaitingItemsCount(): number;
  33487. /**
  33488. * Returns a boolean indicating if the scene is still loading data
  33489. */
  33490. readonly isLoading: boolean;
  33491. /**
  33492. * Registers a function to be executed when the scene is ready
  33493. * @param {Function} func - the function to be executed
  33494. */
  33495. executeWhenReady(func: () => void): void;
  33496. /**
  33497. * Returns a promise that resolves when the scene is ready
  33498. * @returns A promise that resolves when the scene is ready
  33499. */
  33500. whenReadyAsync(): Promise<void>;
  33501. /** @hidden */
  33502. _checkIsReady(): void;
  33503. /**
  33504. * Gets all animatable attached to the scene
  33505. */
  33506. readonly animatables: Animatable[];
  33507. /**
  33508. * Resets the last animation time frame.
  33509. * Useful to override when animations start running when loading a scene for the first time.
  33510. */
  33511. resetLastAnimationTimeFrame(): void;
  33512. /**
  33513. * Gets the current view matrix
  33514. * @returns a Matrix
  33515. */
  33516. getViewMatrix(): Matrix;
  33517. /**
  33518. * Gets the current projection matrix
  33519. * @returns a Matrix
  33520. */
  33521. getProjectionMatrix(): Matrix;
  33522. /**
  33523. * Gets the current transform matrix
  33524. * @returns a Matrix made of View * Projection
  33525. */
  33526. getTransformMatrix(): Matrix;
  33527. /**
  33528. * Sets the current transform matrix
  33529. * @param viewL defines the View matrix to use
  33530. * @param projectionL defines the Projection matrix to use
  33531. * @param viewR defines the right View matrix to use (if provided)
  33532. * @param projectionR defines the right Projection matrix to use (if provided)
  33533. */
  33534. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  33535. /**
  33536. * Gets the uniform buffer used to store scene data
  33537. * @returns a UniformBuffer
  33538. */
  33539. getSceneUniformBuffer(): UniformBuffer;
  33540. /**
  33541. * Gets an unique (relatively to the current scene) Id
  33542. * @returns an unique number for the scene
  33543. */
  33544. getUniqueId(): number;
  33545. /**
  33546. * Add a mesh to the list of scene's meshes
  33547. * @param newMesh defines the mesh to add
  33548. * @param recursive if all child meshes should also be added to the scene
  33549. */
  33550. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  33551. /**
  33552. * Remove a mesh for the list of scene's meshes
  33553. * @param toRemove defines the mesh to remove
  33554. * @param recursive if all child meshes should also be removed from the scene
  33555. * @returns the index where the mesh was in the mesh list
  33556. */
  33557. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  33558. /**
  33559. * Add a transform node to the list of scene's transform nodes
  33560. * @param newTransformNode defines the transform node to add
  33561. */
  33562. addTransformNode(newTransformNode: TransformNode): void;
  33563. /**
  33564. * Remove a transform node for the list of scene's transform nodes
  33565. * @param toRemove defines the transform node to remove
  33566. * @returns the index where the transform node was in the transform node list
  33567. */
  33568. removeTransformNode(toRemove: TransformNode): number;
  33569. /**
  33570. * Remove a skeleton for the list of scene's skeletons
  33571. * @param toRemove defines the skeleton to remove
  33572. * @returns the index where the skeleton was in the skeleton list
  33573. */
  33574. removeSkeleton(toRemove: Skeleton): number;
  33575. /**
  33576. * Remove a morph target for the list of scene's morph targets
  33577. * @param toRemove defines the morph target to remove
  33578. * @returns the index where the morph target was in the morph target list
  33579. */
  33580. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  33581. /**
  33582. * Remove a light for the list of scene's lights
  33583. * @param toRemove defines the light to remove
  33584. * @returns the index where the light was in the light list
  33585. */
  33586. removeLight(toRemove: Light): number;
  33587. /**
  33588. * Remove a camera for the list of scene's cameras
  33589. * @param toRemove defines the camera to remove
  33590. * @returns the index where the camera was in the camera list
  33591. */
  33592. removeCamera(toRemove: Camera): number;
  33593. /**
  33594. * Remove a particle system for the list of scene's particle systems
  33595. * @param toRemove defines the particle system to remove
  33596. * @returns the index where the particle system was in the particle system list
  33597. */
  33598. removeParticleSystem(toRemove: IParticleSystem): number;
  33599. /**
  33600. * Remove a animation for the list of scene's animations
  33601. * @param toRemove defines the animation to remove
  33602. * @returns the index where the animation was in the animation list
  33603. */
  33604. removeAnimation(toRemove: Animation): number;
  33605. /**
  33606. * Removes the given animation group from this scene.
  33607. * @param toRemove The animation group to remove
  33608. * @returns The index of the removed animation group
  33609. */
  33610. removeAnimationGroup(toRemove: AnimationGroup): number;
  33611. /**
  33612. * Removes the given multi-material from this scene.
  33613. * @param toRemove The multi-material to remove
  33614. * @returns The index of the removed multi-material
  33615. */
  33616. removeMultiMaterial(toRemove: MultiMaterial): number;
  33617. /**
  33618. * Removes the given material from this scene.
  33619. * @param toRemove The material to remove
  33620. * @returns The index of the removed material
  33621. */
  33622. removeMaterial(toRemove: Material): number;
  33623. /**
  33624. * Removes the given action manager from this scene.
  33625. * @param toRemove The action manager to remove
  33626. * @returns The index of the removed action manager
  33627. */
  33628. removeActionManager(toRemove: AbstractActionManager): number;
  33629. /**
  33630. * Removes the given texture from this scene.
  33631. * @param toRemove The texture to remove
  33632. * @returns The index of the removed texture
  33633. */
  33634. removeTexture(toRemove: BaseTexture): number;
  33635. /**
  33636. * Adds the given light to this scene
  33637. * @param newLight The light to add
  33638. */
  33639. addLight(newLight: Light): void;
  33640. /**
  33641. * Sorts the list list based on light priorities
  33642. */
  33643. sortLightsByPriority(): void;
  33644. /**
  33645. * Adds the given camera to this scene
  33646. * @param newCamera The camera to add
  33647. */
  33648. addCamera(newCamera: Camera): void;
  33649. /**
  33650. * Adds the given skeleton to this scene
  33651. * @param newSkeleton The skeleton to add
  33652. */
  33653. addSkeleton(newSkeleton: Skeleton): void;
  33654. /**
  33655. * Adds the given particle system to this scene
  33656. * @param newParticleSystem The particle system to add
  33657. */
  33658. addParticleSystem(newParticleSystem: IParticleSystem): void;
  33659. /**
  33660. * Adds the given animation to this scene
  33661. * @param newAnimation The animation to add
  33662. */
  33663. addAnimation(newAnimation: Animation): void;
  33664. /**
  33665. * Adds the given animation group to this scene.
  33666. * @param newAnimationGroup The animation group to add
  33667. */
  33668. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  33669. /**
  33670. * Adds the given multi-material to this scene
  33671. * @param newMultiMaterial The multi-material to add
  33672. */
  33673. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  33674. /**
  33675. * Adds the given material to this scene
  33676. * @param newMaterial The material to add
  33677. */
  33678. addMaterial(newMaterial: Material): void;
  33679. /**
  33680. * Adds the given morph target to this scene
  33681. * @param newMorphTargetManager The morph target to add
  33682. */
  33683. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  33684. /**
  33685. * Adds the given geometry to this scene
  33686. * @param newGeometry The geometry to add
  33687. */
  33688. addGeometry(newGeometry: Geometry): void;
  33689. /**
  33690. * Adds the given action manager to this scene
  33691. * @param newActionManager The action manager to add
  33692. */
  33693. addActionManager(newActionManager: AbstractActionManager): void;
  33694. /**
  33695. * Adds the given texture to this scene.
  33696. * @param newTexture The texture to add
  33697. */
  33698. addTexture(newTexture: BaseTexture): void;
  33699. /**
  33700. * Switch active camera
  33701. * @param newCamera defines the new active camera
  33702. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  33703. */
  33704. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  33705. /**
  33706. * sets the active camera of the scene using its ID
  33707. * @param id defines the camera's ID
  33708. * @return the new active camera or null if none found.
  33709. */
  33710. setActiveCameraByID(id: string): Nullable<Camera>;
  33711. /**
  33712. * sets the active camera of the scene using its name
  33713. * @param name defines the camera's name
  33714. * @returns the new active camera or null if none found.
  33715. */
  33716. setActiveCameraByName(name: string): Nullable<Camera>;
  33717. /**
  33718. * get an animation group using its name
  33719. * @param name defines the material's name
  33720. * @return the animation group or null if none found.
  33721. */
  33722. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  33723. /**
  33724. * Get a material using its unique id
  33725. * @param uniqueId defines the material's unique id
  33726. * @return the material or null if none found.
  33727. */
  33728. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  33729. /**
  33730. * get a material using its id
  33731. * @param id defines the material's ID
  33732. * @return the material or null if none found.
  33733. */
  33734. getMaterialByID(id: string): Nullable<Material>;
  33735. /**
  33736. * Gets a material using its name
  33737. * @param name defines the material's name
  33738. * @return the material or null if none found.
  33739. */
  33740. getMaterialByName(name: string): Nullable<Material>;
  33741. /**
  33742. * Gets a camera using its id
  33743. * @param id defines the id to look for
  33744. * @returns the camera or null if not found
  33745. */
  33746. getCameraByID(id: string): Nullable<Camera>;
  33747. /**
  33748. * Gets a camera using its unique id
  33749. * @param uniqueId defines the unique id to look for
  33750. * @returns the camera or null if not found
  33751. */
  33752. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  33753. /**
  33754. * Gets a camera using its name
  33755. * @param name defines the camera's name
  33756. * @return the camera or null if none found.
  33757. */
  33758. getCameraByName(name: string): Nullable<Camera>;
  33759. /**
  33760. * Gets a bone using its id
  33761. * @param id defines the bone's id
  33762. * @return the bone or null if not found
  33763. */
  33764. getBoneByID(id: string): Nullable<Bone>;
  33765. /**
  33766. * Gets a bone using its id
  33767. * @param name defines the bone's name
  33768. * @return the bone or null if not found
  33769. */
  33770. getBoneByName(name: string): Nullable<Bone>;
  33771. /**
  33772. * Gets a light node using its name
  33773. * @param name defines the the light's name
  33774. * @return the light or null if none found.
  33775. */
  33776. getLightByName(name: string): Nullable<Light>;
  33777. /**
  33778. * Gets a light node using its id
  33779. * @param id defines the light's id
  33780. * @return the light or null if none found.
  33781. */
  33782. getLightByID(id: string): Nullable<Light>;
  33783. /**
  33784. * Gets a light node using its scene-generated unique ID
  33785. * @param uniqueId defines the light's unique id
  33786. * @return the light or null if none found.
  33787. */
  33788. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  33789. /**
  33790. * Gets a particle system by id
  33791. * @param id defines the particle system id
  33792. * @return the corresponding system or null if none found
  33793. */
  33794. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  33795. /**
  33796. * Gets a geometry using its ID
  33797. * @param id defines the geometry's id
  33798. * @return the geometry or null if none found.
  33799. */
  33800. getGeometryByID(id: string): Nullable<Geometry>;
  33801. private _getGeometryByUniqueID;
  33802. /**
  33803. * Add a new geometry to this scene
  33804. * @param geometry defines the geometry to be added to the scene.
  33805. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  33806. * @return a boolean defining if the geometry was added or not
  33807. */
  33808. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  33809. /**
  33810. * Removes an existing geometry
  33811. * @param geometry defines the geometry to be removed from the scene
  33812. * @return a boolean defining if the geometry was removed or not
  33813. */
  33814. removeGeometry(geometry: Geometry): boolean;
  33815. /**
  33816. * Gets the list of geometries attached to the scene
  33817. * @returns an array of Geometry
  33818. */
  33819. getGeometries(): Geometry[];
  33820. /**
  33821. * Gets the first added mesh found of a given ID
  33822. * @param id defines the id to search for
  33823. * @return the mesh found or null if not found at all
  33824. */
  33825. getMeshByID(id: string): Nullable<AbstractMesh>;
  33826. /**
  33827. * Gets a list of meshes using their id
  33828. * @param id defines the id to search for
  33829. * @returns a list of meshes
  33830. */
  33831. getMeshesByID(id: string): Array<AbstractMesh>;
  33832. /**
  33833. * Gets the first added transform node found of a given ID
  33834. * @param id defines the id to search for
  33835. * @return the found transform node or null if not found at all.
  33836. */
  33837. getTransformNodeByID(id: string): Nullable<TransformNode>;
  33838. /**
  33839. * Gets a transform node with its auto-generated unique id
  33840. * @param uniqueId efines the unique id to search for
  33841. * @return the found transform node or null if not found at all.
  33842. */
  33843. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  33844. /**
  33845. * Gets a list of transform nodes using their id
  33846. * @param id defines the id to search for
  33847. * @returns a list of transform nodes
  33848. */
  33849. getTransformNodesByID(id: string): Array<TransformNode>;
  33850. /**
  33851. * Gets a mesh with its auto-generated unique id
  33852. * @param uniqueId defines the unique id to search for
  33853. * @return the found mesh or null if not found at all.
  33854. */
  33855. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  33856. /**
  33857. * Gets a the last added mesh using a given id
  33858. * @param id defines the id to search for
  33859. * @return the found mesh or null if not found at all.
  33860. */
  33861. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  33862. /**
  33863. * Gets a the last added node (Mesh, Camera, Light) using a given id
  33864. * @param id defines the id to search for
  33865. * @return the found node or null if not found at all
  33866. */
  33867. getLastEntryByID(id: string): Nullable<Node>;
  33868. /**
  33869. * Gets a node (Mesh, Camera, Light) using a given id
  33870. * @param id defines the id to search for
  33871. * @return the found node or null if not found at all
  33872. */
  33873. getNodeByID(id: string): Nullable<Node>;
  33874. /**
  33875. * Gets a node (Mesh, Camera, Light) using a given name
  33876. * @param name defines the name to search for
  33877. * @return the found node or null if not found at all.
  33878. */
  33879. getNodeByName(name: string): Nullable<Node>;
  33880. /**
  33881. * Gets a mesh using a given name
  33882. * @param name defines the name to search for
  33883. * @return the found mesh or null if not found at all.
  33884. */
  33885. getMeshByName(name: string): Nullable<AbstractMesh>;
  33886. /**
  33887. * Gets a transform node using a given name
  33888. * @param name defines the name to search for
  33889. * @return the found transform node or null if not found at all.
  33890. */
  33891. getTransformNodeByName(name: string): Nullable<TransformNode>;
  33892. /**
  33893. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  33894. * @param id defines the id to search for
  33895. * @return the found skeleton or null if not found at all.
  33896. */
  33897. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  33898. /**
  33899. * Gets a skeleton using a given auto generated unique id
  33900. * @param uniqueId defines the unique id to search for
  33901. * @return the found skeleton or null if not found at all.
  33902. */
  33903. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  33904. /**
  33905. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  33906. * @param id defines the id to search for
  33907. * @return the found skeleton or null if not found at all.
  33908. */
  33909. getSkeletonById(id: string): Nullable<Skeleton>;
  33910. /**
  33911. * Gets a skeleton using a given name
  33912. * @param name defines the name to search for
  33913. * @return the found skeleton or null if not found at all.
  33914. */
  33915. getSkeletonByName(name: string): Nullable<Skeleton>;
  33916. /**
  33917. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  33918. * @param id defines the id to search for
  33919. * @return the found morph target manager or null if not found at all.
  33920. */
  33921. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  33922. /**
  33923. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  33924. * @param id defines the id to search for
  33925. * @return the found morph target or null if not found at all.
  33926. */
  33927. getMorphTargetById(id: string): Nullable<MorphTarget>;
  33928. /**
  33929. * Gets a boolean indicating if the given mesh is active
  33930. * @param mesh defines the mesh to look for
  33931. * @returns true if the mesh is in the active list
  33932. */
  33933. isActiveMesh(mesh: AbstractMesh): boolean;
  33934. /**
  33935. * Return a unique id as a string which can serve as an identifier for the scene
  33936. */
  33937. readonly uid: string;
  33938. /**
  33939. * Add an externaly attached data from its key.
  33940. * This method call will fail and return false, if such key already exists.
  33941. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  33942. * @param key the unique key that identifies the data
  33943. * @param data the data object to associate to the key for this Engine instance
  33944. * @return true if no such key were already present and the data was added successfully, false otherwise
  33945. */
  33946. addExternalData<T>(key: string, data: T): boolean;
  33947. /**
  33948. * Get an externaly attached data from its key
  33949. * @param key the unique key that identifies the data
  33950. * @return the associated data, if present (can be null), or undefined if not present
  33951. */
  33952. getExternalData<T>(key: string): Nullable<T>;
  33953. /**
  33954. * Get an externaly attached data from its key, create it using a factory if it's not already present
  33955. * @param key the unique key that identifies the data
  33956. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  33957. * @return the associated data, can be null if the factory returned null.
  33958. */
  33959. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  33960. /**
  33961. * Remove an externaly attached data from the Engine instance
  33962. * @param key the unique key that identifies the data
  33963. * @return true if the data was successfully removed, false if it doesn't exist
  33964. */
  33965. removeExternalData(key: string): boolean;
  33966. private _evaluateSubMesh;
  33967. /**
  33968. * Clear the processed materials smart array preventing retention point in material dispose.
  33969. */
  33970. freeProcessedMaterials(): void;
  33971. private _preventFreeActiveMeshesAndRenderingGroups;
  33972. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  33973. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  33974. * when disposing several meshes in a row or a hierarchy of meshes.
  33975. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  33976. */
  33977. blockfreeActiveMeshesAndRenderingGroups: boolean;
  33978. /**
  33979. * Clear the active meshes smart array preventing retention point in mesh dispose.
  33980. */
  33981. freeActiveMeshes(): void;
  33982. /**
  33983. * Clear the info related to rendering groups preventing retention points during dispose.
  33984. */
  33985. freeRenderingGroups(): void;
  33986. /** @hidden */
  33987. _isInIntermediateRendering(): boolean;
  33988. /**
  33989. * Lambda returning the list of potentially active meshes.
  33990. */
  33991. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  33992. /**
  33993. * Lambda returning the list of potentially active sub meshes.
  33994. */
  33995. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  33996. /**
  33997. * Lambda returning the list of potentially intersecting sub meshes.
  33998. */
  33999. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  34000. /**
  34001. * Lambda returning the list of potentially colliding sub meshes.
  34002. */
  34003. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  34004. private _activeMeshesFrozen;
  34005. /**
  34006. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  34007. * @returns the current scene
  34008. */
  34009. freezeActiveMeshes(): Scene;
  34010. /**
  34011. * Use this function to restart evaluating active meshes on every frame
  34012. * @returns the current scene
  34013. */
  34014. unfreezeActiveMeshes(): Scene;
  34015. private _evaluateActiveMeshes;
  34016. private _activeMesh;
  34017. /**
  34018. * Update the transform matrix to update from the current active camera
  34019. * @param force defines a boolean used to force the update even if cache is up to date
  34020. */
  34021. updateTransformMatrix(force?: boolean): void;
  34022. private _bindFrameBuffer;
  34023. /** @hidden */
  34024. _allowPostProcessClearColor: boolean;
  34025. /** @hidden */
  34026. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  34027. private _processSubCameras;
  34028. private _checkIntersections;
  34029. /** @hidden */
  34030. _advancePhysicsEngineStep(step: number): void;
  34031. /**
  34032. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  34033. */
  34034. getDeterministicFrameTime: () => number;
  34035. /** @hidden */
  34036. _animate(): void;
  34037. /**
  34038. * Render the scene
  34039. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  34040. */
  34041. render(updateCameras?: boolean): void;
  34042. /**
  34043. * Freeze all materials
  34044. * A frozen material will not be updatable but should be faster to render
  34045. */
  34046. freezeMaterials(): void;
  34047. /**
  34048. * Unfreeze all materials
  34049. * A frozen material will not be updatable but should be faster to render
  34050. */
  34051. unfreezeMaterials(): void;
  34052. /**
  34053. * Releases all held ressources
  34054. */
  34055. dispose(): void;
  34056. /**
  34057. * Gets if the scene is already disposed
  34058. */
  34059. readonly isDisposed: boolean;
  34060. /**
  34061. * Call this function to reduce memory footprint of the scene.
  34062. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  34063. */
  34064. clearCachedVertexData(): void;
  34065. /**
  34066. * This function will remove the local cached buffer data from texture.
  34067. * It will save memory but will prevent the texture from being rebuilt
  34068. */
  34069. cleanCachedTextureBuffer(): void;
  34070. /**
  34071. * Get the world extend vectors with an optional filter
  34072. *
  34073. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  34074. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  34075. */
  34076. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  34077. min: Vector3;
  34078. max: Vector3;
  34079. };
  34080. /**
  34081. * Creates a ray that can be used to pick in the scene
  34082. * @param x defines the x coordinate of the origin (on-screen)
  34083. * @param y defines the y coordinate of the origin (on-screen)
  34084. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  34085. * @param camera defines the camera to use for the picking
  34086. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  34087. * @returns a Ray
  34088. */
  34089. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  34090. /**
  34091. * Creates a ray that can be used to pick in the scene
  34092. * @param x defines the x coordinate of the origin (on-screen)
  34093. * @param y defines the y coordinate of the origin (on-screen)
  34094. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  34095. * @param result defines the ray where to store the picking ray
  34096. * @param camera defines the camera to use for the picking
  34097. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  34098. * @returns the current scene
  34099. */
  34100. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  34101. /**
  34102. * Creates a ray that can be used to pick in the scene
  34103. * @param x defines the x coordinate of the origin (on-screen)
  34104. * @param y defines the y coordinate of the origin (on-screen)
  34105. * @param camera defines the camera to use for the picking
  34106. * @returns a Ray
  34107. */
  34108. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  34109. /**
  34110. * Creates a ray that can be used to pick in the scene
  34111. * @param x defines the x coordinate of the origin (on-screen)
  34112. * @param y defines the y coordinate of the origin (on-screen)
  34113. * @param result defines the ray where to store the picking ray
  34114. * @param camera defines the camera to use for the picking
  34115. * @returns the current scene
  34116. */
  34117. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  34118. /** Launch a ray to try to pick a mesh in the scene
  34119. * @param x position on screen
  34120. * @param y position on screen
  34121. * @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
  34122. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  34123. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  34124. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34125. * @returns a PickingInfo
  34126. */
  34127. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: (p0: Vector3, p1: Vector3, p2: Vector3) => boolean): Nullable<PickingInfo>;
  34128. /** Use the given ray to pick a mesh in the scene
  34129. * @param ray The ray to use to pick meshes
  34130. * @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
  34131. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  34132. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34133. * @returns a PickingInfo
  34134. */
  34135. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  34136. /**
  34137. * Launch a ray to try to pick a mesh in the scene
  34138. * @param x X position on screen
  34139. * @param y Y position on screen
  34140. * @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
  34141. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  34142. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34143. * @returns an array of PickingInfo
  34144. */
  34145. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  34146. /**
  34147. * Launch a ray to try to pick a mesh in the scene
  34148. * @param ray Ray to use
  34149. * @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
  34150. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34151. * @returns an array of PickingInfo
  34152. */
  34153. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  34154. /**
  34155. * Force the value of meshUnderPointer
  34156. * @param mesh defines the mesh to use
  34157. */
  34158. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  34159. /**
  34160. * Gets the mesh under the pointer
  34161. * @returns a Mesh or null if no mesh is under the pointer
  34162. */
  34163. getPointerOverMesh(): Nullable<AbstractMesh>;
  34164. /** @hidden */
  34165. _rebuildGeometries(): void;
  34166. /** @hidden */
  34167. _rebuildTextures(): void;
  34168. private _getByTags;
  34169. /**
  34170. * Get a list of meshes by tags
  34171. * @param tagsQuery defines the tags query to use
  34172. * @param forEach defines a predicate used to filter results
  34173. * @returns an array of Mesh
  34174. */
  34175. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  34176. /**
  34177. * Get a list of cameras by tags
  34178. * @param tagsQuery defines the tags query to use
  34179. * @param forEach defines a predicate used to filter results
  34180. * @returns an array of Camera
  34181. */
  34182. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  34183. /**
  34184. * Get a list of lights by tags
  34185. * @param tagsQuery defines the tags query to use
  34186. * @param forEach defines a predicate used to filter results
  34187. * @returns an array of Light
  34188. */
  34189. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  34190. /**
  34191. * Get a list of materials by tags
  34192. * @param tagsQuery defines the tags query to use
  34193. * @param forEach defines a predicate used to filter results
  34194. * @returns an array of Material
  34195. */
  34196. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  34197. /**
  34198. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  34199. * This allowed control for front to back rendering or reversly depending of the special needs.
  34200. *
  34201. * @param renderingGroupId The rendering group id corresponding to its index
  34202. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  34203. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  34204. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  34205. */
  34206. 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;
  34207. /**
  34208. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  34209. *
  34210. * @param renderingGroupId The rendering group id corresponding to its index
  34211. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  34212. * @param depth Automatically clears depth between groups if true and autoClear is true.
  34213. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  34214. */
  34215. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  34216. /**
  34217. * Gets the current auto clear configuration for one rendering group of the rendering
  34218. * manager.
  34219. * @param index the rendering group index to get the information for
  34220. * @returns The auto clear setup for the requested rendering group
  34221. */
  34222. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  34223. private _blockMaterialDirtyMechanism;
  34224. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  34225. blockMaterialDirtyMechanism: boolean;
  34226. /**
  34227. * Will flag all materials as dirty to trigger new shader compilation
  34228. * @param flag defines the flag used to specify which material part must be marked as dirty
  34229. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  34230. */
  34231. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  34232. /** @hidden */
  34233. _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;
  34234. /** @hidden */
  34235. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  34236. }
  34237. }
  34238. declare module "babylonjs/assetContainer" {
  34239. import { AbstractScene } from "babylonjs/abstractScene";
  34240. import { Scene } from "babylonjs/scene";
  34241. import { Mesh } from "babylonjs/Meshes/mesh";
  34242. /**
  34243. * Set of assets to keep when moving a scene into an asset container.
  34244. */
  34245. export class KeepAssets extends AbstractScene {
  34246. }
  34247. /**
  34248. * Container with a set of assets that can be added or removed from a scene.
  34249. */
  34250. export class AssetContainer extends AbstractScene {
  34251. /**
  34252. * The scene the AssetContainer belongs to.
  34253. */
  34254. scene: Scene;
  34255. /**
  34256. * Instantiates an AssetContainer.
  34257. * @param scene The scene the AssetContainer belongs to.
  34258. */
  34259. constructor(scene: Scene);
  34260. /**
  34261. * Adds all the assets from the container to the scene.
  34262. */
  34263. addAllToScene(): void;
  34264. /**
  34265. * Removes all the assets in the container from the scene
  34266. */
  34267. removeAllFromScene(): void;
  34268. /**
  34269. * Disposes all the assets in the container
  34270. */
  34271. dispose(): void;
  34272. private _moveAssets;
  34273. /**
  34274. * Removes all the assets contained in the scene and adds them to the container.
  34275. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  34276. */
  34277. moveAllFromScene(keepAssets?: KeepAssets): void;
  34278. /**
  34279. * 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.
  34280. * @returns the root mesh
  34281. */
  34282. createRootMesh(): Mesh;
  34283. }
  34284. }
  34285. declare module "babylonjs/abstractScene" {
  34286. import { Scene } from "babylonjs/scene";
  34287. import { Nullable } from "babylonjs/types";
  34288. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  34289. import { TransformNode } from "babylonjs/Meshes/transformNode";
  34290. import { Geometry } from "babylonjs/Meshes/geometry";
  34291. import { Skeleton } from "babylonjs/Bones/skeleton";
  34292. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  34293. import { AssetContainer } from "babylonjs/assetContainer";
  34294. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  34295. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  34296. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  34297. import { Material } from "babylonjs/Materials/material";
  34298. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  34299. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  34300. import { Camera } from "babylonjs/Cameras/camera";
  34301. import { Light } from "babylonjs/Lights/light";
  34302. import { Node } from "babylonjs/node";
  34303. import { Animation } from "babylonjs/Animations/animation";
  34304. /**
  34305. * Defines how the parser contract is defined.
  34306. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  34307. */
  34308. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  34309. /**
  34310. * Defines how the individual parser contract is defined.
  34311. * These parser can parse an individual asset
  34312. */
  34313. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  34314. /**
  34315. * Base class of the scene acting as a container for the different elements composing a scene.
  34316. * This class is dynamically extended by the different components of the scene increasing
  34317. * flexibility and reducing coupling
  34318. */
  34319. export abstract class AbstractScene {
  34320. /**
  34321. * Stores the list of available parsers in the application.
  34322. */
  34323. private static _BabylonFileParsers;
  34324. /**
  34325. * Stores the list of available individual parsers in the application.
  34326. */
  34327. private static _IndividualBabylonFileParsers;
  34328. /**
  34329. * Adds a parser in the list of available ones
  34330. * @param name Defines the name of the parser
  34331. * @param parser Defines the parser to add
  34332. */
  34333. static AddParser(name: string, parser: BabylonFileParser): void;
  34334. /**
  34335. * Gets a general parser from the list of avaialble ones
  34336. * @param name Defines the name of the parser
  34337. * @returns the requested parser or null
  34338. */
  34339. static GetParser(name: string): Nullable<BabylonFileParser>;
  34340. /**
  34341. * Adds n individual parser in the list of available ones
  34342. * @param name Defines the name of the parser
  34343. * @param parser Defines the parser to add
  34344. */
  34345. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  34346. /**
  34347. * Gets an individual parser from the list of avaialble ones
  34348. * @param name Defines the name of the parser
  34349. * @returns the requested parser or null
  34350. */
  34351. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  34352. /**
  34353. * Parser json data and populate both a scene and its associated container object
  34354. * @param jsonData Defines the data to parse
  34355. * @param scene Defines the scene to parse the data for
  34356. * @param container Defines the container attached to the parsing sequence
  34357. * @param rootUrl Defines the root url of the data
  34358. */
  34359. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  34360. /**
  34361. * Gets the list of root nodes (ie. nodes with no parent)
  34362. */
  34363. rootNodes: Node[];
  34364. /** All of the cameras added to this scene
  34365. * @see http://doc.babylonjs.com/babylon101/cameras
  34366. */
  34367. cameras: Camera[];
  34368. /**
  34369. * All of the lights added to this scene
  34370. * @see http://doc.babylonjs.com/babylon101/lights
  34371. */
  34372. lights: Light[];
  34373. /**
  34374. * All of the (abstract) meshes added to this scene
  34375. */
  34376. meshes: AbstractMesh[];
  34377. /**
  34378. * The list of skeletons added to the scene
  34379. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  34380. */
  34381. skeletons: Skeleton[];
  34382. /**
  34383. * All of the particle systems added to this scene
  34384. * @see http://doc.babylonjs.com/babylon101/particles
  34385. */
  34386. particleSystems: IParticleSystem[];
  34387. /**
  34388. * Gets a list of Animations associated with the scene
  34389. */
  34390. animations: Animation[];
  34391. /**
  34392. * All of the animation groups added to this scene
  34393. * @see http://doc.babylonjs.com/how_to/group
  34394. */
  34395. animationGroups: AnimationGroup[];
  34396. /**
  34397. * All of the multi-materials added to this scene
  34398. * @see http://doc.babylonjs.com/how_to/multi_materials
  34399. */
  34400. multiMaterials: MultiMaterial[];
  34401. /**
  34402. * All of the materials added to this scene
  34403. * In the context of a Scene, it is not supposed to be modified manually.
  34404. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  34405. * Note also that the order of the Material wihin the array is not significant and might change.
  34406. * @see http://doc.babylonjs.com/babylon101/materials
  34407. */
  34408. materials: Material[];
  34409. /**
  34410. * The list of morph target managers added to the scene
  34411. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  34412. */
  34413. morphTargetManagers: MorphTargetManager[];
  34414. /**
  34415. * The list of geometries used in the scene.
  34416. */
  34417. geometries: Geometry[];
  34418. /**
  34419. * All of the tranform nodes added to this scene
  34420. * In the context of a Scene, it is not supposed to be modified manually.
  34421. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  34422. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  34423. * @see http://doc.babylonjs.com/how_to/transformnode
  34424. */
  34425. transformNodes: TransformNode[];
  34426. /**
  34427. * ActionManagers available on the scene.
  34428. */
  34429. actionManagers: AbstractActionManager[];
  34430. /**
  34431. * Textures to keep.
  34432. */
  34433. textures: BaseTexture[];
  34434. /**
  34435. * Environment texture for the scene
  34436. */
  34437. environmentTexture: Nullable<BaseTexture>;
  34438. }
  34439. }
  34440. declare module "babylonjs/Audio/sound" {
  34441. import { Observable } from "babylonjs/Misc/observable";
  34442. import { Vector3 } from "babylonjs/Maths/math";
  34443. import { Nullable } from "babylonjs/types";
  34444. import { Scene } from "babylonjs/scene";
  34445. import { TransformNode } from "babylonjs/Meshes/transformNode";
  34446. /**
  34447. * Defines a sound that can be played in the application.
  34448. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  34449. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34450. */
  34451. export class Sound {
  34452. /**
  34453. * The name of the sound in the scene.
  34454. */
  34455. name: string;
  34456. /**
  34457. * Does the sound autoplay once loaded.
  34458. */
  34459. autoplay: boolean;
  34460. /**
  34461. * Does the sound loop after it finishes playing once.
  34462. */
  34463. loop: boolean;
  34464. /**
  34465. * Does the sound use a custom attenuation curve to simulate the falloff
  34466. * happening when the source gets further away from the camera.
  34467. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  34468. */
  34469. useCustomAttenuation: boolean;
  34470. /**
  34471. * The sound track id this sound belongs to.
  34472. */
  34473. soundTrackId: number;
  34474. /**
  34475. * Is this sound currently played.
  34476. */
  34477. isPlaying: boolean;
  34478. /**
  34479. * Is this sound currently paused.
  34480. */
  34481. isPaused: boolean;
  34482. /**
  34483. * Does this sound enables spatial sound.
  34484. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34485. */
  34486. spatialSound: boolean;
  34487. /**
  34488. * Define the reference distance the sound should be heard perfectly.
  34489. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34490. */
  34491. refDistance: number;
  34492. /**
  34493. * Define the roll off factor of spatial sounds.
  34494. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34495. */
  34496. rolloffFactor: number;
  34497. /**
  34498. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  34499. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34500. */
  34501. maxDistance: number;
  34502. /**
  34503. * Define the distance attenuation model the sound will follow.
  34504. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34505. */
  34506. distanceModel: string;
  34507. /**
  34508. * @hidden
  34509. * Back Compat
  34510. **/
  34511. onended: () => any;
  34512. /**
  34513. * Observable event when the current playing sound finishes.
  34514. */
  34515. onEndedObservable: Observable<Sound>;
  34516. private _panningModel;
  34517. private _playbackRate;
  34518. private _streaming;
  34519. private _startTime;
  34520. private _startOffset;
  34521. private _position;
  34522. /** @hidden */
  34523. _positionInEmitterSpace: boolean;
  34524. private _localDirection;
  34525. private _volume;
  34526. private _isReadyToPlay;
  34527. private _isDirectional;
  34528. private _readyToPlayCallback;
  34529. private _audioBuffer;
  34530. private _soundSource;
  34531. private _streamingSource;
  34532. private _soundPanner;
  34533. private _soundGain;
  34534. private _inputAudioNode;
  34535. private _outputAudioNode;
  34536. private _coneInnerAngle;
  34537. private _coneOuterAngle;
  34538. private _coneOuterGain;
  34539. private _scene;
  34540. private _connectedTransformNode;
  34541. private _customAttenuationFunction;
  34542. private _registerFunc;
  34543. private _isOutputConnected;
  34544. private _htmlAudioElement;
  34545. private _urlType;
  34546. /** @hidden */
  34547. static _SceneComponentInitialization: (scene: Scene) => void;
  34548. /**
  34549. * Create a sound and attach it to a scene
  34550. * @param name Name of your sound
  34551. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  34552. * @param scene defines the scene the sound belongs to
  34553. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  34554. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  34555. */
  34556. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  34557. /**
  34558. * Release the sound and its associated resources
  34559. */
  34560. dispose(): void;
  34561. /**
  34562. * Gets if the sounds is ready to be played or not.
  34563. * @returns true if ready, otherwise false
  34564. */
  34565. isReady(): boolean;
  34566. private _soundLoaded;
  34567. /**
  34568. * Sets the data of the sound from an audiobuffer
  34569. * @param audioBuffer The audioBuffer containing the data
  34570. */
  34571. setAudioBuffer(audioBuffer: AudioBuffer): void;
  34572. /**
  34573. * Updates the current sounds options such as maxdistance, loop...
  34574. * @param options A JSON object containing values named as the object properties
  34575. */
  34576. updateOptions(options: any): void;
  34577. private _createSpatialParameters;
  34578. private _updateSpatialParameters;
  34579. /**
  34580. * Switch the panning model to HRTF:
  34581. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  34582. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34583. */
  34584. switchPanningModelToHRTF(): void;
  34585. /**
  34586. * Switch the panning model to Equal Power:
  34587. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  34588. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34589. */
  34590. switchPanningModelToEqualPower(): void;
  34591. private _switchPanningModel;
  34592. /**
  34593. * Connect this sound to a sound track audio node like gain...
  34594. * @param soundTrackAudioNode the sound track audio node to connect to
  34595. */
  34596. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  34597. /**
  34598. * Transform this sound into a directional source
  34599. * @param coneInnerAngle Size of the inner cone in degree
  34600. * @param coneOuterAngle Size of the outer cone in degree
  34601. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  34602. */
  34603. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  34604. /**
  34605. * Gets or sets the inner angle for the directional cone.
  34606. */
  34607. /**
  34608. * Gets or sets the inner angle for the directional cone.
  34609. */
  34610. directionalConeInnerAngle: number;
  34611. /**
  34612. * Gets or sets the outer angle for the directional cone.
  34613. */
  34614. /**
  34615. * Gets or sets the outer angle for the directional cone.
  34616. */
  34617. directionalConeOuterAngle: number;
  34618. /**
  34619. * Sets the position of the emitter if spatial sound is enabled
  34620. * @param newPosition Defines the new posisiton
  34621. */
  34622. setPosition(newPosition: Vector3): void;
  34623. /**
  34624. * Sets the local direction of the emitter if spatial sound is enabled
  34625. * @param newLocalDirection Defines the new local direction
  34626. */
  34627. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  34628. private _updateDirection;
  34629. /** @hidden */
  34630. updateDistanceFromListener(): void;
  34631. /**
  34632. * Sets a new custom attenuation function for the sound.
  34633. * @param callback Defines the function used for the attenuation
  34634. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  34635. */
  34636. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  34637. /**
  34638. * Play the sound
  34639. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  34640. * @param offset (optional) Start the sound setting it at a specific time
  34641. */
  34642. play(time?: number, offset?: number): void;
  34643. private _onended;
  34644. /**
  34645. * Stop the sound
  34646. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  34647. */
  34648. stop(time?: number): void;
  34649. /**
  34650. * Put the sound in pause
  34651. */
  34652. pause(): void;
  34653. /**
  34654. * Sets a dedicated volume for this sounds
  34655. * @param newVolume Define the new volume of the sound
  34656. * @param time Define in how long the sound should be at this value
  34657. */
  34658. setVolume(newVolume: number, time?: number): void;
  34659. /**
  34660. * Set the sound play back rate
  34661. * @param newPlaybackRate Define the playback rate the sound should be played at
  34662. */
  34663. setPlaybackRate(newPlaybackRate: number): void;
  34664. /**
  34665. * Gets the volume of the sound.
  34666. * @returns the volume of the sound
  34667. */
  34668. getVolume(): number;
  34669. /**
  34670. * Attach the sound to a dedicated mesh
  34671. * @param transformNode The transform node to connect the sound with
  34672. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  34673. */
  34674. attachToMesh(transformNode: TransformNode): void;
  34675. /**
  34676. * Detach the sound from the previously attached mesh
  34677. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  34678. */
  34679. detachFromMesh(): void;
  34680. private _onRegisterAfterWorldMatrixUpdate;
  34681. /**
  34682. * Clone the current sound in the scene.
  34683. * @returns the new sound clone
  34684. */
  34685. clone(): Nullable<Sound>;
  34686. /**
  34687. * Gets the current underlying audio buffer containing the data
  34688. * @returns the audio buffer
  34689. */
  34690. getAudioBuffer(): Nullable<AudioBuffer>;
  34691. /**
  34692. * Serializes the Sound in a JSON representation
  34693. * @returns the JSON representation of the sound
  34694. */
  34695. serialize(): any;
  34696. /**
  34697. * Parse a JSON representation of a sound to innstantiate in a given scene
  34698. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  34699. * @param scene Define the scene the new parsed sound should be created in
  34700. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  34701. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  34702. * @returns the newly parsed sound
  34703. */
  34704. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  34705. }
  34706. }
  34707. declare module "babylonjs/Actions/directAudioActions" {
  34708. import { Action } from "babylonjs/Actions/action";
  34709. import { Condition } from "babylonjs/Actions/condition";
  34710. import { Sound } from "babylonjs/Audio/sound";
  34711. /**
  34712. * This defines an action helpful to play a defined sound on a triggered action.
  34713. */
  34714. export class PlaySoundAction extends Action {
  34715. private _sound;
  34716. /**
  34717. * Instantiate the action
  34718. * @param triggerOptions defines the trigger options
  34719. * @param sound defines the sound to play
  34720. * @param condition defines the trigger related conditions
  34721. */
  34722. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  34723. /** @hidden */
  34724. _prepare(): void;
  34725. /**
  34726. * Execute the action and play the sound.
  34727. */
  34728. execute(): void;
  34729. /**
  34730. * Serializes the actions and its related information.
  34731. * @param parent defines the object to serialize in
  34732. * @returns the serialized object
  34733. */
  34734. serialize(parent: any): any;
  34735. }
  34736. /**
  34737. * This defines an action helpful to stop a defined sound on a triggered action.
  34738. */
  34739. export class StopSoundAction extends Action {
  34740. private _sound;
  34741. /**
  34742. * Instantiate the action
  34743. * @param triggerOptions defines the trigger options
  34744. * @param sound defines the sound to stop
  34745. * @param condition defines the trigger related conditions
  34746. */
  34747. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  34748. /** @hidden */
  34749. _prepare(): void;
  34750. /**
  34751. * Execute the action and stop the sound.
  34752. */
  34753. execute(): void;
  34754. /**
  34755. * Serializes the actions and its related information.
  34756. * @param parent defines the object to serialize in
  34757. * @returns the serialized object
  34758. */
  34759. serialize(parent: any): any;
  34760. }
  34761. }
  34762. declare module "babylonjs/Actions/interpolateValueAction" {
  34763. import { Action } from "babylonjs/Actions/action";
  34764. import { Condition } from "babylonjs/Actions/condition";
  34765. import { Observable } from "babylonjs/Misc/observable";
  34766. /**
  34767. * This defines an action responsible to change the value of a property
  34768. * by interpolating between its current value and the newly set one once triggered.
  34769. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  34770. */
  34771. export class InterpolateValueAction extends Action {
  34772. /**
  34773. * Defines the path of the property where the value should be interpolated
  34774. */
  34775. propertyPath: string;
  34776. /**
  34777. * Defines the target value at the end of the interpolation.
  34778. */
  34779. value: any;
  34780. /**
  34781. * Defines the time it will take for the property to interpolate to the value.
  34782. */
  34783. duration: number;
  34784. /**
  34785. * Defines if the other scene animations should be stopped when the action has been triggered
  34786. */
  34787. stopOtherAnimations?: boolean;
  34788. /**
  34789. * Defines a callback raised once the interpolation animation has been done.
  34790. */
  34791. onInterpolationDone?: () => void;
  34792. /**
  34793. * Observable triggered once the interpolation animation has been done.
  34794. */
  34795. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  34796. private _target;
  34797. private _effectiveTarget;
  34798. private _property;
  34799. /**
  34800. * Instantiate the action
  34801. * @param triggerOptions defines the trigger options
  34802. * @param target defines the object containing the value to interpolate
  34803. * @param propertyPath defines the path to the property in the target object
  34804. * @param value defines the target value at the end of the interpolation
  34805. * @param duration deines the time it will take for the property to interpolate to the value.
  34806. * @param condition defines the trigger related conditions
  34807. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  34808. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  34809. */
  34810. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  34811. /** @hidden */
  34812. _prepare(): void;
  34813. /**
  34814. * Execute the action starts the value interpolation.
  34815. */
  34816. execute(): void;
  34817. /**
  34818. * Serializes the actions and its related information.
  34819. * @param parent defines the object to serialize in
  34820. * @returns the serialized object
  34821. */
  34822. serialize(parent: any): any;
  34823. }
  34824. }
  34825. declare module "babylonjs/Actions/index" {
  34826. export * from "babylonjs/Actions/action";
  34827. export * from "babylonjs/Actions/actionEvent";
  34828. export * from "babylonjs/Actions/actionManager";
  34829. export * from "babylonjs/Actions/condition";
  34830. export * from "babylonjs/Actions/directActions";
  34831. export * from "babylonjs/Actions/directAudioActions";
  34832. export * from "babylonjs/Actions/interpolateValueAction";
  34833. }
  34834. declare module "babylonjs/Animations/index" {
  34835. export * from "babylonjs/Animations/animatable";
  34836. export * from "babylonjs/Animations/animation";
  34837. export * from "babylonjs/Animations/animationGroup";
  34838. export * from "babylonjs/Animations/animationPropertiesOverride";
  34839. export * from "babylonjs/Animations/easing";
  34840. export * from "babylonjs/Animations/runtimeAnimation";
  34841. export * from "babylonjs/Animations/animationEvent";
  34842. export * from "babylonjs/Animations/animationGroup";
  34843. export * from "babylonjs/Animations/animationKey";
  34844. export * from "babylonjs/Animations/animationRange";
  34845. }
  34846. declare module "babylonjs/Audio/soundTrack" {
  34847. import { Sound } from "babylonjs/Audio/sound";
  34848. import { Analyser } from "babylonjs/Audio/analyser";
  34849. import { Scene } from "babylonjs/scene";
  34850. /**
  34851. * Options allowed during the creation of a sound track.
  34852. */
  34853. export interface ISoundTrackOptions {
  34854. /**
  34855. * The volume the sound track should take during creation
  34856. */
  34857. volume?: number;
  34858. /**
  34859. * Define if the sound track is the main sound track of the scene
  34860. */
  34861. mainTrack?: boolean;
  34862. }
  34863. /**
  34864. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  34865. * It will be also used in a future release to apply effects on a specific track.
  34866. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  34867. */
  34868. export class SoundTrack {
  34869. /**
  34870. * The unique identifier of the sound track in the scene.
  34871. */
  34872. id: number;
  34873. /**
  34874. * The list of sounds included in the sound track.
  34875. */
  34876. soundCollection: Array<Sound>;
  34877. private _outputAudioNode;
  34878. private _scene;
  34879. private _isMainTrack;
  34880. private _connectedAnalyser;
  34881. private _options;
  34882. private _isInitialized;
  34883. /**
  34884. * Creates a new sound track.
  34885. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  34886. * @param scene Define the scene the sound track belongs to
  34887. * @param options
  34888. */
  34889. constructor(scene: Scene, options?: ISoundTrackOptions);
  34890. private _initializeSoundTrackAudioGraph;
  34891. /**
  34892. * Release the sound track and its associated resources
  34893. */
  34894. dispose(): void;
  34895. /**
  34896. * Adds a sound to this sound track
  34897. * @param sound define the cound to add
  34898. * @ignoreNaming
  34899. */
  34900. AddSound(sound: Sound): void;
  34901. /**
  34902. * Removes a sound to this sound track
  34903. * @param sound define the cound to remove
  34904. * @ignoreNaming
  34905. */
  34906. RemoveSound(sound: Sound): void;
  34907. /**
  34908. * Set a global volume for the full sound track.
  34909. * @param newVolume Define the new volume of the sound track
  34910. */
  34911. setVolume(newVolume: number): void;
  34912. /**
  34913. * Switch the panning model to HRTF:
  34914. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  34915. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34916. */
  34917. switchPanningModelToHRTF(): void;
  34918. /**
  34919. * Switch the panning model to Equal Power:
  34920. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  34921. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34922. */
  34923. switchPanningModelToEqualPower(): void;
  34924. /**
  34925. * Connect the sound track to an audio analyser allowing some amazing
  34926. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  34927. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  34928. * @param analyser The analyser to connect to the engine
  34929. */
  34930. connectToAnalyser(analyser: Analyser): void;
  34931. }
  34932. }
  34933. declare module "babylonjs/Audio/audioSceneComponent" {
  34934. import { Sound } from "babylonjs/Audio/sound";
  34935. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  34936. import { Nullable } from "babylonjs/types";
  34937. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  34938. import { Scene } from "babylonjs/scene";
  34939. import { AbstractScene } from "babylonjs/abstractScene";
  34940. module "babylonjs/abstractScene" {
  34941. interface AbstractScene {
  34942. /**
  34943. * The list of sounds used in the scene.
  34944. */
  34945. sounds: Nullable<Array<Sound>>;
  34946. }
  34947. }
  34948. module "babylonjs/scene" {
  34949. interface Scene {
  34950. /**
  34951. * @hidden
  34952. * Backing field
  34953. */
  34954. _mainSoundTrack: SoundTrack;
  34955. /**
  34956. * The main sound track played by the scene.
  34957. * It cotains your primary collection of sounds.
  34958. */
  34959. mainSoundTrack: SoundTrack;
  34960. /**
  34961. * The list of sound tracks added to the scene
  34962. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34963. */
  34964. soundTracks: Nullable<Array<SoundTrack>>;
  34965. /**
  34966. * Gets a sound using a given name
  34967. * @param name defines the name to search for
  34968. * @return the found sound or null if not found at all.
  34969. */
  34970. getSoundByName(name: string): Nullable<Sound>;
  34971. /**
  34972. * Gets or sets if audio support is enabled
  34973. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34974. */
  34975. audioEnabled: boolean;
  34976. /**
  34977. * Gets or sets if audio will be output to headphones
  34978. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34979. */
  34980. headphone: boolean;
  34981. }
  34982. }
  34983. /**
  34984. * Defines the sound scene component responsible to manage any sounds
  34985. * in a given scene.
  34986. */
  34987. export class AudioSceneComponent implements ISceneSerializableComponent {
  34988. /**
  34989. * The component name helpfull to identify the component in the list of scene components.
  34990. */
  34991. readonly name: string;
  34992. /**
  34993. * The scene the component belongs to.
  34994. */
  34995. scene: Scene;
  34996. private _audioEnabled;
  34997. /**
  34998. * Gets whether audio is enabled or not.
  34999. * Please use related enable/disable method to switch state.
  35000. */
  35001. readonly audioEnabled: boolean;
  35002. private _headphone;
  35003. /**
  35004. * Gets whether audio is outputing to headphone or not.
  35005. * Please use the according Switch methods to change output.
  35006. */
  35007. readonly headphone: boolean;
  35008. /**
  35009. * Creates a new instance of the component for the given scene
  35010. * @param scene Defines the scene to register the component in
  35011. */
  35012. constructor(scene: Scene);
  35013. /**
  35014. * Registers the component in a given scene
  35015. */
  35016. register(): void;
  35017. /**
  35018. * Rebuilds the elements related to this component in case of
  35019. * context lost for instance.
  35020. */
  35021. rebuild(): void;
  35022. /**
  35023. * Serializes the component data to the specified json object
  35024. * @param serializationObject The object to serialize to
  35025. */
  35026. serialize(serializationObject: any): void;
  35027. /**
  35028. * Adds all the element from the container to the scene
  35029. * @param container the container holding the elements
  35030. */
  35031. addFromContainer(container: AbstractScene): void;
  35032. /**
  35033. * Removes all the elements in the container from the scene
  35034. * @param container contains the elements to remove
  35035. * @param dispose if the removed element should be disposed (default: false)
  35036. */
  35037. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  35038. /**
  35039. * Disposes the component and the associated ressources.
  35040. */
  35041. dispose(): void;
  35042. /**
  35043. * Disables audio in the associated scene.
  35044. */
  35045. disableAudio(): void;
  35046. /**
  35047. * Enables audio in the associated scene.
  35048. */
  35049. enableAudio(): void;
  35050. /**
  35051. * Switch audio to headphone output.
  35052. */
  35053. switchAudioModeForHeadphones(): void;
  35054. /**
  35055. * Switch audio to normal speakers.
  35056. */
  35057. switchAudioModeForNormalSpeakers(): void;
  35058. private _afterRender;
  35059. }
  35060. }
  35061. declare module "babylonjs/Audio/weightedsound" {
  35062. import { Sound } from "babylonjs/Audio/sound";
  35063. /**
  35064. * Wraps one or more Sound objects and selects one with random weight for playback.
  35065. */
  35066. export class WeightedSound {
  35067. /** When true a Sound will be selected and played when the current playing Sound completes. */
  35068. loop: boolean;
  35069. private _coneInnerAngle;
  35070. private _coneOuterAngle;
  35071. private _volume;
  35072. /** A Sound is currently playing. */
  35073. isPlaying: boolean;
  35074. /** A Sound is currently paused. */
  35075. isPaused: boolean;
  35076. private _sounds;
  35077. private _weights;
  35078. private _currentIndex?;
  35079. /**
  35080. * Creates a new WeightedSound from the list of sounds given.
  35081. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  35082. * @param sounds Array of Sounds that will be selected from.
  35083. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  35084. */
  35085. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  35086. /**
  35087. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  35088. */
  35089. /**
  35090. * The size of cone in degress for a directional sound in which there will be no attenuation.
  35091. */
  35092. directionalConeInnerAngle: number;
  35093. /**
  35094. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  35095. * Listener angles between innerAngle and outerAngle will falloff linearly.
  35096. */
  35097. /**
  35098. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  35099. * Listener angles between innerAngle and outerAngle will falloff linearly.
  35100. */
  35101. directionalConeOuterAngle: number;
  35102. /**
  35103. * Playback volume.
  35104. */
  35105. /**
  35106. * Playback volume.
  35107. */
  35108. volume: number;
  35109. private _onended;
  35110. /**
  35111. * Suspend playback
  35112. */
  35113. pause(): void;
  35114. /**
  35115. * Stop playback
  35116. */
  35117. stop(): void;
  35118. /**
  35119. * Start playback.
  35120. * @param startOffset Position the clip head at a specific time in seconds.
  35121. */
  35122. play(startOffset?: number): void;
  35123. }
  35124. }
  35125. declare module "babylonjs/Audio/index" {
  35126. export * from "babylonjs/Audio/analyser";
  35127. export * from "babylonjs/Audio/audioEngine";
  35128. export * from "babylonjs/Audio/audioSceneComponent";
  35129. export * from "babylonjs/Audio/sound";
  35130. export * from "babylonjs/Audio/soundTrack";
  35131. export * from "babylonjs/Audio/weightedsound";
  35132. }
  35133. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  35134. import { Behavior } from "babylonjs/Behaviors/behavior";
  35135. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35136. import { BackEase } from "babylonjs/Animations/easing";
  35137. /**
  35138. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  35139. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  35140. */
  35141. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  35142. /**
  35143. * Gets the name of the behavior.
  35144. */
  35145. readonly name: string;
  35146. /**
  35147. * The easing function used by animations
  35148. */
  35149. static EasingFunction: BackEase;
  35150. /**
  35151. * The easing mode used by animations
  35152. */
  35153. static EasingMode: number;
  35154. /**
  35155. * The duration of the animation, in milliseconds
  35156. */
  35157. transitionDuration: number;
  35158. /**
  35159. * Length of the distance animated by the transition when lower radius is reached
  35160. */
  35161. lowerRadiusTransitionRange: number;
  35162. /**
  35163. * Length of the distance animated by the transition when upper radius is reached
  35164. */
  35165. upperRadiusTransitionRange: number;
  35166. private _autoTransitionRange;
  35167. /**
  35168. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  35169. */
  35170. /**
  35171. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  35172. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  35173. */
  35174. autoTransitionRange: boolean;
  35175. private _attachedCamera;
  35176. private _onAfterCheckInputsObserver;
  35177. private _onMeshTargetChangedObserver;
  35178. /**
  35179. * Initializes the behavior.
  35180. */
  35181. init(): void;
  35182. /**
  35183. * Attaches the behavior to its arc rotate camera.
  35184. * @param camera Defines the camera to attach the behavior to
  35185. */
  35186. attach(camera: ArcRotateCamera): void;
  35187. /**
  35188. * Detaches the behavior from its current arc rotate camera.
  35189. */
  35190. detach(): void;
  35191. private _radiusIsAnimating;
  35192. private _radiusBounceTransition;
  35193. private _animatables;
  35194. private _cachedWheelPrecision;
  35195. /**
  35196. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  35197. * @param radiusLimit The limit to check against.
  35198. * @return Bool to indicate if at limit.
  35199. */
  35200. private _isRadiusAtLimit;
  35201. /**
  35202. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  35203. * @param radiusDelta The delta by which to animate to. Can be negative.
  35204. */
  35205. private _applyBoundRadiusAnimation;
  35206. /**
  35207. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  35208. */
  35209. protected _clearAnimationLocks(): void;
  35210. /**
  35211. * Stops and removes all animations that have been applied to the camera
  35212. */
  35213. stopAllAnimations(): void;
  35214. }
  35215. }
  35216. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  35217. import { Behavior } from "babylonjs/Behaviors/behavior";
  35218. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35219. import { ExponentialEase } from "babylonjs/Animations/easing";
  35220. import { Nullable } from "babylonjs/types";
  35221. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35222. import { Vector3 } from "babylonjs/Maths/math";
  35223. /**
  35224. * 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.
  35225. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  35226. */
  35227. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  35228. /**
  35229. * Gets the name of the behavior.
  35230. */
  35231. readonly name: string;
  35232. private _mode;
  35233. private _radiusScale;
  35234. private _positionScale;
  35235. private _defaultElevation;
  35236. private _elevationReturnTime;
  35237. private _elevationReturnWaitTime;
  35238. private _zoomStopsAnimation;
  35239. private _framingTime;
  35240. /**
  35241. * The easing function used by animations
  35242. */
  35243. static EasingFunction: ExponentialEase;
  35244. /**
  35245. * The easing mode used by animations
  35246. */
  35247. static EasingMode: number;
  35248. /**
  35249. * Sets the current mode used by the behavior
  35250. */
  35251. /**
  35252. * Gets current mode used by the behavior.
  35253. */
  35254. mode: number;
  35255. /**
  35256. * Sets the scale applied to the radius (1 by default)
  35257. */
  35258. /**
  35259. * Gets the scale applied to the radius
  35260. */
  35261. radiusScale: number;
  35262. /**
  35263. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  35264. */
  35265. /**
  35266. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  35267. */
  35268. positionScale: number;
  35269. /**
  35270. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  35271. * behaviour is triggered, in radians.
  35272. */
  35273. /**
  35274. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  35275. * behaviour is triggered, in radians.
  35276. */
  35277. defaultElevation: number;
  35278. /**
  35279. * Sets the time (in milliseconds) taken to return to the default beta position.
  35280. * Negative value indicates camera should not return to default.
  35281. */
  35282. /**
  35283. * Gets the time (in milliseconds) taken to return to the default beta position.
  35284. * Negative value indicates camera should not return to default.
  35285. */
  35286. elevationReturnTime: number;
  35287. /**
  35288. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  35289. */
  35290. /**
  35291. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  35292. */
  35293. elevationReturnWaitTime: number;
  35294. /**
  35295. * Sets the flag that indicates if user zooming should stop animation.
  35296. */
  35297. /**
  35298. * Gets the flag that indicates if user zooming should stop animation.
  35299. */
  35300. zoomStopsAnimation: boolean;
  35301. /**
  35302. * Sets the transition time when framing the mesh, in milliseconds
  35303. */
  35304. /**
  35305. * Gets the transition time when framing the mesh, in milliseconds
  35306. */
  35307. framingTime: number;
  35308. /**
  35309. * Define if the behavior should automatically change the configured
  35310. * camera limits and sensibilities.
  35311. */
  35312. autoCorrectCameraLimitsAndSensibility: boolean;
  35313. private _onPrePointerObservableObserver;
  35314. private _onAfterCheckInputsObserver;
  35315. private _onMeshTargetChangedObserver;
  35316. private _attachedCamera;
  35317. private _isPointerDown;
  35318. private _lastInteractionTime;
  35319. /**
  35320. * Initializes the behavior.
  35321. */
  35322. init(): void;
  35323. /**
  35324. * Attaches the behavior to its arc rotate camera.
  35325. * @param camera Defines the camera to attach the behavior to
  35326. */
  35327. attach(camera: ArcRotateCamera): void;
  35328. /**
  35329. * Detaches the behavior from its current arc rotate camera.
  35330. */
  35331. detach(): void;
  35332. private _animatables;
  35333. private _betaIsAnimating;
  35334. private _betaTransition;
  35335. private _radiusTransition;
  35336. private _vectorTransition;
  35337. /**
  35338. * Targets the given mesh and updates zoom level accordingly.
  35339. * @param mesh The mesh to target.
  35340. * @param radius Optional. If a cached radius position already exists, overrides default.
  35341. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35342. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35343. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35344. */
  35345. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35346. /**
  35347. * Targets the given mesh with its children and updates zoom level accordingly.
  35348. * @param mesh The mesh to target.
  35349. * @param radius Optional. If a cached radius position already exists, overrides default.
  35350. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35351. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35352. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35353. */
  35354. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35355. /**
  35356. * Targets the given meshes with their children and updates zoom level accordingly.
  35357. * @param meshes The mesh to target.
  35358. * @param radius Optional. If a cached radius position already exists, overrides default.
  35359. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35360. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35361. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35362. */
  35363. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35364. /**
  35365. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  35366. * @param minimumWorld Determines the smaller position of the bounding box extend
  35367. * @param maximumWorld Determines the bigger position of the bounding box extend
  35368. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35369. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35370. */
  35371. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35372. /**
  35373. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  35374. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  35375. * frustum width.
  35376. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  35377. * to fully enclose the mesh in the viewing frustum.
  35378. */
  35379. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  35380. /**
  35381. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  35382. * is automatically returned to its default position (expected to be above ground plane).
  35383. */
  35384. private _maintainCameraAboveGround;
  35385. /**
  35386. * Returns the frustum slope based on the canvas ratio and camera FOV
  35387. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  35388. */
  35389. private _getFrustumSlope;
  35390. /**
  35391. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  35392. */
  35393. private _clearAnimationLocks;
  35394. /**
  35395. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  35396. */
  35397. private _applyUserInteraction;
  35398. /**
  35399. * Stops and removes all animations that have been applied to the camera
  35400. */
  35401. stopAllAnimations(): void;
  35402. /**
  35403. * Gets a value indicating if the user is moving the camera
  35404. */
  35405. readonly isUserIsMoving: boolean;
  35406. /**
  35407. * The camera can move all the way towards the mesh.
  35408. */
  35409. static IgnoreBoundsSizeMode: number;
  35410. /**
  35411. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  35412. */
  35413. static FitFrustumSidesMode: number;
  35414. }
  35415. }
  35416. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  35417. import { Nullable } from "babylonjs/types";
  35418. import { Camera } from "babylonjs/Cameras/camera";
  35419. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  35420. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  35421. /**
  35422. * Base class for Camera Pointer Inputs.
  35423. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  35424. * for example usage.
  35425. */
  35426. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  35427. /**
  35428. * Defines the camera the input is attached to.
  35429. */
  35430. abstract camera: Camera;
  35431. /**
  35432. * Whether keyboard modifier keys are pressed at time of last mouse event.
  35433. */
  35434. protected _altKey: boolean;
  35435. protected _ctrlKey: boolean;
  35436. protected _metaKey: boolean;
  35437. protected _shiftKey: boolean;
  35438. /**
  35439. * Which mouse buttons were pressed at time of last mouse event.
  35440. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  35441. */
  35442. protected _buttonsPressed: number;
  35443. /**
  35444. * Defines the buttons associated with the input to handle camera move.
  35445. */
  35446. buttons: number[];
  35447. /**
  35448. * Attach the input controls to a specific dom element to get the input from.
  35449. * @param element Defines the element the controls should be listened from
  35450. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35451. */
  35452. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35453. /**
  35454. * Detach the current controls from the specified dom element.
  35455. * @param element Defines the element to stop listening the inputs from
  35456. */
  35457. detachControl(element: Nullable<HTMLElement>): void;
  35458. /**
  35459. * Gets the class name of the current input.
  35460. * @returns the class name
  35461. */
  35462. getClassName(): string;
  35463. /**
  35464. * Get the friendly name associated with the input class.
  35465. * @returns the input friendly name
  35466. */
  35467. getSimpleName(): string;
  35468. /**
  35469. * Called on pointer POINTERDOUBLETAP event.
  35470. * Override this method to provide functionality on POINTERDOUBLETAP event.
  35471. */
  35472. protected onDoubleTap(type: string): void;
  35473. /**
  35474. * Called on pointer POINTERMOVE event if only a single touch is active.
  35475. * Override this method to provide functionality.
  35476. */
  35477. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  35478. /**
  35479. * Called on pointer POINTERMOVE event if multiple touches are active.
  35480. * Override this method to provide functionality.
  35481. */
  35482. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  35483. /**
  35484. * Called on JS contextmenu event.
  35485. * Override this method to provide functionality.
  35486. */
  35487. protected onContextMenu(evt: PointerEvent): void;
  35488. /**
  35489. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  35490. * press.
  35491. * Override this method to provide functionality.
  35492. */
  35493. protected onButtonDown(evt: PointerEvent): void;
  35494. /**
  35495. * Called each time a new POINTERUP event occurs. Ie, for each button
  35496. * release.
  35497. * Override this method to provide functionality.
  35498. */
  35499. protected onButtonUp(evt: PointerEvent): void;
  35500. /**
  35501. * Called when window becomes inactive.
  35502. * Override this method to provide functionality.
  35503. */
  35504. protected onLostFocus(): void;
  35505. private _pointerInput;
  35506. private _observer;
  35507. private _onLostFocus;
  35508. private pointA;
  35509. private pointB;
  35510. }
  35511. }
  35512. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  35513. import { Nullable } from "babylonjs/types";
  35514. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35515. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  35516. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  35517. /**
  35518. * Manage the pointers inputs to control an arc rotate camera.
  35519. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35520. */
  35521. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  35522. /**
  35523. * Defines the camera the input is attached to.
  35524. */
  35525. camera: ArcRotateCamera;
  35526. /**
  35527. * Gets the class name of the current input.
  35528. * @returns the class name
  35529. */
  35530. getClassName(): string;
  35531. /**
  35532. * Defines the buttons associated with the input to handle camera move.
  35533. */
  35534. buttons: number[];
  35535. /**
  35536. * Defines the pointer angular sensibility along the X axis or how fast is
  35537. * the camera rotating.
  35538. */
  35539. angularSensibilityX: number;
  35540. /**
  35541. * Defines the pointer angular sensibility along the Y axis or how fast is
  35542. * the camera rotating.
  35543. */
  35544. angularSensibilityY: number;
  35545. /**
  35546. * Defines the pointer pinch precision or how fast is the camera zooming.
  35547. */
  35548. pinchPrecision: number;
  35549. /**
  35550. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  35551. * from 0.
  35552. * It defines the percentage of current camera.radius to use as delta when
  35553. * pinch zoom is used.
  35554. */
  35555. pinchDeltaPercentage: number;
  35556. /**
  35557. * Defines the pointer panning sensibility or how fast is the camera moving.
  35558. */
  35559. panningSensibility: number;
  35560. /**
  35561. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  35562. */
  35563. multiTouchPanning: boolean;
  35564. /**
  35565. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  35566. * zoom (pinch) through multitouch.
  35567. */
  35568. multiTouchPanAndZoom: boolean;
  35569. /**
  35570. * Revers pinch action direction.
  35571. */
  35572. pinchInwards: boolean;
  35573. private _isPanClick;
  35574. private _twoFingerActivityCount;
  35575. private _isPinching;
  35576. /**
  35577. * Called on pointer POINTERMOVE event if only a single touch is active.
  35578. */
  35579. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  35580. /**
  35581. * Called on pointer POINTERDOUBLETAP event.
  35582. */
  35583. protected onDoubleTap(type: string): void;
  35584. /**
  35585. * Called on pointer POINTERMOVE event if multiple touches are active.
  35586. */
  35587. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  35588. /**
  35589. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  35590. * press.
  35591. */
  35592. protected onButtonDown(evt: PointerEvent): void;
  35593. /**
  35594. * Called each time a new POINTERUP event occurs. Ie, for each button
  35595. * release.
  35596. */
  35597. protected onButtonUp(evt: PointerEvent): void;
  35598. /**
  35599. * Called when window becomes inactive.
  35600. */
  35601. protected onLostFocus(): void;
  35602. }
  35603. }
  35604. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  35605. import { Nullable } from "babylonjs/types";
  35606. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35607. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  35608. /**
  35609. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  35610. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35611. */
  35612. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  35613. /**
  35614. * Defines the camera the input is attached to.
  35615. */
  35616. camera: ArcRotateCamera;
  35617. /**
  35618. * Defines the list of key codes associated with the up action (increase alpha)
  35619. */
  35620. keysUp: number[];
  35621. /**
  35622. * Defines the list of key codes associated with the down action (decrease alpha)
  35623. */
  35624. keysDown: number[];
  35625. /**
  35626. * Defines the list of key codes associated with the left action (increase beta)
  35627. */
  35628. keysLeft: number[];
  35629. /**
  35630. * Defines the list of key codes associated with the right action (decrease beta)
  35631. */
  35632. keysRight: number[];
  35633. /**
  35634. * Defines the list of key codes associated with the reset action.
  35635. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  35636. */
  35637. keysReset: number[];
  35638. /**
  35639. * Defines the panning sensibility of the inputs.
  35640. * (How fast is the camera paning)
  35641. */
  35642. panningSensibility: number;
  35643. /**
  35644. * Defines the zooming sensibility of the inputs.
  35645. * (How fast is the camera zooming)
  35646. */
  35647. zoomingSensibility: number;
  35648. /**
  35649. * Defines wether maintaining the alt key down switch the movement mode from
  35650. * orientation to zoom.
  35651. */
  35652. useAltToZoom: boolean;
  35653. /**
  35654. * Rotation speed of the camera
  35655. */
  35656. angularSpeed: number;
  35657. private _keys;
  35658. private _ctrlPressed;
  35659. private _altPressed;
  35660. private _onCanvasBlurObserver;
  35661. private _onKeyboardObserver;
  35662. private _engine;
  35663. private _scene;
  35664. /**
  35665. * Attach the input controls to a specific dom element to get the input from.
  35666. * @param element Defines the element the controls should be listened from
  35667. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35668. */
  35669. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35670. /**
  35671. * Detach the current controls from the specified dom element.
  35672. * @param element Defines the element to stop listening the inputs from
  35673. */
  35674. detachControl(element: Nullable<HTMLElement>): void;
  35675. /**
  35676. * Update the current camera state depending on the inputs that have been used this frame.
  35677. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  35678. */
  35679. checkInputs(): void;
  35680. /**
  35681. * Gets the class name of the current intput.
  35682. * @returns the class name
  35683. */
  35684. getClassName(): string;
  35685. /**
  35686. * Get the friendly name associated with the input class.
  35687. * @returns the input friendly name
  35688. */
  35689. getSimpleName(): string;
  35690. }
  35691. }
  35692. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  35693. import { Nullable } from "babylonjs/types";
  35694. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35695. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  35696. /**
  35697. * Manage the mouse wheel inputs to control an arc rotate camera.
  35698. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35699. */
  35700. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  35701. /**
  35702. * Defines the camera the input is attached to.
  35703. */
  35704. camera: ArcRotateCamera;
  35705. /**
  35706. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  35707. */
  35708. wheelPrecision: number;
  35709. /**
  35710. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  35711. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  35712. */
  35713. wheelDeltaPercentage: number;
  35714. private _wheel;
  35715. private _observer;
  35716. /**
  35717. * Attach the input controls to a specific dom element to get the input from.
  35718. * @param element Defines the element the controls should be listened from
  35719. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35720. */
  35721. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35722. /**
  35723. * Detach the current controls from the specified dom element.
  35724. * @param element Defines the element to stop listening the inputs from
  35725. */
  35726. detachControl(element: Nullable<HTMLElement>): void;
  35727. /**
  35728. * Gets the class name of the current intput.
  35729. * @returns the class name
  35730. */
  35731. getClassName(): string;
  35732. /**
  35733. * Get the friendly name associated with the input class.
  35734. * @returns the input friendly name
  35735. */
  35736. getSimpleName(): string;
  35737. }
  35738. }
  35739. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  35740. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35741. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  35742. /**
  35743. * Default Inputs manager for the ArcRotateCamera.
  35744. * It groups all the default supported inputs for ease of use.
  35745. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35746. */
  35747. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  35748. /**
  35749. * Instantiates a new ArcRotateCameraInputsManager.
  35750. * @param camera Defines the camera the inputs belong to
  35751. */
  35752. constructor(camera: ArcRotateCamera);
  35753. /**
  35754. * Add mouse wheel input support to the input manager.
  35755. * @returns the current input manager
  35756. */
  35757. addMouseWheel(): ArcRotateCameraInputsManager;
  35758. /**
  35759. * Add pointers input support to the input manager.
  35760. * @returns the current input manager
  35761. */
  35762. addPointers(): ArcRotateCameraInputsManager;
  35763. /**
  35764. * Add keyboard input support to the input manager.
  35765. * @returns the current input manager
  35766. */
  35767. addKeyboard(): ArcRotateCameraInputsManager;
  35768. }
  35769. }
  35770. declare module "babylonjs/Cameras/arcRotateCamera" {
  35771. import { Observable } from "babylonjs/Misc/observable";
  35772. import { Nullable } from "babylonjs/types";
  35773. import { Scene } from "babylonjs/scene";
  35774. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math";
  35775. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35776. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  35777. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  35778. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  35779. import { Camera } from "babylonjs/Cameras/camera";
  35780. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  35781. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  35782. import { Collider } from "babylonjs/Collisions/collider";
  35783. /**
  35784. * This represents an orbital type of camera.
  35785. *
  35786. * 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.
  35787. * 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.
  35788. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  35789. */
  35790. export class ArcRotateCamera extends TargetCamera {
  35791. /**
  35792. * Defines the rotation angle of the camera along the longitudinal axis.
  35793. */
  35794. alpha: number;
  35795. /**
  35796. * Defines the rotation angle of the camera along the latitudinal axis.
  35797. */
  35798. beta: number;
  35799. /**
  35800. * Defines the radius of the camera from it s target point.
  35801. */
  35802. radius: number;
  35803. protected _target: Vector3;
  35804. protected _targetHost: Nullable<AbstractMesh>;
  35805. /**
  35806. * Defines the target point of the camera.
  35807. * The camera looks towards it form the radius distance.
  35808. */
  35809. target: Vector3;
  35810. /**
  35811. * Define the current local position of the camera in the scene
  35812. */
  35813. position: Vector3;
  35814. protected _upVector: Vector3;
  35815. protected _upToYMatrix: Matrix;
  35816. protected _YToUpMatrix: Matrix;
  35817. /**
  35818. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  35819. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  35820. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  35821. */
  35822. upVector: Vector3;
  35823. /**
  35824. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  35825. */
  35826. setMatUp(): void;
  35827. /**
  35828. * Current inertia value on the longitudinal axis.
  35829. * The bigger this number the longer it will take for the camera to stop.
  35830. */
  35831. inertialAlphaOffset: number;
  35832. /**
  35833. * Current inertia value on the latitudinal axis.
  35834. * The bigger this number the longer it will take for the camera to stop.
  35835. */
  35836. inertialBetaOffset: number;
  35837. /**
  35838. * Current inertia value on the radius axis.
  35839. * The bigger this number the longer it will take for the camera to stop.
  35840. */
  35841. inertialRadiusOffset: number;
  35842. /**
  35843. * Minimum allowed angle on the longitudinal axis.
  35844. * This can help limiting how the Camera is able to move in the scene.
  35845. */
  35846. lowerAlphaLimit: Nullable<number>;
  35847. /**
  35848. * Maximum allowed angle on the longitudinal axis.
  35849. * This can help limiting how the Camera is able to move in the scene.
  35850. */
  35851. upperAlphaLimit: Nullable<number>;
  35852. /**
  35853. * Minimum allowed angle on the latitudinal axis.
  35854. * This can help limiting how the Camera is able to move in the scene.
  35855. */
  35856. lowerBetaLimit: number;
  35857. /**
  35858. * Maximum allowed angle on the latitudinal axis.
  35859. * This can help limiting how the Camera is able to move in the scene.
  35860. */
  35861. upperBetaLimit: number;
  35862. /**
  35863. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  35864. * This can help limiting how the Camera is able to move in the scene.
  35865. */
  35866. lowerRadiusLimit: Nullable<number>;
  35867. /**
  35868. * Maximum allowed distance of the camera to the target (The camera can not get further).
  35869. * This can help limiting how the Camera is able to move in the scene.
  35870. */
  35871. upperRadiusLimit: Nullable<number>;
  35872. /**
  35873. * Defines the current inertia value used during panning of the camera along the X axis.
  35874. */
  35875. inertialPanningX: number;
  35876. /**
  35877. * Defines the current inertia value used during panning of the camera along the Y axis.
  35878. */
  35879. inertialPanningY: number;
  35880. /**
  35881. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  35882. * Basically if your fingers moves away from more than this distance you will be considered
  35883. * in pinch mode.
  35884. */
  35885. pinchToPanMaxDistance: number;
  35886. /**
  35887. * Defines the maximum distance the camera can pan.
  35888. * This could help keeping the cammera always in your scene.
  35889. */
  35890. panningDistanceLimit: Nullable<number>;
  35891. /**
  35892. * Defines the target of the camera before paning.
  35893. */
  35894. panningOriginTarget: Vector3;
  35895. /**
  35896. * Defines the value of the inertia used during panning.
  35897. * 0 would mean stop inertia and one would mean no decelleration at all.
  35898. */
  35899. panningInertia: number;
  35900. /**
  35901. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  35902. */
  35903. angularSensibilityX: number;
  35904. /**
  35905. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  35906. */
  35907. angularSensibilityY: number;
  35908. /**
  35909. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  35910. */
  35911. pinchPrecision: number;
  35912. /**
  35913. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  35914. * It will be used instead of pinchDeltaPrecision if different from 0.
  35915. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  35916. */
  35917. pinchDeltaPercentage: number;
  35918. /**
  35919. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  35920. */
  35921. panningSensibility: number;
  35922. /**
  35923. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  35924. */
  35925. keysUp: number[];
  35926. /**
  35927. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  35928. */
  35929. keysDown: number[];
  35930. /**
  35931. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  35932. */
  35933. keysLeft: number[];
  35934. /**
  35935. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  35936. */
  35937. keysRight: number[];
  35938. /**
  35939. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  35940. */
  35941. wheelPrecision: number;
  35942. /**
  35943. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  35944. * It will be used instead of pinchDeltaPrecision if different from 0.
  35945. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  35946. */
  35947. wheelDeltaPercentage: number;
  35948. /**
  35949. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  35950. */
  35951. zoomOnFactor: number;
  35952. /**
  35953. * Defines a screen offset for the camera position.
  35954. */
  35955. targetScreenOffset: Vector2;
  35956. /**
  35957. * Allows the camera to be completely reversed.
  35958. * If false the camera can not arrive upside down.
  35959. */
  35960. allowUpsideDown: boolean;
  35961. /**
  35962. * Define if double tap/click is used to restore the previously saved state of the camera.
  35963. */
  35964. useInputToRestoreState: boolean;
  35965. /** @hidden */
  35966. _viewMatrix: Matrix;
  35967. /** @hidden */
  35968. _useCtrlForPanning: boolean;
  35969. /** @hidden */
  35970. _panningMouseButton: number;
  35971. /**
  35972. * Defines the input associated to the camera.
  35973. */
  35974. inputs: ArcRotateCameraInputsManager;
  35975. /** @hidden */
  35976. _reset: () => void;
  35977. /**
  35978. * Defines the allowed panning axis.
  35979. */
  35980. panningAxis: Vector3;
  35981. protected _localDirection: Vector3;
  35982. protected _transformedDirection: Vector3;
  35983. private _bouncingBehavior;
  35984. /**
  35985. * Gets the bouncing behavior of the camera if it has been enabled.
  35986. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  35987. */
  35988. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  35989. /**
  35990. * Defines if the bouncing behavior of the camera is enabled on the camera.
  35991. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  35992. */
  35993. useBouncingBehavior: boolean;
  35994. private _framingBehavior;
  35995. /**
  35996. * Gets the framing behavior of the camera if it has been enabled.
  35997. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  35998. */
  35999. readonly framingBehavior: Nullable<FramingBehavior>;
  36000. /**
  36001. * Defines if the framing behavior of the camera is enabled on the camera.
  36002. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  36003. */
  36004. useFramingBehavior: boolean;
  36005. private _autoRotationBehavior;
  36006. /**
  36007. * Gets the auto rotation behavior of the camera if it has been enabled.
  36008. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36009. */
  36010. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  36011. /**
  36012. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  36013. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36014. */
  36015. useAutoRotationBehavior: boolean;
  36016. /**
  36017. * Observable triggered when the mesh target has been changed on the camera.
  36018. */
  36019. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  36020. /**
  36021. * Event raised when the camera is colliding with a mesh.
  36022. */
  36023. onCollide: (collidedMesh: AbstractMesh) => void;
  36024. /**
  36025. * Defines whether the camera should check collision with the objects oh the scene.
  36026. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  36027. */
  36028. checkCollisions: boolean;
  36029. /**
  36030. * Defines the collision radius of the camera.
  36031. * This simulates a sphere around the camera.
  36032. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  36033. */
  36034. collisionRadius: Vector3;
  36035. protected _collider: Collider;
  36036. protected _previousPosition: Vector3;
  36037. protected _collisionVelocity: Vector3;
  36038. protected _newPosition: Vector3;
  36039. protected _previousAlpha: number;
  36040. protected _previousBeta: number;
  36041. protected _previousRadius: number;
  36042. protected _collisionTriggered: boolean;
  36043. protected _targetBoundingCenter: Nullable<Vector3>;
  36044. private _computationVector;
  36045. /**
  36046. * Instantiates a new ArcRotateCamera in a given scene
  36047. * @param name Defines the name of the camera
  36048. * @param alpha Defines the camera rotation along the logitudinal axis
  36049. * @param beta Defines the camera rotation along the latitudinal axis
  36050. * @param radius Defines the camera distance from its target
  36051. * @param target Defines the camera target
  36052. * @param scene Defines the scene the camera belongs to
  36053. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  36054. */
  36055. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  36056. /** @hidden */
  36057. _initCache(): void;
  36058. /** @hidden */
  36059. _updateCache(ignoreParentClass?: boolean): void;
  36060. protected _getTargetPosition(): Vector3;
  36061. private _storedAlpha;
  36062. private _storedBeta;
  36063. private _storedRadius;
  36064. private _storedTarget;
  36065. /**
  36066. * Stores the current state of the camera (alpha, beta, radius and target)
  36067. * @returns the camera itself
  36068. */
  36069. storeState(): Camera;
  36070. /**
  36071. * @hidden
  36072. * Restored camera state. You must call storeState() first
  36073. */
  36074. _restoreStateValues(): boolean;
  36075. /** @hidden */
  36076. _isSynchronizedViewMatrix(): boolean;
  36077. /**
  36078. * Attached controls to the current camera.
  36079. * @param element Defines the element the controls should be listened from
  36080. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36081. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  36082. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  36083. */
  36084. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  36085. /**
  36086. * Detach the current controls from the camera.
  36087. * The camera will stop reacting to inputs.
  36088. * @param element Defines the element to stop listening the inputs from
  36089. */
  36090. detachControl(element: HTMLElement): void;
  36091. /** @hidden */
  36092. _checkInputs(): void;
  36093. protected _checkLimits(): void;
  36094. /**
  36095. * Rebuilds angles (alpha, beta) and radius from the give position and target
  36096. */
  36097. rebuildAnglesAndRadius(): void;
  36098. /**
  36099. * Use a position to define the current camera related information like aplha, beta and radius
  36100. * @param position Defines the position to set the camera at
  36101. */
  36102. setPosition(position: Vector3): void;
  36103. /**
  36104. * Defines the target the camera should look at.
  36105. * This will automatically adapt alpha beta and radius to fit within the new target.
  36106. * @param target Defines the new target as a Vector or a mesh
  36107. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  36108. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  36109. */
  36110. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  36111. /** @hidden */
  36112. _getViewMatrix(): Matrix;
  36113. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  36114. /**
  36115. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  36116. * @param meshes Defines the mesh to zoom on
  36117. * @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)
  36118. */
  36119. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  36120. /**
  36121. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  36122. * The target will be changed but the radius
  36123. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  36124. * @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)
  36125. */
  36126. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  36127. min: Vector3;
  36128. max: Vector3;
  36129. distance: number;
  36130. }, doNotUpdateMaxZ?: boolean): void;
  36131. /**
  36132. * @override
  36133. * Override Camera.createRigCamera
  36134. */
  36135. createRigCamera(name: string, cameraIndex: number): Camera;
  36136. /**
  36137. * @hidden
  36138. * @override
  36139. * Override Camera._updateRigCameras
  36140. */
  36141. _updateRigCameras(): void;
  36142. /**
  36143. * Destroy the camera and release the current resources hold by it.
  36144. */
  36145. dispose(): void;
  36146. /**
  36147. * Gets the current object class name.
  36148. * @return the class name
  36149. */
  36150. getClassName(): string;
  36151. }
  36152. }
  36153. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  36154. import { Behavior } from "babylonjs/Behaviors/behavior";
  36155. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36156. /**
  36157. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  36158. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36159. */
  36160. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  36161. /**
  36162. * Gets the name of the behavior.
  36163. */
  36164. readonly name: string;
  36165. private _zoomStopsAnimation;
  36166. private _idleRotationSpeed;
  36167. private _idleRotationWaitTime;
  36168. private _idleRotationSpinupTime;
  36169. /**
  36170. * Sets the flag that indicates if user zooming should stop animation.
  36171. */
  36172. /**
  36173. * Gets the flag that indicates if user zooming should stop animation.
  36174. */
  36175. zoomStopsAnimation: boolean;
  36176. /**
  36177. * Sets the default speed at which the camera rotates around the model.
  36178. */
  36179. /**
  36180. * Gets the default speed at which the camera rotates around the model.
  36181. */
  36182. idleRotationSpeed: number;
  36183. /**
  36184. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  36185. */
  36186. /**
  36187. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  36188. */
  36189. idleRotationWaitTime: number;
  36190. /**
  36191. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  36192. */
  36193. /**
  36194. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  36195. */
  36196. idleRotationSpinupTime: number;
  36197. /**
  36198. * Gets a value indicating if the camera is currently rotating because of this behavior
  36199. */
  36200. readonly rotationInProgress: boolean;
  36201. private _onPrePointerObservableObserver;
  36202. private _onAfterCheckInputsObserver;
  36203. private _attachedCamera;
  36204. private _isPointerDown;
  36205. private _lastFrameTime;
  36206. private _lastInteractionTime;
  36207. private _cameraRotationSpeed;
  36208. /**
  36209. * Initializes the behavior.
  36210. */
  36211. init(): void;
  36212. /**
  36213. * Attaches the behavior to its arc rotate camera.
  36214. * @param camera Defines the camera to attach the behavior to
  36215. */
  36216. attach(camera: ArcRotateCamera): void;
  36217. /**
  36218. * Detaches the behavior from its current arc rotate camera.
  36219. */
  36220. detach(): void;
  36221. /**
  36222. * Returns true if user is scrolling.
  36223. * @return true if user is scrolling.
  36224. */
  36225. private _userIsZooming;
  36226. private _lastFrameRadius;
  36227. private _shouldAnimationStopForInteraction;
  36228. /**
  36229. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  36230. */
  36231. private _applyUserInteraction;
  36232. private _userIsMoving;
  36233. }
  36234. }
  36235. declare module "babylonjs/Behaviors/Cameras/index" {
  36236. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  36237. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  36238. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  36239. }
  36240. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  36241. import { Mesh } from "babylonjs/Meshes/mesh";
  36242. import { TransformNode } from "babylonjs/Meshes/transformNode";
  36243. import { Behavior } from "babylonjs/Behaviors/behavior";
  36244. /**
  36245. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  36246. */
  36247. export class AttachToBoxBehavior implements Behavior<Mesh> {
  36248. private ui;
  36249. /**
  36250. * The name of the behavior
  36251. */
  36252. name: string;
  36253. /**
  36254. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  36255. */
  36256. distanceAwayFromFace: number;
  36257. /**
  36258. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  36259. */
  36260. distanceAwayFromBottomOfFace: number;
  36261. private _faceVectors;
  36262. private _target;
  36263. private _scene;
  36264. private _onRenderObserver;
  36265. private _tmpMatrix;
  36266. private _tmpVector;
  36267. /**
  36268. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  36269. * @param ui The transform node that should be attched to the mesh
  36270. */
  36271. constructor(ui: TransformNode);
  36272. /**
  36273. * Initializes the behavior
  36274. */
  36275. init(): void;
  36276. private _closestFace;
  36277. private _zeroVector;
  36278. private _lookAtTmpMatrix;
  36279. private _lookAtToRef;
  36280. /**
  36281. * Attaches the AttachToBoxBehavior to the passed in mesh
  36282. * @param target The mesh that the specified node will be attached to
  36283. */
  36284. attach(target: Mesh): void;
  36285. /**
  36286. * Detaches the behavior from the mesh
  36287. */
  36288. detach(): void;
  36289. }
  36290. }
  36291. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  36292. import { Behavior } from "babylonjs/Behaviors/behavior";
  36293. import { Mesh } from "babylonjs/Meshes/mesh";
  36294. /**
  36295. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  36296. */
  36297. export class FadeInOutBehavior implements Behavior<Mesh> {
  36298. /**
  36299. * Time in milliseconds to delay before fading in (Default: 0)
  36300. */
  36301. delay: number;
  36302. /**
  36303. * Time in milliseconds for the mesh to fade in (Default: 300)
  36304. */
  36305. fadeInTime: number;
  36306. private _millisecondsPerFrame;
  36307. private _hovered;
  36308. private _hoverValue;
  36309. private _ownerNode;
  36310. /**
  36311. * Instatiates the FadeInOutBehavior
  36312. */
  36313. constructor();
  36314. /**
  36315. * The name of the behavior
  36316. */
  36317. readonly name: string;
  36318. /**
  36319. * Initializes the behavior
  36320. */
  36321. init(): void;
  36322. /**
  36323. * Attaches the fade behavior on the passed in mesh
  36324. * @param ownerNode The mesh that will be faded in/out once attached
  36325. */
  36326. attach(ownerNode: Mesh): void;
  36327. /**
  36328. * Detaches the behavior from the mesh
  36329. */
  36330. detach(): void;
  36331. /**
  36332. * Triggers the mesh to begin fading in or out
  36333. * @param value if the object should fade in or out (true to fade in)
  36334. */
  36335. fadeIn(value: boolean): void;
  36336. private _update;
  36337. private _setAllVisibility;
  36338. }
  36339. }
  36340. declare module "babylonjs/Misc/pivotTools" {
  36341. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36342. /**
  36343. * Class containing a set of static utilities functions for managing Pivots
  36344. * @hidden
  36345. */
  36346. export class PivotTools {
  36347. private static _PivotCached;
  36348. private static _OldPivotPoint;
  36349. private static _PivotTranslation;
  36350. private static _PivotTmpVector;
  36351. /** @hidden */
  36352. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  36353. /** @hidden */
  36354. static _RestorePivotPoint(mesh: AbstractMesh): void;
  36355. }
  36356. }
  36357. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  36358. import { Scene } from "babylonjs/scene";
  36359. import { Vector4, Plane } from "babylonjs/Maths/math";
  36360. import { Mesh } from "babylonjs/Meshes/mesh";
  36361. import { Nullable } from "babylonjs/types";
  36362. /**
  36363. * Class containing static functions to help procedurally build meshes
  36364. */
  36365. export class PlaneBuilder {
  36366. /**
  36367. * Creates a plane mesh
  36368. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  36369. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  36370. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  36371. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  36372. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  36373. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  36374. * @param name defines the name of the mesh
  36375. * @param options defines the options used to create the mesh
  36376. * @param scene defines the hosting scene
  36377. * @returns the plane mesh
  36378. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  36379. */
  36380. static CreatePlane(name: string, options: {
  36381. size?: number;
  36382. width?: number;
  36383. height?: number;
  36384. sideOrientation?: number;
  36385. frontUVs?: Vector4;
  36386. backUVs?: Vector4;
  36387. updatable?: boolean;
  36388. sourcePlane?: Plane;
  36389. }, scene?: Nullable<Scene>): Mesh;
  36390. }
  36391. }
  36392. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  36393. import { Behavior } from "babylonjs/Behaviors/behavior";
  36394. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36395. import { Observable } from "babylonjs/Misc/observable";
  36396. import { Vector3 } from "babylonjs/Maths/math";
  36397. import { Ray } from "babylonjs/Culling/ray";
  36398. import "babylonjs/Meshes/Builders/planeBuilder";
  36399. /**
  36400. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  36401. */
  36402. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  36403. private static _AnyMouseID;
  36404. private _attachedNode;
  36405. private _dragPlane;
  36406. private _scene;
  36407. private _pointerObserver;
  36408. private _beforeRenderObserver;
  36409. private static _planeScene;
  36410. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  36411. /**
  36412. * 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)
  36413. */
  36414. maxDragAngle: number;
  36415. /**
  36416. * @hidden
  36417. */
  36418. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  36419. /**
  36420. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  36421. */
  36422. currentDraggingPointerID: number;
  36423. /**
  36424. * The last position where the pointer hit the drag plane in world space
  36425. */
  36426. lastDragPosition: Vector3;
  36427. /**
  36428. * If the behavior is currently in a dragging state
  36429. */
  36430. dragging: boolean;
  36431. /**
  36432. * 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)
  36433. */
  36434. dragDeltaRatio: number;
  36435. /**
  36436. * If the drag plane orientation should be updated during the dragging (Default: true)
  36437. */
  36438. updateDragPlane: boolean;
  36439. private _debugMode;
  36440. private _moving;
  36441. /**
  36442. * Fires each time the attached mesh is dragged with the pointer
  36443. * * delta between last drag position and current drag position in world space
  36444. * * dragDistance along the drag axis
  36445. * * dragPlaneNormal normal of the current drag plane used during the drag
  36446. * * dragPlanePoint in world space where the drag intersects the drag plane
  36447. */
  36448. onDragObservable: Observable<{
  36449. delta: Vector3;
  36450. dragPlanePoint: Vector3;
  36451. dragPlaneNormal: Vector3;
  36452. dragDistance: number;
  36453. pointerId: number;
  36454. }>;
  36455. /**
  36456. * Fires each time a drag begins (eg. mouse down on mesh)
  36457. */
  36458. onDragStartObservable: Observable<{
  36459. dragPlanePoint: Vector3;
  36460. pointerId: number;
  36461. }>;
  36462. /**
  36463. * Fires each time a drag ends (eg. mouse release after drag)
  36464. */
  36465. onDragEndObservable: Observable<{
  36466. dragPlanePoint: Vector3;
  36467. pointerId: number;
  36468. }>;
  36469. /**
  36470. * If the attached mesh should be moved when dragged
  36471. */
  36472. moveAttached: boolean;
  36473. /**
  36474. * If the drag behavior will react to drag events (Default: true)
  36475. */
  36476. enabled: boolean;
  36477. /**
  36478. * If camera controls should be detached during the drag
  36479. */
  36480. detachCameraControls: boolean;
  36481. /**
  36482. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  36483. */
  36484. useObjectOrienationForDragging: boolean;
  36485. private _options;
  36486. /**
  36487. * Creates a pointer drag behavior that can be attached to a mesh
  36488. * @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)
  36489. */
  36490. constructor(options?: {
  36491. dragAxis?: Vector3;
  36492. dragPlaneNormal?: Vector3;
  36493. });
  36494. /**
  36495. * Predicate to determine if it is valid to move the object to a new position when it is moved
  36496. */
  36497. validateDrag: (targetPosition: Vector3) => boolean;
  36498. /**
  36499. * The name of the behavior
  36500. */
  36501. readonly name: string;
  36502. /**
  36503. * Initializes the behavior
  36504. */
  36505. init(): void;
  36506. private _tmpVector;
  36507. private _alternatePickedPoint;
  36508. private _worldDragAxis;
  36509. private _targetPosition;
  36510. private _attachedElement;
  36511. /**
  36512. * Attaches the drag behavior the passed in mesh
  36513. * @param ownerNode The mesh that will be dragged around once attached
  36514. */
  36515. attach(ownerNode: AbstractMesh): void;
  36516. /**
  36517. * Force relase the drag action by code.
  36518. */
  36519. releaseDrag(): void;
  36520. private _startDragRay;
  36521. private _lastPointerRay;
  36522. /**
  36523. * Simulates the start of a pointer drag event on the behavior
  36524. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  36525. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  36526. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  36527. */
  36528. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  36529. private _startDrag;
  36530. private _dragDelta;
  36531. private _moveDrag;
  36532. private _pickWithRayOnDragPlane;
  36533. private _pointA;
  36534. private _pointB;
  36535. private _pointC;
  36536. private _lineA;
  36537. private _lineB;
  36538. private _localAxis;
  36539. private _lookAt;
  36540. private _updateDragPlanePosition;
  36541. /**
  36542. * Detaches the behavior from the mesh
  36543. */
  36544. detach(): void;
  36545. }
  36546. }
  36547. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  36548. import { Mesh } from "babylonjs/Meshes/mesh";
  36549. import { Behavior } from "babylonjs/Behaviors/behavior";
  36550. /**
  36551. * A behavior that when attached to a mesh will allow the mesh to be scaled
  36552. */
  36553. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  36554. private _dragBehaviorA;
  36555. private _dragBehaviorB;
  36556. private _startDistance;
  36557. private _initialScale;
  36558. private _targetScale;
  36559. private _ownerNode;
  36560. private _sceneRenderObserver;
  36561. /**
  36562. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  36563. */
  36564. constructor();
  36565. /**
  36566. * The name of the behavior
  36567. */
  36568. readonly name: string;
  36569. /**
  36570. * Initializes the behavior
  36571. */
  36572. init(): void;
  36573. private _getCurrentDistance;
  36574. /**
  36575. * Attaches the scale behavior the passed in mesh
  36576. * @param ownerNode The mesh that will be scaled around once attached
  36577. */
  36578. attach(ownerNode: Mesh): void;
  36579. /**
  36580. * Detaches the behavior from the mesh
  36581. */
  36582. detach(): void;
  36583. }
  36584. }
  36585. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  36586. import { Behavior } from "babylonjs/Behaviors/behavior";
  36587. import { Mesh } from "babylonjs/Meshes/mesh";
  36588. import { Observable } from "babylonjs/Misc/observable";
  36589. /**
  36590. * 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
  36591. */
  36592. export class SixDofDragBehavior implements Behavior<Mesh> {
  36593. private static _virtualScene;
  36594. private _ownerNode;
  36595. private _sceneRenderObserver;
  36596. private _scene;
  36597. private _targetPosition;
  36598. private _virtualOriginMesh;
  36599. private _virtualDragMesh;
  36600. private _pointerObserver;
  36601. private _moving;
  36602. private _startingOrientation;
  36603. /**
  36604. * 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)
  36605. */
  36606. private zDragFactor;
  36607. /**
  36608. * If the object should rotate to face the drag origin
  36609. */
  36610. rotateDraggedObject: boolean;
  36611. /**
  36612. * If the behavior is currently in a dragging state
  36613. */
  36614. dragging: boolean;
  36615. /**
  36616. * 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)
  36617. */
  36618. dragDeltaRatio: number;
  36619. /**
  36620. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  36621. */
  36622. currentDraggingPointerID: number;
  36623. /**
  36624. * If camera controls should be detached during the drag
  36625. */
  36626. detachCameraControls: boolean;
  36627. /**
  36628. * Fires each time a drag starts
  36629. */
  36630. onDragStartObservable: Observable<{}>;
  36631. /**
  36632. * Fires each time a drag ends (eg. mouse release after drag)
  36633. */
  36634. onDragEndObservable: Observable<{}>;
  36635. /**
  36636. * 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
  36637. */
  36638. constructor();
  36639. /**
  36640. * The name of the behavior
  36641. */
  36642. readonly name: string;
  36643. /**
  36644. * Initializes the behavior
  36645. */
  36646. init(): void;
  36647. /**
  36648. * Attaches the scale behavior the passed in mesh
  36649. * @param ownerNode The mesh that will be scaled around once attached
  36650. */
  36651. attach(ownerNode: Mesh): void;
  36652. /**
  36653. * Detaches the behavior from the mesh
  36654. */
  36655. detach(): void;
  36656. }
  36657. }
  36658. declare module "babylonjs/Behaviors/Meshes/index" {
  36659. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  36660. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  36661. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  36662. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  36663. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  36664. }
  36665. declare module "babylonjs/Behaviors/index" {
  36666. export * from "babylonjs/Behaviors/behavior";
  36667. export * from "babylonjs/Behaviors/Cameras/index";
  36668. export * from "babylonjs/Behaviors/Meshes/index";
  36669. }
  36670. declare module "babylonjs/Bones/boneIKController" {
  36671. import { Bone } from "babylonjs/Bones/bone";
  36672. import { Vector3 } from "babylonjs/Maths/math";
  36673. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36674. import { Nullable } from "babylonjs/types";
  36675. /**
  36676. * Class used to apply inverse kinematics to bones
  36677. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  36678. */
  36679. export class BoneIKController {
  36680. private static _tmpVecs;
  36681. private static _tmpQuat;
  36682. private static _tmpMats;
  36683. /**
  36684. * Gets or sets the target mesh
  36685. */
  36686. targetMesh: AbstractMesh;
  36687. /** Gets or sets the mesh used as pole */
  36688. poleTargetMesh: AbstractMesh;
  36689. /**
  36690. * Gets or sets the bone used as pole
  36691. */
  36692. poleTargetBone: Nullable<Bone>;
  36693. /**
  36694. * Gets or sets the target position
  36695. */
  36696. targetPosition: Vector3;
  36697. /**
  36698. * Gets or sets the pole target position
  36699. */
  36700. poleTargetPosition: Vector3;
  36701. /**
  36702. * Gets or sets the pole target local offset
  36703. */
  36704. poleTargetLocalOffset: Vector3;
  36705. /**
  36706. * Gets or sets the pole angle
  36707. */
  36708. poleAngle: number;
  36709. /**
  36710. * Gets or sets the mesh associated with the controller
  36711. */
  36712. mesh: AbstractMesh;
  36713. /**
  36714. * 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)
  36715. */
  36716. slerpAmount: number;
  36717. private _bone1Quat;
  36718. private _bone1Mat;
  36719. private _bone2Ang;
  36720. private _bone1;
  36721. private _bone2;
  36722. private _bone1Length;
  36723. private _bone2Length;
  36724. private _maxAngle;
  36725. private _maxReach;
  36726. private _rightHandedSystem;
  36727. private _bendAxis;
  36728. private _slerping;
  36729. private _adjustRoll;
  36730. /**
  36731. * Gets or sets maximum allowed angle
  36732. */
  36733. maxAngle: number;
  36734. /**
  36735. * Creates a new BoneIKController
  36736. * @param mesh defines the mesh to control
  36737. * @param bone defines the bone to control
  36738. * @param options defines options to set up the controller
  36739. */
  36740. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  36741. targetMesh?: AbstractMesh;
  36742. poleTargetMesh?: AbstractMesh;
  36743. poleTargetBone?: Bone;
  36744. poleTargetLocalOffset?: Vector3;
  36745. poleAngle?: number;
  36746. bendAxis?: Vector3;
  36747. maxAngle?: number;
  36748. slerpAmount?: number;
  36749. });
  36750. private _setMaxAngle;
  36751. /**
  36752. * Force the controller to update the bones
  36753. */
  36754. update(): void;
  36755. }
  36756. }
  36757. declare module "babylonjs/Bones/boneLookController" {
  36758. import { Vector3, Space } from "babylonjs/Maths/math";
  36759. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36760. import { Bone } from "babylonjs/Bones/bone";
  36761. /**
  36762. * Class used to make a bone look toward a point in space
  36763. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  36764. */
  36765. export class BoneLookController {
  36766. private static _tmpVecs;
  36767. private static _tmpQuat;
  36768. private static _tmpMats;
  36769. /**
  36770. * The target Vector3 that the bone will look at
  36771. */
  36772. target: Vector3;
  36773. /**
  36774. * The mesh that the bone is attached to
  36775. */
  36776. mesh: AbstractMesh;
  36777. /**
  36778. * The bone that will be looking to the target
  36779. */
  36780. bone: Bone;
  36781. /**
  36782. * The up axis of the coordinate system that is used when the bone is rotated
  36783. */
  36784. upAxis: Vector3;
  36785. /**
  36786. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  36787. */
  36788. upAxisSpace: Space;
  36789. /**
  36790. * Used to make an adjustment to the yaw of the bone
  36791. */
  36792. adjustYaw: number;
  36793. /**
  36794. * Used to make an adjustment to the pitch of the bone
  36795. */
  36796. adjustPitch: number;
  36797. /**
  36798. * Used to make an adjustment to the roll of the bone
  36799. */
  36800. adjustRoll: number;
  36801. /**
  36802. * 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)
  36803. */
  36804. slerpAmount: number;
  36805. private _minYaw;
  36806. private _maxYaw;
  36807. private _minPitch;
  36808. private _maxPitch;
  36809. private _minYawSin;
  36810. private _minYawCos;
  36811. private _maxYawSin;
  36812. private _maxYawCos;
  36813. private _midYawConstraint;
  36814. private _minPitchTan;
  36815. private _maxPitchTan;
  36816. private _boneQuat;
  36817. private _slerping;
  36818. private _transformYawPitch;
  36819. private _transformYawPitchInv;
  36820. private _firstFrameSkipped;
  36821. private _yawRange;
  36822. private _fowardAxis;
  36823. /**
  36824. * Gets or sets the minimum yaw angle that the bone can look to
  36825. */
  36826. minYaw: number;
  36827. /**
  36828. * Gets or sets the maximum yaw angle that the bone can look to
  36829. */
  36830. maxYaw: number;
  36831. /**
  36832. * Gets or sets the minimum pitch angle that the bone can look to
  36833. */
  36834. minPitch: number;
  36835. /**
  36836. * Gets or sets the maximum pitch angle that the bone can look to
  36837. */
  36838. maxPitch: number;
  36839. /**
  36840. * Create a BoneLookController
  36841. * @param mesh the mesh that the bone belongs to
  36842. * @param bone the bone that will be looking to the target
  36843. * @param target the target Vector3 to look at
  36844. * @param options optional settings:
  36845. * * maxYaw: the maximum angle the bone will yaw to
  36846. * * minYaw: the minimum angle the bone will yaw to
  36847. * * maxPitch: the maximum angle the bone will pitch to
  36848. * * minPitch: the minimum angle the bone will yaw to
  36849. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  36850. * * upAxis: the up axis of the coordinate system
  36851. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  36852. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  36853. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  36854. * * adjustYaw: used to make an adjustment to the yaw of the bone
  36855. * * adjustPitch: used to make an adjustment to the pitch of the bone
  36856. * * adjustRoll: used to make an adjustment to the roll of the bone
  36857. **/
  36858. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  36859. maxYaw?: number;
  36860. minYaw?: number;
  36861. maxPitch?: number;
  36862. minPitch?: number;
  36863. slerpAmount?: number;
  36864. upAxis?: Vector3;
  36865. upAxisSpace?: Space;
  36866. yawAxis?: Vector3;
  36867. pitchAxis?: Vector3;
  36868. adjustYaw?: number;
  36869. adjustPitch?: number;
  36870. adjustRoll?: number;
  36871. });
  36872. /**
  36873. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  36874. */
  36875. update(): void;
  36876. private _getAngleDiff;
  36877. private _getAngleBetween;
  36878. private _isAngleBetween;
  36879. }
  36880. }
  36881. declare module "babylonjs/Bones/index" {
  36882. export * from "babylonjs/Bones/bone";
  36883. export * from "babylonjs/Bones/boneIKController";
  36884. export * from "babylonjs/Bones/boneLookController";
  36885. export * from "babylonjs/Bones/skeleton";
  36886. }
  36887. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  36888. import { Nullable } from "babylonjs/types";
  36889. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36890. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36891. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  36892. /**
  36893. * Manage the gamepad inputs to control an arc rotate camera.
  36894. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36895. */
  36896. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  36897. /**
  36898. * Defines the camera the input is attached to.
  36899. */
  36900. camera: ArcRotateCamera;
  36901. /**
  36902. * Defines the gamepad the input is gathering event from.
  36903. */
  36904. gamepad: Nullable<Gamepad>;
  36905. /**
  36906. * Defines the gamepad rotation sensiblity.
  36907. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  36908. */
  36909. gamepadRotationSensibility: number;
  36910. /**
  36911. * Defines the gamepad move sensiblity.
  36912. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  36913. */
  36914. gamepadMoveSensibility: number;
  36915. private _onGamepadConnectedObserver;
  36916. private _onGamepadDisconnectedObserver;
  36917. /**
  36918. * Attach the input controls to a specific dom element to get the input from.
  36919. * @param element Defines the element the controls should be listened from
  36920. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36921. */
  36922. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36923. /**
  36924. * Detach the current controls from the specified dom element.
  36925. * @param element Defines the element to stop listening the inputs from
  36926. */
  36927. detachControl(element: Nullable<HTMLElement>): void;
  36928. /**
  36929. * Update the current camera state depending on the inputs that have been used this frame.
  36930. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36931. */
  36932. checkInputs(): void;
  36933. /**
  36934. * Gets the class name of the current intput.
  36935. * @returns the class name
  36936. */
  36937. getClassName(): string;
  36938. /**
  36939. * Get the friendly name associated with the input class.
  36940. * @returns the input friendly name
  36941. */
  36942. getSimpleName(): string;
  36943. }
  36944. }
  36945. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  36946. import { Nullable } from "babylonjs/types";
  36947. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36948. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36949. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  36950. interface ArcRotateCameraInputsManager {
  36951. /**
  36952. * Add orientation input support to the input manager.
  36953. * @returns the current input manager
  36954. */
  36955. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  36956. }
  36957. }
  36958. /**
  36959. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  36960. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36961. */
  36962. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  36963. /**
  36964. * Defines the camera the input is attached to.
  36965. */
  36966. camera: ArcRotateCamera;
  36967. /**
  36968. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  36969. */
  36970. alphaCorrection: number;
  36971. /**
  36972. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  36973. */
  36974. gammaCorrection: number;
  36975. private _alpha;
  36976. private _gamma;
  36977. private _dirty;
  36978. private _deviceOrientationHandler;
  36979. /**
  36980. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  36981. */
  36982. constructor();
  36983. /**
  36984. * Attach the input controls to a specific dom element to get the input from.
  36985. * @param element Defines the element the controls should be listened from
  36986. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36987. */
  36988. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36989. /** @hidden */
  36990. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  36991. /**
  36992. * Update the current camera state depending on the inputs that have been used this frame.
  36993. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36994. */
  36995. checkInputs(): void;
  36996. /**
  36997. * Detach the current controls from the specified dom element.
  36998. * @param element Defines the element to stop listening the inputs from
  36999. */
  37000. detachControl(element: Nullable<HTMLElement>): void;
  37001. /**
  37002. * Gets the class name of the current intput.
  37003. * @returns the class name
  37004. */
  37005. getClassName(): string;
  37006. /**
  37007. * Get the friendly name associated with the input class.
  37008. * @returns the input friendly name
  37009. */
  37010. getSimpleName(): string;
  37011. }
  37012. }
  37013. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  37014. import { Nullable } from "babylonjs/types";
  37015. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37016. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  37017. /**
  37018. * Listen to mouse events to control the camera.
  37019. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37020. */
  37021. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  37022. /**
  37023. * Defines the camera the input is attached to.
  37024. */
  37025. camera: FlyCamera;
  37026. /**
  37027. * Defines if touch is enabled. (Default is true.)
  37028. */
  37029. touchEnabled: boolean;
  37030. /**
  37031. * Defines the buttons associated with the input to handle camera rotation.
  37032. */
  37033. buttons: number[];
  37034. /**
  37035. * Assign buttons for Yaw control.
  37036. */
  37037. buttonsYaw: number[];
  37038. /**
  37039. * Assign buttons for Pitch control.
  37040. */
  37041. buttonsPitch: number[];
  37042. /**
  37043. * Assign buttons for Roll control.
  37044. */
  37045. buttonsRoll: number[];
  37046. /**
  37047. * Detect if any button is being pressed while mouse is moved.
  37048. * -1 = Mouse locked.
  37049. * 0 = Left button.
  37050. * 1 = Middle Button.
  37051. * 2 = Right Button.
  37052. */
  37053. activeButton: number;
  37054. /**
  37055. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  37056. * Higher values reduce its sensitivity.
  37057. */
  37058. angularSensibility: number;
  37059. private _mousemoveCallback;
  37060. private _observer;
  37061. private _rollObserver;
  37062. private previousPosition;
  37063. private noPreventDefault;
  37064. private element;
  37065. /**
  37066. * Listen to mouse events to control the camera.
  37067. * @param touchEnabled Define if touch is enabled. (Default is true.)
  37068. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37069. */
  37070. constructor(touchEnabled?: boolean);
  37071. /**
  37072. * Attach the mouse control to the HTML DOM element.
  37073. * @param element Defines the element that listens to the input events.
  37074. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  37075. */
  37076. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37077. /**
  37078. * Detach the current controls from the specified dom element.
  37079. * @param element Defines the element to stop listening the inputs from
  37080. */
  37081. detachControl(element: Nullable<HTMLElement>): void;
  37082. /**
  37083. * Gets the class name of the current input.
  37084. * @returns the class name.
  37085. */
  37086. getClassName(): string;
  37087. /**
  37088. * Get the friendly name associated with the input class.
  37089. * @returns the input's friendly name.
  37090. */
  37091. getSimpleName(): string;
  37092. private _pointerInput;
  37093. private _onMouseMove;
  37094. /**
  37095. * Rotate camera by mouse offset.
  37096. */
  37097. private rotateCamera;
  37098. }
  37099. }
  37100. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  37101. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  37102. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  37103. /**
  37104. * Default Inputs manager for the FlyCamera.
  37105. * It groups all the default supported inputs for ease of use.
  37106. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37107. */
  37108. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  37109. /**
  37110. * Instantiates a new FlyCameraInputsManager.
  37111. * @param camera Defines the camera the inputs belong to.
  37112. */
  37113. constructor(camera: FlyCamera);
  37114. /**
  37115. * Add keyboard input support to the input manager.
  37116. * @returns the new FlyCameraKeyboardMoveInput().
  37117. */
  37118. addKeyboard(): FlyCameraInputsManager;
  37119. /**
  37120. * Add mouse input support to the input manager.
  37121. * @param touchEnabled Enable touch screen support.
  37122. * @returns the new FlyCameraMouseInput().
  37123. */
  37124. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  37125. }
  37126. }
  37127. declare module "babylonjs/Cameras/flyCamera" {
  37128. import { Scene } from "babylonjs/scene";
  37129. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  37130. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37131. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  37132. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  37133. /**
  37134. * This is a flying camera, designed for 3D movement and rotation in all directions,
  37135. * such as in a 3D Space Shooter or a Flight Simulator.
  37136. */
  37137. export class FlyCamera extends TargetCamera {
  37138. /**
  37139. * Define the collision ellipsoid of the camera.
  37140. * This is helpful for simulating a camera body, like a player's body.
  37141. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  37142. */
  37143. ellipsoid: Vector3;
  37144. /**
  37145. * Define an offset for the position of the ellipsoid around the camera.
  37146. * This can be helpful if the camera is attached away from the player's body center,
  37147. * such as at its head.
  37148. */
  37149. ellipsoidOffset: Vector3;
  37150. /**
  37151. * Enable or disable collisions of the camera with the rest of the scene objects.
  37152. */
  37153. checkCollisions: boolean;
  37154. /**
  37155. * Enable or disable gravity on the camera.
  37156. */
  37157. applyGravity: boolean;
  37158. /**
  37159. * Define the current direction the camera is moving to.
  37160. */
  37161. cameraDirection: Vector3;
  37162. /**
  37163. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  37164. * This overrides and empties cameraRotation.
  37165. */
  37166. rotationQuaternion: Quaternion;
  37167. /**
  37168. * Track Roll to maintain the wanted Rolling when looking around.
  37169. */
  37170. _trackRoll: number;
  37171. /**
  37172. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  37173. */
  37174. rollCorrect: number;
  37175. /**
  37176. * Mimic a banked turn, Rolling the camera when Yawing.
  37177. * It's recommended to use rollCorrect = 10 for faster banking correction.
  37178. */
  37179. bankedTurn: boolean;
  37180. /**
  37181. * Limit in radians for how much Roll banking will add. (Default: 90°)
  37182. */
  37183. bankedTurnLimit: number;
  37184. /**
  37185. * Value of 0 disables the banked Roll.
  37186. * Value of 1 is equal to the Yaw angle in radians.
  37187. */
  37188. bankedTurnMultiplier: number;
  37189. /**
  37190. * The inputs manager loads all the input sources, such as keyboard and mouse.
  37191. */
  37192. inputs: FlyCameraInputsManager;
  37193. /**
  37194. * Gets the input sensibility for mouse input.
  37195. * Higher values reduce sensitivity.
  37196. */
  37197. /**
  37198. * Sets the input sensibility for a mouse input.
  37199. * Higher values reduce sensitivity.
  37200. */
  37201. angularSensibility: number;
  37202. /**
  37203. * Get the keys for camera movement forward.
  37204. */
  37205. /**
  37206. * Set the keys for camera movement forward.
  37207. */
  37208. keysForward: number[];
  37209. /**
  37210. * Get the keys for camera movement backward.
  37211. */
  37212. keysBackward: number[];
  37213. /**
  37214. * Get the keys for camera movement up.
  37215. */
  37216. /**
  37217. * Set the keys for camera movement up.
  37218. */
  37219. keysUp: number[];
  37220. /**
  37221. * Get the keys for camera movement down.
  37222. */
  37223. /**
  37224. * Set the keys for camera movement down.
  37225. */
  37226. keysDown: number[];
  37227. /**
  37228. * Get the keys for camera movement left.
  37229. */
  37230. /**
  37231. * Set the keys for camera movement left.
  37232. */
  37233. keysLeft: number[];
  37234. /**
  37235. * Set the keys for camera movement right.
  37236. */
  37237. /**
  37238. * Set the keys for camera movement right.
  37239. */
  37240. keysRight: number[];
  37241. /**
  37242. * Event raised when the camera collides with a mesh in the scene.
  37243. */
  37244. onCollide: (collidedMesh: AbstractMesh) => void;
  37245. private _collider;
  37246. private _needMoveForGravity;
  37247. private _oldPosition;
  37248. private _diffPosition;
  37249. private _newPosition;
  37250. /** @hidden */
  37251. _localDirection: Vector3;
  37252. /** @hidden */
  37253. _transformedDirection: Vector3;
  37254. /**
  37255. * Instantiates a FlyCamera.
  37256. * This is a flying camera, designed for 3D movement and rotation in all directions,
  37257. * such as in a 3D Space Shooter or a Flight Simulator.
  37258. * @param name Define the name of the camera in the scene.
  37259. * @param position Define the starting position of the camera in the scene.
  37260. * @param scene Define the scene the camera belongs to.
  37261. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  37262. */
  37263. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  37264. /**
  37265. * Attach a control to the HTML DOM element.
  37266. * @param element Defines the element that listens to the input events.
  37267. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  37268. */
  37269. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37270. /**
  37271. * Detach a control from the HTML DOM element.
  37272. * The camera will stop reacting to that input.
  37273. * @param element Defines the element that listens to the input events.
  37274. */
  37275. detachControl(element: HTMLElement): void;
  37276. private _collisionMask;
  37277. /**
  37278. * Get the mask that the camera ignores in collision events.
  37279. */
  37280. /**
  37281. * Set the mask that the camera ignores in collision events.
  37282. */
  37283. collisionMask: number;
  37284. /** @hidden */
  37285. _collideWithWorld(displacement: Vector3): void;
  37286. /** @hidden */
  37287. private _onCollisionPositionChange;
  37288. /** @hidden */
  37289. _checkInputs(): void;
  37290. /** @hidden */
  37291. _decideIfNeedsToMove(): boolean;
  37292. /** @hidden */
  37293. _updatePosition(): void;
  37294. /**
  37295. * Restore the Roll to its target value at the rate specified.
  37296. * @param rate - Higher means slower restoring.
  37297. * @hidden
  37298. */
  37299. restoreRoll(rate: number): void;
  37300. /**
  37301. * Destroy the camera and release the current resources held by it.
  37302. */
  37303. dispose(): void;
  37304. /**
  37305. * Get the current object class name.
  37306. * @returns the class name.
  37307. */
  37308. getClassName(): string;
  37309. }
  37310. }
  37311. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  37312. import { Nullable } from "babylonjs/types";
  37313. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37314. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  37315. /**
  37316. * Listen to keyboard events to control the camera.
  37317. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37318. */
  37319. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  37320. /**
  37321. * Defines the camera the input is attached to.
  37322. */
  37323. camera: FlyCamera;
  37324. /**
  37325. * The list of keyboard keys used to control the forward move of the camera.
  37326. */
  37327. keysForward: number[];
  37328. /**
  37329. * The list of keyboard keys used to control the backward move of the camera.
  37330. */
  37331. keysBackward: number[];
  37332. /**
  37333. * The list of keyboard keys used to control the forward move of the camera.
  37334. */
  37335. keysUp: number[];
  37336. /**
  37337. * The list of keyboard keys used to control the backward move of the camera.
  37338. */
  37339. keysDown: number[];
  37340. /**
  37341. * The list of keyboard keys used to control the right strafe move of the camera.
  37342. */
  37343. keysRight: number[];
  37344. /**
  37345. * The list of keyboard keys used to control the left strafe move of the camera.
  37346. */
  37347. keysLeft: number[];
  37348. private _keys;
  37349. private _onCanvasBlurObserver;
  37350. private _onKeyboardObserver;
  37351. private _engine;
  37352. private _scene;
  37353. /**
  37354. * Attach the input controls to a specific dom element to get the input from.
  37355. * @param element Defines the element the controls should be listened from
  37356. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37357. */
  37358. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37359. /**
  37360. * Detach the current controls from the specified dom element.
  37361. * @param element Defines the element to stop listening the inputs from
  37362. */
  37363. detachControl(element: Nullable<HTMLElement>): void;
  37364. /**
  37365. * Gets the class name of the current intput.
  37366. * @returns the class name
  37367. */
  37368. getClassName(): string;
  37369. /** @hidden */
  37370. _onLostFocus(e: FocusEvent): void;
  37371. /**
  37372. * Get the friendly name associated with the input class.
  37373. * @returns the input friendly name
  37374. */
  37375. getSimpleName(): string;
  37376. /**
  37377. * Update the current camera state depending on the inputs that have been used this frame.
  37378. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37379. */
  37380. checkInputs(): void;
  37381. }
  37382. }
  37383. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  37384. import { Nullable } from "babylonjs/types";
  37385. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  37386. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37387. /**
  37388. * Manage the mouse wheel inputs to control a follow camera.
  37389. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37390. */
  37391. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  37392. /**
  37393. * Defines the camera the input is attached to.
  37394. */
  37395. camera: FollowCamera;
  37396. /**
  37397. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  37398. */
  37399. axisControlRadius: boolean;
  37400. /**
  37401. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  37402. */
  37403. axisControlHeight: boolean;
  37404. /**
  37405. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  37406. */
  37407. axisControlRotation: boolean;
  37408. /**
  37409. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  37410. * relation to mouseWheel events.
  37411. */
  37412. wheelPrecision: number;
  37413. /**
  37414. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  37415. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  37416. */
  37417. wheelDeltaPercentage: number;
  37418. private _wheel;
  37419. private _observer;
  37420. /**
  37421. * Attach the input controls to a specific dom element to get the input from.
  37422. * @param element Defines the element the controls should be listened from
  37423. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37424. */
  37425. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37426. /**
  37427. * Detach the current controls from the specified dom element.
  37428. * @param element Defines the element to stop listening the inputs from
  37429. */
  37430. detachControl(element: Nullable<HTMLElement>): void;
  37431. /**
  37432. * Gets the class name of the current intput.
  37433. * @returns the class name
  37434. */
  37435. getClassName(): string;
  37436. /**
  37437. * Get the friendly name associated with the input class.
  37438. * @returns the input friendly name
  37439. */
  37440. getSimpleName(): string;
  37441. }
  37442. }
  37443. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  37444. import { Nullable } from "babylonjs/types";
  37445. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  37446. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  37447. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  37448. /**
  37449. * Manage the pointers inputs to control an follow camera.
  37450. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37451. */
  37452. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  37453. /**
  37454. * Defines the camera the input is attached to.
  37455. */
  37456. camera: FollowCamera;
  37457. /**
  37458. * Gets the class name of the current input.
  37459. * @returns the class name
  37460. */
  37461. getClassName(): string;
  37462. /**
  37463. * Defines the pointer angular sensibility along the X axis or how fast is
  37464. * the camera rotating.
  37465. * A negative number will reverse the axis direction.
  37466. */
  37467. angularSensibilityX: number;
  37468. /**
  37469. * Defines the pointer angular sensibility along the Y axis or how fast is
  37470. * the camera rotating.
  37471. * A negative number will reverse the axis direction.
  37472. */
  37473. angularSensibilityY: number;
  37474. /**
  37475. * Defines the pointer pinch precision or how fast is the camera zooming.
  37476. * A negative number will reverse the axis direction.
  37477. */
  37478. pinchPrecision: number;
  37479. /**
  37480. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  37481. * from 0.
  37482. * It defines the percentage of current camera.radius to use as delta when
  37483. * pinch zoom is used.
  37484. */
  37485. pinchDeltaPercentage: number;
  37486. /**
  37487. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  37488. */
  37489. axisXControlRadius: boolean;
  37490. /**
  37491. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  37492. */
  37493. axisXControlHeight: boolean;
  37494. /**
  37495. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  37496. */
  37497. axisXControlRotation: boolean;
  37498. /**
  37499. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  37500. */
  37501. axisYControlRadius: boolean;
  37502. /**
  37503. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  37504. */
  37505. axisYControlHeight: boolean;
  37506. /**
  37507. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  37508. */
  37509. axisYControlRotation: boolean;
  37510. /**
  37511. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  37512. */
  37513. axisPinchControlRadius: boolean;
  37514. /**
  37515. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  37516. */
  37517. axisPinchControlHeight: boolean;
  37518. /**
  37519. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  37520. */
  37521. axisPinchControlRotation: boolean;
  37522. /**
  37523. * Log error messages if basic misconfiguration has occurred.
  37524. */
  37525. warningEnable: boolean;
  37526. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  37527. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  37528. private _warningCounter;
  37529. private _warning;
  37530. }
  37531. }
  37532. declare module "babylonjs/Cameras/followCameraInputsManager" {
  37533. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  37534. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  37535. /**
  37536. * Default Inputs manager for the FollowCamera.
  37537. * It groups all the default supported inputs for ease of use.
  37538. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37539. */
  37540. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  37541. /**
  37542. * Instantiates a new FollowCameraInputsManager.
  37543. * @param camera Defines the camera the inputs belong to
  37544. */
  37545. constructor(camera: FollowCamera);
  37546. /**
  37547. * Add keyboard input support to the input manager.
  37548. * @returns the current input manager
  37549. */
  37550. addKeyboard(): FollowCameraInputsManager;
  37551. /**
  37552. * Add mouse wheel input support to the input manager.
  37553. * @returns the current input manager
  37554. */
  37555. addMouseWheel(): FollowCameraInputsManager;
  37556. /**
  37557. * Add pointers input support to the input manager.
  37558. * @returns the current input manager
  37559. */
  37560. addPointers(): FollowCameraInputsManager;
  37561. /**
  37562. * Add orientation input support to the input manager.
  37563. * @returns the current input manager
  37564. */
  37565. addVRDeviceOrientation(): FollowCameraInputsManager;
  37566. }
  37567. }
  37568. declare module "babylonjs/Cameras/followCamera" {
  37569. import { Nullable } from "babylonjs/types";
  37570. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  37571. import { Scene } from "babylonjs/scene";
  37572. import { Vector3 } from "babylonjs/Maths/math";
  37573. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37574. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  37575. /**
  37576. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  37577. * an arc rotate version arcFollowCamera are available.
  37578. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37579. */
  37580. export class FollowCamera extends TargetCamera {
  37581. /**
  37582. * Distance the follow camera should follow an object at
  37583. */
  37584. radius: number;
  37585. /**
  37586. * Minimum allowed distance of the camera to the axis of rotation
  37587. * (The camera can not get closer).
  37588. * This can help limiting how the Camera is able to move in the scene.
  37589. */
  37590. lowerRadiusLimit: Nullable<number>;
  37591. /**
  37592. * Maximum allowed distance of the camera to the axis of rotation
  37593. * (The camera can not get further).
  37594. * This can help limiting how the Camera is able to move in the scene.
  37595. */
  37596. upperRadiusLimit: Nullable<number>;
  37597. /**
  37598. * Define a rotation offset between the camera and the object it follows
  37599. */
  37600. rotationOffset: number;
  37601. /**
  37602. * Minimum allowed angle to camera position relative to target object.
  37603. * This can help limiting how the Camera is able to move in the scene.
  37604. */
  37605. lowerRotationOffsetLimit: Nullable<number>;
  37606. /**
  37607. * Maximum allowed angle to camera position relative to target object.
  37608. * This can help limiting how the Camera is able to move in the scene.
  37609. */
  37610. upperRotationOffsetLimit: Nullable<number>;
  37611. /**
  37612. * Define a height offset between the camera and the object it follows.
  37613. * It can help following an object from the top (like a car chaing a plane)
  37614. */
  37615. heightOffset: number;
  37616. /**
  37617. * Minimum allowed height of camera position relative to target object.
  37618. * This can help limiting how the Camera is able to move in the scene.
  37619. */
  37620. lowerHeightOffsetLimit: Nullable<number>;
  37621. /**
  37622. * Maximum allowed height of camera position relative to target object.
  37623. * This can help limiting how the Camera is able to move in the scene.
  37624. */
  37625. upperHeightOffsetLimit: Nullable<number>;
  37626. /**
  37627. * Define how fast the camera can accelerate to follow it s target.
  37628. */
  37629. cameraAcceleration: number;
  37630. /**
  37631. * Define the speed limit of the camera following an object.
  37632. */
  37633. maxCameraSpeed: number;
  37634. /**
  37635. * Define the target of the camera.
  37636. */
  37637. lockedTarget: Nullable<AbstractMesh>;
  37638. /**
  37639. * Defines the input associated with the camera.
  37640. */
  37641. inputs: FollowCameraInputsManager;
  37642. /**
  37643. * Instantiates the follow camera.
  37644. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37645. * @param name Define the name of the camera in the scene
  37646. * @param position Define the position of the camera
  37647. * @param scene Define the scene the camera belong to
  37648. * @param lockedTarget Define the target of the camera
  37649. */
  37650. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  37651. private _follow;
  37652. /**
  37653. * Attached controls to the current camera.
  37654. * @param element Defines the element the controls should be listened from
  37655. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37656. */
  37657. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37658. /**
  37659. * Detach the current controls from the camera.
  37660. * The camera will stop reacting to inputs.
  37661. * @param element Defines the element to stop listening the inputs from
  37662. */
  37663. detachControl(element: HTMLElement): void;
  37664. /** @hidden */
  37665. _checkInputs(): void;
  37666. private _checkLimits;
  37667. /**
  37668. * Gets the camera class name.
  37669. * @returns the class name
  37670. */
  37671. getClassName(): string;
  37672. }
  37673. /**
  37674. * Arc Rotate version of the follow camera.
  37675. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  37676. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37677. */
  37678. export class ArcFollowCamera extends TargetCamera {
  37679. /** The longitudinal angle of the camera */
  37680. alpha: number;
  37681. /** The latitudinal angle of the camera */
  37682. beta: number;
  37683. /** The radius of the camera from its target */
  37684. radius: number;
  37685. /** Define the camera target (the messh it should follow) */
  37686. target: Nullable<AbstractMesh>;
  37687. private _cartesianCoordinates;
  37688. /**
  37689. * Instantiates a new ArcFollowCamera
  37690. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37691. * @param name Define the name of the camera
  37692. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  37693. * @param beta Define the rotation angle of the camera around the elevation axis
  37694. * @param radius Define the radius of the camera from its target point
  37695. * @param target Define the target of the camera
  37696. * @param scene Define the scene the camera belongs to
  37697. */
  37698. constructor(name: string,
  37699. /** The longitudinal angle of the camera */
  37700. alpha: number,
  37701. /** The latitudinal angle of the camera */
  37702. beta: number,
  37703. /** The radius of the camera from its target */
  37704. radius: number,
  37705. /** Define the camera target (the messh it should follow) */
  37706. target: Nullable<AbstractMesh>, scene: Scene);
  37707. private _follow;
  37708. /** @hidden */
  37709. _checkInputs(): void;
  37710. /**
  37711. * Returns the class name of the object.
  37712. * It is mostly used internally for serialization purposes.
  37713. */
  37714. getClassName(): string;
  37715. }
  37716. }
  37717. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  37718. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37719. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  37720. import { Nullable } from "babylonjs/types";
  37721. /**
  37722. * Manage the keyboard inputs to control the movement of a follow camera.
  37723. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37724. */
  37725. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  37726. /**
  37727. * Defines the camera the input is attached to.
  37728. */
  37729. camera: FollowCamera;
  37730. /**
  37731. * Defines the list of key codes associated with the up action (increase heightOffset)
  37732. */
  37733. keysHeightOffsetIncr: number[];
  37734. /**
  37735. * Defines the list of key codes associated with the down action (decrease heightOffset)
  37736. */
  37737. keysHeightOffsetDecr: number[];
  37738. /**
  37739. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  37740. */
  37741. keysHeightOffsetModifierAlt: boolean;
  37742. /**
  37743. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  37744. */
  37745. keysHeightOffsetModifierCtrl: boolean;
  37746. /**
  37747. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  37748. */
  37749. keysHeightOffsetModifierShift: boolean;
  37750. /**
  37751. * Defines the list of key codes associated with the left action (increase rotationOffset)
  37752. */
  37753. keysRotationOffsetIncr: number[];
  37754. /**
  37755. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  37756. */
  37757. keysRotationOffsetDecr: number[];
  37758. /**
  37759. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  37760. */
  37761. keysRotationOffsetModifierAlt: boolean;
  37762. /**
  37763. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  37764. */
  37765. keysRotationOffsetModifierCtrl: boolean;
  37766. /**
  37767. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  37768. */
  37769. keysRotationOffsetModifierShift: boolean;
  37770. /**
  37771. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  37772. */
  37773. keysRadiusIncr: number[];
  37774. /**
  37775. * Defines the list of key codes associated with the zoom-out action (increase radius)
  37776. */
  37777. keysRadiusDecr: number[];
  37778. /**
  37779. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  37780. */
  37781. keysRadiusModifierAlt: boolean;
  37782. /**
  37783. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  37784. */
  37785. keysRadiusModifierCtrl: boolean;
  37786. /**
  37787. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  37788. */
  37789. keysRadiusModifierShift: boolean;
  37790. /**
  37791. * Defines the rate of change of heightOffset.
  37792. */
  37793. heightSensibility: number;
  37794. /**
  37795. * Defines the rate of change of rotationOffset.
  37796. */
  37797. rotationSensibility: number;
  37798. /**
  37799. * Defines the rate of change of radius.
  37800. */
  37801. radiusSensibility: number;
  37802. private _keys;
  37803. private _ctrlPressed;
  37804. private _altPressed;
  37805. private _shiftPressed;
  37806. private _onCanvasBlurObserver;
  37807. private _onKeyboardObserver;
  37808. private _engine;
  37809. private _scene;
  37810. /**
  37811. * Attach the input controls to a specific dom element to get the input from.
  37812. * @param element Defines the element the controls should be listened from
  37813. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37814. */
  37815. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37816. /**
  37817. * Detach the current controls from the specified dom element.
  37818. * @param element Defines the element to stop listening the inputs from
  37819. */
  37820. detachControl(element: Nullable<HTMLElement>): void;
  37821. /**
  37822. * Update the current camera state depending on the inputs that have been used this frame.
  37823. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37824. */
  37825. checkInputs(): void;
  37826. /**
  37827. * Gets the class name of the current input.
  37828. * @returns the class name
  37829. */
  37830. getClassName(): string;
  37831. /**
  37832. * Get the friendly name associated with the input class.
  37833. * @returns the input friendly name
  37834. */
  37835. getSimpleName(): string;
  37836. /**
  37837. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  37838. * allow modification of the heightOffset value.
  37839. */
  37840. private _modifierHeightOffset;
  37841. /**
  37842. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  37843. * allow modification of the rotationOffset value.
  37844. */
  37845. private _modifierRotationOffset;
  37846. /**
  37847. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  37848. * allow modification of the radius value.
  37849. */
  37850. private _modifierRadius;
  37851. }
  37852. }
  37853. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  37854. import { Nullable } from "babylonjs/types";
  37855. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37856. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  37857. import { Observable } from "babylonjs/Misc/observable";
  37858. module "babylonjs/Cameras/freeCameraInputsManager" {
  37859. interface FreeCameraInputsManager {
  37860. /**
  37861. * @hidden
  37862. */
  37863. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  37864. /**
  37865. * Add orientation input support to the input manager.
  37866. * @returns the current input manager
  37867. */
  37868. addDeviceOrientation(): FreeCameraInputsManager;
  37869. }
  37870. }
  37871. /**
  37872. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  37873. * Screen rotation is taken into account.
  37874. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37875. */
  37876. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  37877. private _camera;
  37878. private _screenOrientationAngle;
  37879. private _constantTranform;
  37880. private _screenQuaternion;
  37881. private _alpha;
  37882. private _beta;
  37883. private _gamma;
  37884. /**
  37885. * @hidden
  37886. */
  37887. _onDeviceOrientationChangedObservable: Observable<void>;
  37888. /**
  37889. * Instantiates a new input
  37890. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37891. */
  37892. constructor();
  37893. /**
  37894. * Define the camera controlled by the input.
  37895. */
  37896. camera: FreeCamera;
  37897. /**
  37898. * Attach the input controls to a specific dom element to get the input from.
  37899. * @param element Defines the element the controls should be listened from
  37900. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37901. */
  37902. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37903. private _orientationChanged;
  37904. private _deviceOrientation;
  37905. /**
  37906. * Detach the current controls from the specified dom element.
  37907. * @param element Defines the element to stop listening the inputs from
  37908. */
  37909. detachControl(element: Nullable<HTMLElement>): void;
  37910. /**
  37911. * Update the current camera state depending on the inputs that have been used this frame.
  37912. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37913. */
  37914. checkInputs(): void;
  37915. /**
  37916. * Gets the class name of the current intput.
  37917. * @returns the class name
  37918. */
  37919. getClassName(): string;
  37920. /**
  37921. * Get the friendly name associated with the input class.
  37922. * @returns the input friendly name
  37923. */
  37924. getSimpleName(): string;
  37925. }
  37926. }
  37927. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  37928. import { Nullable } from "babylonjs/types";
  37929. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37930. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  37931. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  37932. /**
  37933. * Manage the gamepad inputs to control a free camera.
  37934. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37935. */
  37936. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  37937. /**
  37938. * Define the camera the input is attached to.
  37939. */
  37940. camera: FreeCamera;
  37941. /**
  37942. * Define the Gamepad controlling the input
  37943. */
  37944. gamepad: Nullable<Gamepad>;
  37945. /**
  37946. * Defines the gamepad rotation sensiblity.
  37947. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  37948. */
  37949. gamepadAngularSensibility: number;
  37950. /**
  37951. * Defines the gamepad move sensiblity.
  37952. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  37953. */
  37954. gamepadMoveSensibility: number;
  37955. private _onGamepadConnectedObserver;
  37956. private _onGamepadDisconnectedObserver;
  37957. private _cameraTransform;
  37958. private _deltaTransform;
  37959. private _vector3;
  37960. private _vector2;
  37961. /**
  37962. * Attach the input controls to a specific dom element to get the input from.
  37963. * @param element Defines the element the controls should be listened from
  37964. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37965. */
  37966. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37967. /**
  37968. * Detach the current controls from the specified dom element.
  37969. * @param element Defines the element to stop listening the inputs from
  37970. */
  37971. detachControl(element: Nullable<HTMLElement>): void;
  37972. /**
  37973. * Update the current camera state depending on the inputs that have been used this frame.
  37974. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37975. */
  37976. checkInputs(): void;
  37977. /**
  37978. * Gets the class name of the current intput.
  37979. * @returns the class name
  37980. */
  37981. getClassName(): string;
  37982. /**
  37983. * Get the friendly name associated with the input class.
  37984. * @returns the input friendly name
  37985. */
  37986. getSimpleName(): string;
  37987. }
  37988. }
  37989. declare module "babylonjs/Misc/virtualJoystick" {
  37990. import { Nullable } from "babylonjs/types";
  37991. import { Vector3 } from "babylonjs/Maths/math";
  37992. /**
  37993. * Defines the potential axis of a Joystick
  37994. */
  37995. export enum JoystickAxis {
  37996. /** X axis */
  37997. X = 0,
  37998. /** Y axis */
  37999. Y = 1,
  38000. /** Z axis */
  38001. Z = 2
  38002. }
  38003. /**
  38004. * Class used to define virtual joystick (used in touch mode)
  38005. */
  38006. export class VirtualJoystick {
  38007. /**
  38008. * Gets or sets a boolean indicating that left and right values must be inverted
  38009. */
  38010. reverseLeftRight: boolean;
  38011. /**
  38012. * Gets or sets a boolean indicating that up and down values must be inverted
  38013. */
  38014. reverseUpDown: boolean;
  38015. /**
  38016. * Gets the offset value for the position (ie. the change of the position value)
  38017. */
  38018. deltaPosition: Vector3;
  38019. /**
  38020. * Gets a boolean indicating if the virtual joystick was pressed
  38021. */
  38022. pressed: boolean;
  38023. /**
  38024. * Canvas the virtual joystick will render onto, default z-index of this is 5
  38025. */
  38026. static Canvas: Nullable<HTMLCanvasElement>;
  38027. private static _globalJoystickIndex;
  38028. private static vjCanvasContext;
  38029. private static vjCanvasWidth;
  38030. private static vjCanvasHeight;
  38031. private static halfWidth;
  38032. private _action;
  38033. private _axisTargetedByLeftAndRight;
  38034. private _axisTargetedByUpAndDown;
  38035. private _joystickSensibility;
  38036. private _inversedSensibility;
  38037. private _joystickPointerID;
  38038. private _joystickColor;
  38039. private _joystickPointerPos;
  38040. private _joystickPreviousPointerPos;
  38041. private _joystickPointerStartPos;
  38042. private _deltaJoystickVector;
  38043. private _leftJoystick;
  38044. private _touches;
  38045. private _onPointerDownHandlerRef;
  38046. private _onPointerMoveHandlerRef;
  38047. private _onPointerUpHandlerRef;
  38048. private _onResize;
  38049. /**
  38050. * Creates a new virtual joystick
  38051. * @param leftJoystick defines that the joystick is for left hand (false by default)
  38052. */
  38053. constructor(leftJoystick?: boolean);
  38054. /**
  38055. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  38056. * @param newJoystickSensibility defines the new sensibility
  38057. */
  38058. setJoystickSensibility(newJoystickSensibility: number): void;
  38059. private _onPointerDown;
  38060. private _onPointerMove;
  38061. private _onPointerUp;
  38062. /**
  38063. * Change the color of the virtual joystick
  38064. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  38065. */
  38066. setJoystickColor(newColor: string): void;
  38067. /**
  38068. * Defines a callback to call when the joystick is touched
  38069. * @param action defines the callback
  38070. */
  38071. setActionOnTouch(action: () => any): void;
  38072. /**
  38073. * Defines which axis you'd like to control for left & right
  38074. * @param axis defines the axis to use
  38075. */
  38076. setAxisForLeftRight(axis: JoystickAxis): void;
  38077. /**
  38078. * Defines which axis you'd like to control for up & down
  38079. * @param axis defines the axis to use
  38080. */
  38081. setAxisForUpDown(axis: JoystickAxis): void;
  38082. private _drawVirtualJoystick;
  38083. /**
  38084. * Release internal HTML canvas
  38085. */
  38086. releaseCanvas(): void;
  38087. }
  38088. }
  38089. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  38090. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  38091. import { Nullable } from "babylonjs/types";
  38092. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38093. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38094. module "babylonjs/Cameras/freeCameraInputsManager" {
  38095. interface FreeCameraInputsManager {
  38096. /**
  38097. * Add virtual joystick input support to the input manager.
  38098. * @returns the current input manager
  38099. */
  38100. addVirtualJoystick(): FreeCameraInputsManager;
  38101. }
  38102. }
  38103. /**
  38104. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  38105. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38106. */
  38107. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  38108. /**
  38109. * Defines the camera the input is attached to.
  38110. */
  38111. camera: FreeCamera;
  38112. private _leftjoystick;
  38113. private _rightjoystick;
  38114. /**
  38115. * Gets the left stick of the virtual joystick.
  38116. * @returns The virtual Joystick
  38117. */
  38118. getLeftJoystick(): VirtualJoystick;
  38119. /**
  38120. * Gets the right stick of the virtual joystick.
  38121. * @returns The virtual Joystick
  38122. */
  38123. getRightJoystick(): VirtualJoystick;
  38124. /**
  38125. * Update the current camera state depending on the inputs that have been used this frame.
  38126. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38127. */
  38128. checkInputs(): void;
  38129. /**
  38130. * Attach the input controls to a specific dom element to get the input from.
  38131. * @param element Defines the element the controls should be listened from
  38132. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38133. */
  38134. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38135. /**
  38136. * Detach the current controls from the specified dom element.
  38137. * @param element Defines the element to stop listening the inputs from
  38138. */
  38139. detachControl(element: Nullable<HTMLElement>): void;
  38140. /**
  38141. * Gets the class name of the current intput.
  38142. * @returns the class name
  38143. */
  38144. getClassName(): string;
  38145. /**
  38146. * Get the friendly name associated with the input class.
  38147. * @returns the input friendly name
  38148. */
  38149. getSimpleName(): string;
  38150. }
  38151. }
  38152. declare module "babylonjs/Cameras/Inputs/index" {
  38153. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  38154. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  38155. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  38156. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  38157. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  38158. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  38159. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  38160. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  38161. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  38162. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  38163. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  38164. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  38165. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  38166. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  38167. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  38168. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  38169. }
  38170. declare module "babylonjs/Cameras/touchCamera" {
  38171. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38172. import { Scene } from "babylonjs/scene";
  38173. import { Vector3 } from "babylonjs/Maths/math";
  38174. /**
  38175. * This represents a FPS type of camera controlled by touch.
  38176. * This is like a universal camera minus the Gamepad controls.
  38177. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38178. */
  38179. export class TouchCamera extends FreeCamera {
  38180. /**
  38181. * Defines the touch sensibility for rotation.
  38182. * The higher the faster.
  38183. */
  38184. touchAngularSensibility: number;
  38185. /**
  38186. * Defines the touch sensibility for move.
  38187. * The higher the faster.
  38188. */
  38189. touchMoveSensibility: number;
  38190. /**
  38191. * Instantiates a new touch camera.
  38192. * This represents a FPS type of camera controlled by touch.
  38193. * This is like a universal camera minus the Gamepad controls.
  38194. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38195. * @param name Define the name of the camera in the scene
  38196. * @param position Define the start position of the camera in the scene
  38197. * @param scene Define the scene the camera belongs to
  38198. */
  38199. constructor(name: string, position: Vector3, scene: Scene);
  38200. /**
  38201. * Gets the current object class name.
  38202. * @return the class name
  38203. */
  38204. getClassName(): string;
  38205. /** @hidden */
  38206. _setupInputs(): void;
  38207. }
  38208. }
  38209. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  38210. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38211. import { Scene } from "babylonjs/scene";
  38212. import { Vector3, Axis } from "babylonjs/Maths/math";
  38213. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  38214. /**
  38215. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  38216. * being tilted forward or back and left or right.
  38217. */
  38218. export class DeviceOrientationCamera extends FreeCamera {
  38219. private _initialQuaternion;
  38220. private _quaternionCache;
  38221. private _tmpDragQuaternion;
  38222. /**
  38223. * Creates a new device orientation camera
  38224. * @param name The name of the camera
  38225. * @param position The start position camera
  38226. * @param scene The scene the camera belongs to
  38227. */
  38228. constructor(name: string, position: Vector3, scene: Scene);
  38229. /**
  38230. * Disabled pointer input on first orientation sensor update (Default: true)
  38231. */
  38232. disablePointerInputWhenUsingDeviceOrientation: boolean;
  38233. private _dragFactor;
  38234. /**
  38235. * Enabled turning on the y axis when the orientation sensor is active
  38236. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  38237. */
  38238. enableHorizontalDragging(dragFactor?: number): void;
  38239. /**
  38240. * Gets the current instance class name ("DeviceOrientationCamera").
  38241. * This helps avoiding instanceof at run time.
  38242. * @returns the class name
  38243. */
  38244. getClassName(): string;
  38245. /**
  38246. * @hidden
  38247. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  38248. */
  38249. _checkInputs(): void;
  38250. /**
  38251. * Reset the camera to its default orientation on the specified axis only.
  38252. * @param axis The axis to reset
  38253. */
  38254. resetToCurrentRotation(axis?: Axis): void;
  38255. }
  38256. }
  38257. declare module "babylonjs/Cameras/universalCamera" {
  38258. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  38259. import { Scene } from "babylonjs/scene";
  38260. import { Vector3 } from "babylonjs/Maths/math";
  38261. /**
  38262. * 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,
  38263. * which still works and will still be found in many Playgrounds.
  38264. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38265. */
  38266. export class UniversalCamera extends TouchCamera {
  38267. /**
  38268. * Defines the gamepad rotation sensiblity.
  38269. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  38270. */
  38271. gamepadAngularSensibility: number;
  38272. /**
  38273. * Defines the gamepad move sensiblity.
  38274. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  38275. */
  38276. gamepadMoveSensibility: number;
  38277. /**
  38278. * 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,
  38279. * which still works and will still be found in many Playgrounds.
  38280. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38281. * @param name Define the name of the camera in the scene
  38282. * @param position Define the start position of the camera in the scene
  38283. * @param scene Define the scene the camera belongs to
  38284. */
  38285. constructor(name: string, position: Vector3, scene: Scene);
  38286. /**
  38287. * Gets the current object class name.
  38288. * @return the class name
  38289. */
  38290. getClassName(): string;
  38291. }
  38292. }
  38293. declare module "babylonjs/Cameras/gamepadCamera" {
  38294. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  38295. import { Scene } from "babylonjs/scene";
  38296. import { Vector3 } from "babylonjs/Maths/math";
  38297. /**
  38298. * This represents a FPS type of camera. This is only here for back compat purpose.
  38299. * Please use the UniversalCamera instead as both are identical.
  38300. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38301. */
  38302. export class GamepadCamera extends UniversalCamera {
  38303. /**
  38304. * Instantiates a new Gamepad Camera
  38305. * This represents a FPS type of camera. This is only here for back compat purpose.
  38306. * Please use the UniversalCamera instead as both are identical.
  38307. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38308. * @param name Define the name of the camera in the scene
  38309. * @param position Define the start position of the camera in the scene
  38310. * @param scene Define the scene the camera belongs to
  38311. */
  38312. constructor(name: string, position: Vector3, scene: Scene);
  38313. /**
  38314. * Gets the current object class name.
  38315. * @return the class name
  38316. */
  38317. getClassName(): string;
  38318. }
  38319. }
  38320. declare module "babylonjs/Shaders/pass.fragment" {
  38321. /** @hidden */
  38322. export var passPixelShader: {
  38323. name: string;
  38324. shader: string;
  38325. };
  38326. }
  38327. declare module "babylonjs/Shaders/passCube.fragment" {
  38328. /** @hidden */
  38329. export var passCubePixelShader: {
  38330. name: string;
  38331. shader: string;
  38332. };
  38333. }
  38334. declare module "babylonjs/PostProcesses/passPostProcess" {
  38335. import { Nullable } from "babylonjs/types";
  38336. import { Camera } from "babylonjs/Cameras/camera";
  38337. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  38338. import { Engine } from "babylonjs/Engines/engine";
  38339. import "babylonjs/Shaders/pass.fragment";
  38340. import "babylonjs/Shaders/passCube.fragment";
  38341. /**
  38342. * PassPostProcess which produces an output the same as it's input
  38343. */
  38344. export class PassPostProcess extends PostProcess {
  38345. /**
  38346. * Creates the PassPostProcess
  38347. * @param name The name of the effect.
  38348. * @param options The required width/height ratio to downsize to before computing the render pass.
  38349. * @param camera The camera to apply the render pass to.
  38350. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  38351. * @param engine The engine which the post process will be applied. (default: current engine)
  38352. * @param reusable If the post process can be reused on the same frame. (default: false)
  38353. * @param textureType The type of texture to be used when performing the post processing.
  38354. * @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)
  38355. */
  38356. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  38357. }
  38358. /**
  38359. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  38360. */
  38361. export class PassCubePostProcess extends PostProcess {
  38362. private _face;
  38363. /**
  38364. * Gets or sets the cube face to display.
  38365. * * 0 is +X
  38366. * * 1 is -X
  38367. * * 2 is +Y
  38368. * * 3 is -Y
  38369. * * 4 is +Z
  38370. * * 5 is -Z
  38371. */
  38372. face: number;
  38373. /**
  38374. * Creates the PassCubePostProcess
  38375. * @param name The name of the effect.
  38376. * @param options The required width/height ratio to downsize to before computing the render pass.
  38377. * @param camera The camera to apply the render pass to.
  38378. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  38379. * @param engine The engine which the post process will be applied. (default: current engine)
  38380. * @param reusable If the post process can be reused on the same frame. (default: false)
  38381. * @param textureType The type of texture to be used when performing the post processing.
  38382. * @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)
  38383. */
  38384. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  38385. }
  38386. }
  38387. declare module "babylonjs/Shaders/anaglyph.fragment" {
  38388. /** @hidden */
  38389. export var anaglyphPixelShader: {
  38390. name: string;
  38391. shader: string;
  38392. };
  38393. }
  38394. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  38395. import { Engine } from "babylonjs/Engines/engine";
  38396. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  38397. import { Camera } from "babylonjs/Cameras/camera";
  38398. import "babylonjs/Shaders/anaglyph.fragment";
  38399. /**
  38400. * Postprocess used to generate anaglyphic rendering
  38401. */
  38402. export class AnaglyphPostProcess extends PostProcess {
  38403. private _passedProcess;
  38404. /**
  38405. * Creates a new AnaglyphPostProcess
  38406. * @param name defines postprocess name
  38407. * @param options defines creation options or target ratio scale
  38408. * @param rigCameras defines cameras using this postprocess
  38409. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  38410. * @param engine defines hosting engine
  38411. * @param reusable defines if the postprocess will be reused multiple times per frame
  38412. */
  38413. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  38414. }
  38415. }
  38416. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  38417. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  38418. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38419. import { Scene } from "babylonjs/scene";
  38420. import { Vector3 } from "babylonjs/Maths/math";
  38421. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  38422. /**
  38423. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  38424. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38425. */
  38426. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  38427. /**
  38428. * Creates a new AnaglyphArcRotateCamera
  38429. * @param name defines camera name
  38430. * @param alpha defines alpha angle (in radians)
  38431. * @param beta defines beta angle (in radians)
  38432. * @param radius defines radius
  38433. * @param target defines camera target
  38434. * @param interaxialDistance defines distance between each color axis
  38435. * @param scene defines the hosting scene
  38436. */
  38437. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  38438. /**
  38439. * Gets camera class name
  38440. * @returns AnaglyphArcRotateCamera
  38441. */
  38442. getClassName(): string;
  38443. }
  38444. }
  38445. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  38446. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38447. import { Scene } from "babylonjs/scene";
  38448. import { Vector3 } from "babylonjs/Maths/math";
  38449. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  38450. /**
  38451. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  38452. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38453. */
  38454. export class AnaglyphFreeCamera extends FreeCamera {
  38455. /**
  38456. * Creates a new AnaglyphFreeCamera
  38457. * @param name defines camera name
  38458. * @param position defines initial position
  38459. * @param interaxialDistance defines distance between each color axis
  38460. * @param scene defines the hosting scene
  38461. */
  38462. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  38463. /**
  38464. * Gets camera class name
  38465. * @returns AnaglyphFreeCamera
  38466. */
  38467. getClassName(): string;
  38468. }
  38469. }
  38470. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  38471. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  38472. import { Scene } from "babylonjs/scene";
  38473. import { Vector3 } from "babylonjs/Maths/math";
  38474. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  38475. /**
  38476. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  38477. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38478. */
  38479. export class AnaglyphGamepadCamera extends GamepadCamera {
  38480. /**
  38481. * Creates a new AnaglyphGamepadCamera
  38482. * @param name defines camera name
  38483. * @param position defines initial position
  38484. * @param interaxialDistance defines distance between each color axis
  38485. * @param scene defines the hosting scene
  38486. */
  38487. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  38488. /**
  38489. * Gets camera class name
  38490. * @returns AnaglyphGamepadCamera
  38491. */
  38492. getClassName(): string;
  38493. }
  38494. }
  38495. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  38496. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  38497. import { Scene } from "babylonjs/scene";
  38498. import { Vector3 } from "babylonjs/Maths/math";
  38499. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  38500. /**
  38501. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  38502. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38503. */
  38504. export class AnaglyphUniversalCamera extends UniversalCamera {
  38505. /**
  38506. * Creates a new AnaglyphUniversalCamera
  38507. * @param name defines camera name
  38508. * @param position defines initial position
  38509. * @param interaxialDistance defines distance between each color axis
  38510. * @param scene defines the hosting scene
  38511. */
  38512. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  38513. /**
  38514. * Gets camera class name
  38515. * @returns AnaglyphUniversalCamera
  38516. */
  38517. getClassName(): string;
  38518. }
  38519. }
  38520. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  38521. /** @hidden */
  38522. export var stereoscopicInterlacePixelShader: {
  38523. name: string;
  38524. shader: string;
  38525. };
  38526. }
  38527. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  38528. import { Camera } from "babylonjs/Cameras/camera";
  38529. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  38530. import { Engine } from "babylonjs/Engines/engine";
  38531. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  38532. /**
  38533. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  38534. */
  38535. export class StereoscopicInterlacePostProcess extends PostProcess {
  38536. private _stepSize;
  38537. private _passedProcess;
  38538. /**
  38539. * Initializes a StereoscopicInterlacePostProcess
  38540. * @param name The name of the effect.
  38541. * @param rigCameras The rig cameras to be appled to the post process
  38542. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  38543. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  38544. * @param engine The engine which the post process will be applied. (default: current engine)
  38545. * @param reusable If the post process can be reused on the same frame. (default: false)
  38546. */
  38547. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  38548. }
  38549. }
  38550. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  38551. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  38552. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38553. import { Scene } from "babylonjs/scene";
  38554. import { Vector3 } from "babylonjs/Maths/math";
  38555. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  38556. /**
  38557. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  38558. * @see http://doc.babylonjs.com/features/cameras
  38559. */
  38560. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  38561. /**
  38562. * Creates a new StereoscopicArcRotateCamera
  38563. * @param name defines camera name
  38564. * @param alpha defines alpha angle (in radians)
  38565. * @param beta defines beta angle (in radians)
  38566. * @param radius defines radius
  38567. * @param target defines camera target
  38568. * @param interaxialDistance defines distance between each color axis
  38569. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38570. * @param scene defines the hosting scene
  38571. */
  38572. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38573. /**
  38574. * Gets camera class name
  38575. * @returns StereoscopicArcRotateCamera
  38576. */
  38577. getClassName(): string;
  38578. }
  38579. }
  38580. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  38581. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38582. import { Scene } from "babylonjs/scene";
  38583. import { Vector3 } from "babylonjs/Maths/math";
  38584. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  38585. /**
  38586. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  38587. * @see http://doc.babylonjs.com/features/cameras
  38588. */
  38589. export class StereoscopicFreeCamera extends FreeCamera {
  38590. /**
  38591. * Creates a new StereoscopicFreeCamera
  38592. * @param name defines camera name
  38593. * @param position defines initial position
  38594. * @param interaxialDistance defines distance between each color axis
  38595. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38596. * @param scene defines the hosting scene
  38597. */
  38598. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38599. /**
  38600. * Gets camera class name
  38601. * @returns StereoscopicFreeCamera
  38602. */
  38603. getClassName(): string;
  38604. }
  38605. }
  38606. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  38607. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  38608. import { Scene } from "babylonjs/scene";
  38609. import { Vector3 } from "babylonjs/Maths/math";
  38610. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  38611. /**
  38612. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  38613. * @see http://doc.babylonjs.com/features/cameras
  38614. */
  38615. export class StereoscopicGamepadCamera extends GamepadCamera {
  38616. /**
  38617. * Creates a new StereoscopicGamepadCamera
  38618. * @param name defines camera name
  38619. * @param position defines initial position
  38620. * @param interaxialDistance defines distance between each color axis
  38621. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38622. * @param scene defines the hosting scene
  38623. */
  38624. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38625. /**
  38626. * Gets camera class name
  38627. * @returns StereoscopicGamepadCamera
  38628. */
  38629. getClassName(): string;
  38630. }
  38631. }
  38632. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  38633. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  38634. import { Scene } from "babylonjs/scene";
  38635. import { Vector3 } from "babylonjs/Maths/math";
  38636. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  38637. /**
  38638. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  38639. * @see http://doc.babylonjs.com/features/cameras
  38640. */
  38641. export class StereoscopicUniversalCamera extends UniversalCamera {
  38642. /**
  38643. * Creates a new StereoscopicUniversalCamera
  38644. * @param name defines camera name
  38645. * @param position defines initial position
  38646. * @param interaxialDistance defines distance between each color axis
  38647. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38648. * @param scene defines the hosting scene
  38649. */
  38650. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38651. /**
  38652. * Gets camera class name
  38653. * @returns StereoscopicUniversalCamera
  38654. */
  38655. getClassName(): string;
  38656. }
  38657. }
  38658. declare module "babylonjs/Cameras/Stereoscopic/index" {
  38659. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  38660. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  38661. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  38662. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  38663. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  38664. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  38665. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  38666. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  38667. }
  38668. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  38669. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38670. import { Scene } from "babylonjs/scene";
  38671. import { Vector3 } from "babylonjs/Maths/math";
  38672. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  38673. /**
  38674. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  38675. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  38676. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  38677. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  38678. */
  38679. export class VirtualJoysticksCamera extends FreeCamera {
  38680. /**
  38681. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  38682. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  38683. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  38684. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  38685. * @param name Define the name of the camera in the scene
  38686. * @param position Define the start position of the camera in the scene
  38687. * @param scene Define the scene the camera belongs to
  38688. */
  38689. constructor(name: string, position: Vector3, scene: Scene);
  38690. /**
  38691. * Gets the current object class name.
  38692. * @return the class name
  38693. */
  38694. getClassName(): string;
  38695. }
  38696. }
  38697. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  38698. import { Matrix } from "babylonjs/Maths/math";
  38699. /**
  38700. * This represents all the required metrics to create a VR camera.
  38701. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  38702. */
  38703. export class VRCameraMetrics {
  38704. /**
  38705. * Define the horizontal resolution off the screen.
  38706. */
  38707. hResolution: number;
  38708. /**
  38709. * Define the vertical resolution off the screen.
  38710. */
  38711. vResolution: number;
  38712. /**
  38713. * Define the horizontal screen size.
  38714. */
  38715. hScreenSize: number;
  38716. /**
  38717. * Define the vertical screen size.
  38718. */
  38719. vScreenSize: number;
  38720. /**
  38721. * Define the vertical screen center position.
  38722. */
  38723. vScreenCenter: number;
  38724. /**
  38725. * Define the distance of the eyes to the screen.
  38726. */
  38727. eyeToScreenDistance: number;
  38728. /**
  38729. * Define the distance between both lenses
  38730. */
  38731. lensSeparationDistance: number;
  38732. /**
  38733. * Define the distance between both viewer's eyes.
  38734. */
  38735. interpupillaryDistance: number;
  38736. /**
  38737. * Define the distortion factor of the VR postprocess.
  38738. * Please, touch with care.
  38739. */
  38740. distortionK: number[];
  38741. /**
  38742. * Define the chromatic aberration correction factors for the VR post process.
  38743. */
  38744. chromaAbCorrection: number[];
  38745. /**
  38746. * Define the scale factor of the post process.
  38747. * The smaller the better but the slower.
  38748. */
  38749. postProcessScaleFactor: number;
  38750. /**
  38751. * Define an offset for the lens center.
  38752. */
  38753. lensCenterOffset: number;
  38754. /**
  38755. * Define if the current vr camera should compensate the distortion of the lense or not.
  38756. */
  38757. compensateDistortion: boolean;
  38758. /**
  38759. * Defines if multiview should be enabled when rendering (Default: false)
  38760. */
  38761. multiviewEnabled: boolean;
  38762. /**
  38763. * Gets the rendering aspect ratio based on the provided resolutions.
  38764. */
  38765. readonly aspectRatio: number;
  38766. /**
  38767. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  38768. */
  38769. readonly aspectRatioFov: number;
  38770. /**
  38771. * @hidden
  38772. */
  38773. readonly leftHMatrix: Matrix;
  38774. /**
  38775. * @hidden
  38776. */
  38777. readonly rightHMatrix: Matrix;
  38778. /**
  38779. * @hidden
  38780. */
  38781. readonly leftPreViewMatrix: Matrix;
  38782. /**
  38783. * @hidden
  38784. */
  38785. readonly rightPreViewMatrix: Matrix;
  38786. /**
  38787. * Get the default VRMetrics based on the most generic setup.
  38788. * @returns the default vr metrics
  38789. */
  38790. static GetDefault(): VRCameraMetrics;
  38791. }
  38792. }
  38793. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  38794. /** @hidden */
  38795. export var vrDistortionCorrectionPixelShader: {
  38796. name: string;
  38797. shader: string;
  38798. };
  38799. }
  38800. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  38801. import { Camera } from "babylonjs/Cameras/camera";
  38802. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  38803. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  38804. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  38805. /**
  38806. * VRDistortionCorrectionPostProcess used for mobile VR
  38807. */
  38808. export class VRDistortionCorrectionPostProcess extends PostProcess {
  38809. private _isRightEye;
  38810. private _distortionFactors;
  38811. private _postProcessScaleFactor;
  38812. private _lensCenterOffset;
  38813. private _scaleIn;
  38814. private _scaleFactor;
  38815. private _lensCenter;
  38816. /**
  38817. * Initializes the VRDistortionCorrectionPostProcess
  38818. * @param name The name of the effect.
  38819. * @param camera The camera to apply the render pass to.
  38820. * @param isRightEye If this is for the right eye distortion
  38821. * @param vrMetrics All the required metrics for the VR camera
  38822. */
  38823. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  38824. }
  38825. }
  38826. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  38827. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  38828. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38829. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  38830. import { Scene } from "babylonjs/scene";
  38831. import { Vector3 } from "babylonjs/Maths/math";
  38832. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  38833. import "babylonjs/Cameras/RigModes/vrRigMode";
  38834. /**
  38835. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  38836. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  38837. */
  38838. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  38839. /**
  38840. * Creates a new VRDeviceOrientationArcRotateCamera
  38841. * @param name defines camera name
  38842. * @param alpha defines the camera rotation along the logitudinal axis
  38843. * @param beta defines the camera rotation along the latitudinal axis
  38844. * @param radius defines the camera distance from its target
  38845. * @param target defines the camera target
  38846. * @param scene defines the scene the camera belongs to
  38847. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  38848. * @param vrCameraMetrics defines the vr metrics associated to the camera
  38849. */
  38850. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  38851. /**
  38852. * Gets camera class name
  38853. * @returns VRDeviceOrientationArcRotateCamera
  38854. */
  38855. getClassName(): string;
  38856. }
  38857. }
  38858. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  38859. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  38860. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  38861. import { Scene } from "babylonjs/scene";
  38862. import { Vector3 } from "babylonjs/Maths/math";
  38863. import "babylonjs/Cameras/RigModes/vrRigMode";
  38864. /**
  38865. * Camera used to simulate VR rendering (based on FreeCamera)
  38866. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  38867. */
  38868. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  38869. /**
  38870. * Creates a new VRDeviceOrientationFreeCamera
  38871. * @param name defines camera name
  38872. * @param position defines the start position of the camera
  38873. * @param scene defines the scene the camera belongs to
  38874. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  38875. * @param vrCameraMetrics defines the vr metrics associated to the camera
  38876. */
  38877. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  38878. /**
  38879. * Gets camera class name
  38880. * @returns VRDeviceOrientationFreeCamera
  38881. */
  38882. getClassName(): string;
  38883. }
  38884. }
  38885. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  38886. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  38887. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  38888. import { Scene } from "babylonjs/scene";
  38889. import { Vector3 } from "babylonjs/Maths/math";
  38890. /**
  38891. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  38892. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  38893. */
  38894. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  38895. /**
  38896. * Creates a new VRDeviceOrientationGamepadCamera
  38897. * @param name defines camera name
  38898. * @param position defines the start position of the camera
  38899. * @param scene defines the scene the camera belongs to
  38900. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  38901. * @param vrCameraMetrics defines the vr metrics associated to the camera
  38902. */
  38903. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  38904. /**
  38905. * Gets camera class name
  38906. * @returns VRDeviceOrientationGamepadCamera
  38907. */
  38908. getClassName(): string;
  38909. }
  38910. }
  38911. declare module "babylonjs/Gamepads/xboxGamepad" {
  38912. import { Observable } from "babylonjs/Misc/observable";
  38913. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  38914. /**
  38915. * Defines supported buttons for XBox360 compatible gamepads
  38916. */
  38917. export enum Xbox360Button {
  38918. /** A */
  38919. A = 0,
  38920. /** B */
  38921. B = 1,
  38922. /** X */
  38923. X = 2,
  38924. /** Y */
  38925. Y = 3,
  38926. /** Start */
  38927. Start = 4,
  38928. /** Back */
  38929. Back = 5,
  38930. /** Left button */
  38931. LB = 6,
  38932. /** Right button */
  38933. RB = 7,
  38934. /** Left stick */
  38935. LeftStick = 8,
  38936. /** Right stick */
  38937. RightStick = 9
  38938. }
  38939. /** Defines values for XBox360 DPad */
  38940. export enum Xbox360Dpad {
  38941. /** Up */
  38942. Up = 0,
  38943. /** Down */
  38944. Down = 1,
  38945. /** Left */
  38946. Left = 2,
  38947. /** Right */
  38948. Right = 3
  38949. }
  38950. /**
  38951. * Defines a XBox360 gamepad
  38952. */
  38953. export class Xbox360Pad extends Gamepad {
  38954. private _leftTrigger;
  38955. private _rightTrigger;
  38956. private _onlefttriggerchanged;
  38957. private _onrighttriggerchanged;
  38958. private _onbuttondown;
  38959. private _onbuttonup;
  38960. private _ondpaddown;
  38961. private _ondpadup;
  38962. /** Observable raised when a button is pressed */
  38963. onButtonDownObservable: Observable<Xbox360Button>;
  38964. /** Observable raised when a button is released */
  38965. onButtonUpObservable: Observable<Xbox360Button>;
  38966. /** Observable raised when a pad is pressed */
  38967. onPadDownObservable: Observable<Xbox360Dpad>;
  38968. /** Observable raised when a pad is released */
  38969. onPadUpObservable: Observable<Xbox360Dpad>;
  38970. private _buttonA;
  38971. private _buttonB;
  38972. private _buttonX;
  38973. private _buttonY;
  38974. private _buttonBack;
  38975. private _buttonStart;
  38976. private _buttonLB;
  38977. private _buttonRB;
  38978. private _buttonLeftStick;
  38979. private _buttonRightStick;
  38980. private _dPadUp;
  38981. private _dPadDown;
  38982. private _dPadLeft;
  38983. private _dPadRight;
  38984. private _isXboxOnePad;
  38985. /**
  38986. * Creates a new XBox360 gamepad object
  38987. * @param id defines the id of this gamepad
  38988. * @param index defines its index
  38989. * @param gamepad defines the internal HTML gamepad object
  38990. * @param xboxOne defines if it is a XBox One gamepad
  38991. */
  38992. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  38993. /**
  38994. * Defines the callback to call when left trigger is pressed
  38995. * @param callback defines the callback to use
  38996. */
  38997. onlefttriggerchanged(callback: (value: number) => void): void;
  38998. /**
  38999. * Defines the callback to call when right trigger is pressed
  39000. * @param callback defines the callback to use
  39001. */
  39002. onrighttriggerchanged(callback: (value: number) => void): void;
  39003. /**
  39004. * Gets the left trigger value
  39005. */
  39006. /**
  39007. * Sets the left trigger value
  39008. */
  39009. leftTrigger: number;
  39010. /**
  39011. * Gets the right trigger value
  39012. */
  39013. /**
  39014. * Sets the right trigger value
  39015. */
  39016. rightTrigger: number;
  39017. /**
  39018. * Defines the callback to call when a button is pressed
  39019. * @param callback defines the callback to use
  39020. */
  39021. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  39022. /**
  39023. * Defines the callback to call when a button is released
  39024. * @param callback defines the callback to use
  39025. */
  39026. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  39027. /**
  39028. * Defines the callback to call when a pad is pressed
  39029. * @param callback defines the callback to use
  39030. */
  39031. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  39032. /**
  39033. * Defines the callback to call when a pad is released
  39034. * @param callback defines the callback to use
  39035. */
  39036. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  39037. private _setButtonValue;
  39038. private _setDPadValue;
  39039. /**
  39040. * Gets the value of the `A` button
  39041. */
  39042. /**
  39043. * Sets the value of the `A` button
  39044. */
  39045. buttonA: number;
  39046. /**
  39047. * Gets the value of the `B` button
  39048. */
  39049. /**
  39050. * Sets the value of the `B` button
  39051. */
  39052. buttonB: number;
  39053. /**
  39054. * Gets the value of the `X` button
  39055. */
  39056. /**
  39057. * Sets the value of the `X` button
  39058. */
  39059. buttonX: number;
  39060. /**
  39061. * Gets the value of the `Y` button
  39062. */
  39063. /**
  39064. * Sets the value of the `Y` button
  39065. */
  39066. buttonY: number;
  39067. /**
  39068. * Gets the value of the `Start` button
  39069. */
  39070. /**
  39071. * Sets the value of the `Start` button
  39072. */
  39073. buttonStart: number;
  39074. /**
  39075. * Gets the value of the `Back` button
  39076. */
  39077. /**
  39078. * Sets the value of the `Back` button
  39079. */
  39080. buttonBack: number;
  39081. /**
  39082. * Gets the value of the `Left` button
  39083. */
  39084. /**
  39085. * Sets the value of the `Left` button
  39086. */
  39087. buttonLB: number;
  39088. /**
  39089. * Gets the value of the `Right` button
  39090. */
  39091. /**
  39092. * Sets the value of the `Right` button
  39093. */
  39094. buttonRB: number;
  39095. /**
  39096. * Gets the value of the Left joystick
  39097. */
  39098. /**
  39099. * Sets the value of the Left joystick
  39100. */
  39101. buttonLeftStick: number;
  39102. /**
  39103. * Gets the value of the Right joystick
  39104. */
  39105. /**
  39106. * Sets the value of the Right joystick
  39107. */
  39108. buttonRightStick: number;
  39109. /**
  39110. * Gets the value of D-pad up
  39111. */
  39112. /**
  39113. * Sets the value of D-pad up
  39114. */
  39115. dPadUp: number;
  39116. /**
  39117. * Gets the value of D-pad down
  39118. */
  39119. /**
  39120. * Sets the value of D-pad down
  39121. */
  39122. dPadDown: number;
  39123. /**
  39124. * Gets the value of D-pad left
  39125. */
  39126. /**
  39127. * Sets the value of D-pad left
  39128. */
  39129. dPadLeft: number;
  39130. /**
  39131. * Gets the value of D-pad right
  39132. */
  39133. /**
  39134. * Sets the value of D-pad right
  39135. */
  39136. dPadRight: number;
  39137. /**
  39138. * Force the gamepad to synchronize with device values
  39139. */
  39140. update(): void;
  39141. /**
  39142. * Disposes the gamepad
  39143. */
  39144. dispose(): void;
  39145. }
  39146. }
  39147. declare module "babylonjs/Materials/pushMaterial" {
  39148. import { Nullable } from "babylonjs/types";
  39149. import { Scene } from "babylonjs/scene";
  39150. import { Matrix } from "babylonjs/Maths/math";
  39151. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39152. import { Mesh } from "babylonjs/Meshes/mesh";
  39153. import { Material } from "babylonjs/Materials/material";
  39154. import { Effect } from "babylonjs/Materials/effect";
  39155. /**
  39156. * Base class of materials working in push mode in babylon JS
  39157. * @hidden
  39158. */
  39159. export class PushMaterial extends Material {
  39160. protected _activeEffect: Effect;
  39161. protected _normalMatrix: Matrix;
  39162. /**
  39163. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  39164. * This means that the material can keep using a previous shader while a new one is being compiled.
  39165. * This is mostly used when shader parallel compilation is supported (true by default)
  39166. */
  39167. allowShaderHotSwapping: boolean;
  39168. constructor(name: string, scene: Scene);
  39169. getEffect(): Effect;
  39170. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  39171. /**
  39172. * Binds the given world matrix to the active effect
  39173. *
  39174. * @param world the matrix to bind
  39175. */
  39176. bindOnlyWorldMatrix(world: Matrix): void;
  39177. /**
  39178. * Binds the given normal matrix to the active effect
  39179. *
  39180. * @param normalMatrix the matrix to bind
  39181. */
  39182. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  39183. bind(world: Matrix, mesh?: Mesh): void;
  39184. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  39185. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  39186. }
  39187. }
  39188. declare module "babylonjs/Materials/materialFlags" {
  39189. /**
  39190. * This groups all the flags used to control the materials channel.
  39191. */
  39192. export class MaterialFlags {
  39193. private static _DiffuseTextureEnabled;
  39194. /**
  39195. * Are diffuse textures enabled in the application.
  39196. */
  39197. static DiffuseTextureEnabled: boolean;
  39198. private static _AmbientTextureEnabled;
  39199. /**
  39200. * Are ambient textures enabled in the application.
  39201. */
  39202. static AmbientTextureEnabled: boolean;
  39203. private static _OpacityTextureEnabled;
  39204. /**
  39205. * Are opacity textures enabled in the application.
  39206. */
  39207. static OpacityTextureEnabled: boolean;
  39208. private static _ReflectionTextureEnabled;
  39209. /**
  39210. * Are reflection textures enabled in the application.
  39211. */
  39212. static ReflectionTextureEnabled: boolean;
  39213. private static _EmissiveTextureEnabled;
  39214. /**
  39215. * Are emissive textures enabled in the application.
  39216. */
  39217. static EmissiveTextureEnabled: boolean;
  39218. private static _SpecularTextureEnabled;
  39219. /**
  39220. * Are specular textures enabled in the application.
  39221. */
  39222. static SpecularTextureEnabled: boolean;
  39223. private static _BumpTextureEnabled;
  39224. /**
  39225. * Are bump textures enabled in the application.
  39226. */
  39227. static BumpTextureEnabled: boolean;
  39228. private static _LightmapTextureEnabled;
  39229. /**
  39230. * Are lightmap textures enabled in the application.
  39231. */
  39232. static LightmapTextureEnabled: boolean;
  39233. private static _RefractionTextureEnabled;
  39234. /**
  39235. * Are refraction textures enabled in the application.
  39236. */
  39237. static RefractionTextureEnabled: boolean;
  39238. private static _ColorGradingTextureEnabled;
  39239. /**
  39240. * Are color grading textures enabled in the application.
  39241. */
  39242. static ColorGradingTextureEnabled: boolean;
  39243. private static _FresnelEnabled;
  39244. /**
  39245. * Are fresnels enabled in the application.
  39246. */
  39247. static FresnelEnabled: boolean;
  39248. private static _ClearCoatTextureEnabled;
  39249. /**
  39250. * Are clear coat textures enabled in the application.
  39251. */
  39252. static ClearCoatTextureEnabled: boolean;
  39253. private static _ClearCoatBumpTextureEnabled;
  39254. /**
  39255. * Are clear coat bump textures enabled in the application.
  39256. */
  39257. static ClearCoatBumpTextureEnabled: boolean;
  39258. private static _ClearCoatTintTextureEnabled;
  39259. /**
  39260. * Are clear coat tint textures enabled in the application.
  39261. */
  39262. static ClearCoatTintTextureEnabled: boolean;
  39263. private static _SheenTextureEnabled;
  39264. /**
  39265. * Are sheen textures enabled in the application.
  39266. */
  39267. static SheenTextureEnabled: boolean;
  39268. private static _AnisotropicTextureEnabled;
  39269. /**
  39270. * Are anisotropic textures enabled in the application.
  39271. */
  39272. static AnisotropicTextureEnabled: boolean;
  39273. private static _ThicknessTextureEnabled;
  39274. /**
  39275. * Are thickness textures enabled in the application.
  39276. */
  39277. static ThicknessTextureEnabled: boolean;
  39278. }
  39279. }
  39280. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  39281. /** @hidden */
  39282. export var defaultFragmentDeclaration: {
  39283. name: string;
  39284. shader: string;
  39285. };
  39286. }
  39287. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  39288. /** @hidden */
  39289. export var defaultUboDeclaration: {
  39290. name: string;
  39291. shader: string;
  39292. };
  39293. }
  39294. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  39295. /** @hidden */
  39296. export var lightFragmentDeclaration: {
  39297. name: string;
  39298. shader: string;
  39299. };
  39300. }
  39301. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  39302. /** @hidden */
  39303. export var lightUboDeclaration: {
  39304. name: string;
  39305. shader: string;
  39306. };
  39307. }
  39308. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  39309. /** @hidden */
  39310. export var lightsFragmentFunctions: {
  39311. name: string;
  39312. shader: string;
  39313. };
  39314. }
  39315. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  39316. /** @hidden */
  39317. export var shadowsFragmentFunctions: {
  39318. name: string;
  39319. shader: string;
  39320. };
  39321. }
  39322. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  39323. /** @hidden */
  39324. export var fresnelFunction: {
  39325. name: string;
  39326. shader: string;
  39327. };
  39328. }
  39329. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  39330. /** @hidden */
  39331. export var reflectionFunction: {
  39332. name: string;
  39333. shader: string;
  39334. };
  39335. }
  39336. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  39337. /** @hidden */
  39338. export var bumpFragmentFunctions: {
  39339. name: string;
  39340. shader: string;
  39341. };
  39342. }
  39343. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  39344. /** @hidden */
  39345. export var logDepthDeclaration: {
  39346. name: string;
  39347. shader: string;
  39348. };
  39349. }
  39350. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  39351. /** @hidden */
  39352. export var bumpFragment: {
  39353. name: string;
  39354. shader: string;
  39355. };
  39356. }
  39357. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  39358. /** @hidden */
  39359. export var depthPrePass: {
  39360. name: string;
  39361. shader: string;
  39362. };
  39363. }
  39364. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  39365. /** @hidden */
  39366. export var lightFragment: {
  39367. name: string;
  39368. shader: string;
  39369. };
  39370. }
  39371. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  39372. /** @hidden */
  39373. export var logDepthFragment: {
  39374. name: string;
  39375. shader: string;
  39376. };
  39377. }
  39378. declare module "babylonjs/Shaders/default.fragment" {
  39379. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  39380. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  39381. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  39382. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  39383. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  39384. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  39385. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  39386. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  39387. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  39388. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  39389. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  39390. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  39391. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  39392. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  39393. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  39394. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  39395. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  39396. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  39397. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  39398. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  39399. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  39400. /** @hidden */
  39401. export var defaultPixelShader: {
  39402. name: string;
  39403. shader: string;
  39404. };
  39405. }
  39406. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  39407. /** @hidden */
  39408. export var defaultVertexDeclaration: {
  39409. name: string;
  39410. shader: string;
  39411. };
  39412. }
  39413. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  39414. /** @hidden */
  39415. export var bumpVertexDeclaration: {
  39416. name: string;
  39417. shader: string;
  39418. };
  39419. }
  39420. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  39421. /** @hidden */
  39422. export var bumpVertex: {
  39423. name: string;
  39424. shader: string;
  39425. };
  39426. }
  39427. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  39428. /** @hidden */
  39429. export var fogVertex: {
  39430. name: string;
  39431. shader: string;
  39432. };
  39433. }
  39434. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  39435. /** @hidden */
  39436. export var shadowsVertex: {
  39437. name: string;
  39438. shader: string;
  39439. };
  39440. }
  39441. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  39442. /** @hidden */
  39443. export var pointCloudVertex: {
  39444. name: string;
  39445. shader: string;
  39446. };
  39447. }
  39448. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  39449. /** @hidden */
  39450. export var logDepthVertex: {
  39451. name: string;
  39452. shader: string;
  39453. };
  39454. }
  39455. declare module "babylonjs/Shaders/default.vertex" {
  39456. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  39457. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  39458. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  39459. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  39460. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  39461. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  39462. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  39463. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  39464. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  39465. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  39466. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  39467. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  39468. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  39469. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  39470. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  39471. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  39472. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  39473. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  39474. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  39475. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  39476. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  39477. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  39478. /** @hidden */
  39479. export var defaultVertexShader: {
  39480. name: string;
  39481. shader: string;
  39482. };
  39483. }
  39484. declare module "babylonjs/Materials/standardMaterial" {
  39485. import { SmartArray } from "babylonjs/Misc/smartArray";
  39486. import { IAnimatable } from "babylonjs/Misc/tools";
  39487. import { Nullable } from "babylonjs/types";
  39488. import { Scene } from "babylonjs/scene";
  39489. import { Matrix, Color3 } from "babylonjs/Maths/math";
  39490. import { SubMesh } from "babylonjs/Meshes/subMesh";
  39491. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39492. import { Mesh } from "babylonjs/Meshes/mesh";
  39493. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  39494. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  39495. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  39496. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  39497. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  39498. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  39499. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  39500. import "babylonjs/Shaders/default.fragment";
  39501. import "babylonjs/Shaders/default.vertex";
  39502. /** @hidden */
  39503. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  39504. MAINUV1: boolean;
  39505. MAINUV2: boolean;
  39506. DIFFUSE: boolean;
  39507. DIFFUSEDIRECTUV: number;
  39508. AMBIENT: boolean;
  39509. AMBIENTDIRECTUV: number;
  39510. OPACITY: boolean;
  39511. OPACITYDIRECTUV: number;
  39512. OPACITYRGB: boolean;
  39513. REFLECTION: boolean;
  39514. EMISSIVE: boolean;
  39515. EMISSIVEDIRECTUV: number;
  39516. SPECULAR: boolean;
  39517. SPECULARDIRECTUV: number;
  39518. BUMP: boolean;
  39519. BUMPDIRECTUV: number;
  39520. PARALLAX: boolean;
  39521. PARALLAXOCCLUSION: boolean;
  39522. SPECULAROVERALPHA: boolean;
  39523. CLIPPLANE: boolean;
  39524. CLIPPLANE2: boolean;
  39525. CLIPPLANE3: boolean;
  39526. CLIPPLANE4: boolean;
  39527. ALPHATEST: boolean;
  39528. DEPTHPREPASS: boolean;
  39529. ALPHAFROMDIFFUSE: boolean;
  39530. POINTSIZE: boolean;
  39531. FOG: boolean;
  39532. SPECULARTERM: boolean;
  39533. DIFFUSEFRESNEL: boolean;
  39534. OPACITYFRESNEL: boolean;
  39535. REFLECTIONFRESNEL: boolean;
  39536. REFRACTIONFRESNEL: boolean;
  39537. EMISSIVEFRESNEL: boolean;
  39538. FRESNEL: boolean;
  39539. NORMAL: boolean;
  39540. UV1: boolean;
  39541. UV2: boolean;
  39542. VERTEXCOLOR: boolean;
  39543. VERTEXALPHA: boolean;
  39544. NUM_BONE_INFLUENCERS: number;
  39545. BonesPerMesh: number;
  39546. BONETEXTURE: boolean;
  39547. INSTANCES: boolean;
  39548. GLOSSINESS: boolean;
  39549. ROUGHNESS: boolean;
  39550. EMISSIVEASILLUMINATION: boolean;
  39551. LINKEMISSIVEWITHDIFFUSE: boolean;
  39552. REFLECTIONFRESNELFROMSPECULAR: boolean;
  39553. LIGHTMAP: boolean;
  39554. LIGHTMAPDIRECTUV: number;
  39555. OBJECTSPACE_NORMALMAP: boolean;
  39556. USELIGHTMAPASSHADOWMAP: boolean;
  39557. REFLECTIONMAP_3D: boolean;
  39558. REFLECTIONMAP_SPHERICAL: boolean;
  39559. REFLECTIONMAP_PLANAR: boolean;
  39560. REFLECTIONMAP_CUBIC: boolean;
  39561. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  39562. REFLECTIONMAP_PROJECTION: boolean;
  39563. REFLECTIONMAP_SKYBOX: boolean;
  39564. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  39565. REFLECTIONMAP_EXPLICIT: boolean;
  39566. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  39567. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  39568. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  39569. INVERTCUBICMAP: boolean;
  39570. LOGARITHMICDEPTH: boolean;
  39571. REFRACTION: boolean;
  39572. REFRACTIONMAP_3D: boolean;
  39573. REFLECTIONOVERALPHA: boolean;
  39574. TWOSIDEDLIGHTING: boolean;
  39575. SHADOWFLOAT: boolean;
  39576. MORPHTARGETS: boolean;
  39577. MORPHTARGETS_NORMAL: boolean;
  39578. MORPHTARGETS_TANGENT: boolean;
  39579. NUM_MORPH_INFLUENCERS: number;
  39580. NONUNIFORMSCALING: boolean;
  39581. PREMULTIPLYALPHA: boolean;
  39582. IMAGEPROCESSING: boolean;
  39583. VIGNETTE: boolean;
  39584. VIGNETTEBLENDMODEMULTIPLY: boolean;
  39585. VIGNETTEBLENDMODEOPAQUE: boolean;
  39586. TONEMAPPING: boolean;
  39587. TONEMAPPING_ACES: boolean;
  39588. CONTRAST: boolean;
  39589. COLORCURVES: boolean;
  39590. COLORGRADING: boolean;
  39591. COLORGRADING3D: boolean;
  39592. SAMPLER3DGREENDEPTH: boolean;
  39593. SAMPLER3DBGRMAP: boolean;
  39594. IMAGEPROCESSINGPOSTPROCESS: boolean;
  39595. MULTIVIEW: boolean;
  39596. /**
  39597. * If the reflection texture on this material is in linear color space
  39598. * @hidden
  39599. */
  39600. IS_REFLECTION_LINEAR: boolean;
  39601. /**
  39602. * If the refraction texture on this material is in linear color space
  39603. * @hidden
  39604. */
  39605. IS_REFRACTION_LINEAR: boolean;
  39606. EXPOSURE: boolean;
  39607. constructor();
  39608. setReflectionMode(modeToEnable: string): void;
  39609. }
  39610. /**
  39611. * This is the default material used in Babylon. It is the best trade off between quality
  39612. * and performances.
  39613. * @see http://doc.babylonjs.com/babylon101/materials
  39614. */
  39615. export class StandardMaterial extends PushMaterial {
  39616. private _diffuseTexture;
  39617. /**
  39618. * The basic texture of the material as viewed under a light.
  39619. */
  39620. diffuseTexture: Nullable<BaseTexture>;
  39621. private _ambientTexture;
  39622. /**
  39623. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  39624. */
  39625. ambientTexture: Nullable<BaseTexture>;
  39626. private _opacityTexture;
  39627. /**
  39628. * Define the transparency of the material from a texture.
  39629. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  39630. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  39631. */
  39632. opacityTexture: Nullable<BaseTexture>;
  39633. private _reflectionTexture;
  39634. /**
  39635. * Define the texture used to display the reflection.
  39636. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39637. */
  39638. reflectionTexture: Nullable<BaseTexture>;
  39639. private _emissiveTexture;
  39640. /**
  39641. * Define texture of the material as if self lit.
  39642. * This will be mixed in the final result even in the absence of light.
  39643. */
  39644. emissiveTexture: Nullable<BaseTexture>;
  39645. private _specularTexture;
  39646. /**
  39647. * Define how the color and intensity of the highlight given by the light in the material.
  39648. */
  39649. specularTexture: Nullable<BaseTexture>;
  39650. private _bumpTexture;
  39651. /**
  39652. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  39653. * 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.
  39654. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  39655. */
  39656. bumpTexture: Nullable<BaseTexture>;
  39657. private _lightmapTexture;
  39658. /**
  39659. * Complex lighting can be computationally expensive to compute at runtime.
  39660. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  39661. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  39662. */
  39663. lightmapTexture: Nullable<BaseTexture>;
  39664. private _refractionTexture;
  39665. /**
  39666. * Define the texture used to display the refraction.
  39667. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39668. */
  39669. refractionTexture: Nullable<BaseTexture>;
  39670. /**
  39671. * The color of the material lit by the environmental background lighting.
  39672. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  39673. */
  39674. ambientColor: Color3;
  39675. /**
  39676. * The basic color of the material as viewed under a light.
  39677. */
  39678. diffuseColor: Color3;
  39679. /**
  39680. * Define how the color and intensity of the highlight given by the light in the material.
  39681. */
  39682. specularColor: Color3;
  39683. /**
  39684. * Define the color of the material as if self lit.
  39685. * This will be mixed in the final result even in the absence of light.
  39686. */
  39687. emissiveColor: Color3;
  39688. /**
  39689. * Defines how sharp are the highlights in the material.
  39690. * The bigger the value the sharper giving a more glossy feeling to the result.
  39691. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  39692. */
  39693. specularPower: number;
  39694. private _useAlphaFromDiffuseTexture;
  39695. /**
  39696. * Does the transparency come from the diffuse texture alpha channel.
  39697. */
  39698. useAlphaFromDiffuseTexture: boolean;
  39699. private _useEmissiveAsIllumination;
  39700. /**
  39701. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  39702. */
  39703. useEmissiveAsIllumination: boolean;
  39704. private _linkEmissiveWithDiffuse;
  39705. /**
  39706. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  39707. * the emissive level when the final color is close to one.
  39708. */
  39709. linkEmissiveWithDiffuse: boolean;
  39710. private _useSpecularOverAlpha;
  39711. /**
  39712. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  39713. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  39714. */
  39715. useSpecularOverAlpha: boolean;
  39716. private _useReflectionOverAlpha;
  39717. /**
  39718. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  39719. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  39720. */
  39721. useReflectionOverAlpha: boolean;
  39722. private _disableLighting;
  39723. /**
  39724. * Does lights from the scene impacts this material.
  39725. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  39726. */
  39727. disableLighting: boolean;
  39728. private _useObjectSpaceNormalMap;
  39729. /**
  39730. * Allows using an object space normal map (instead of tangent space).
  39731. */
  39732. useObjectSpaceNormalMap: boolean;
  39733. private _useParallax;
  39734. /**
  39735. * Is parallax enabled or not.
  39736. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  39737. */
  39738. useParallax: boolean;
  39739. private _useParallaxOcclusion;
  39740. /**
  39741. * Is parallax occlusion enabled or not.
  39742. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  39743. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  39744. */
  39745. useParallaxOcclusion: boolean;
  39746. /**
  39747. * 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.
  39748. */
  39749. parallaxScaleBias: number;
  39750. private _roughness;
  39751. /**
  39752. * Helps to define how blurry the reflections should appears in the material.
  39753. */
  39754. roughness: number;
  39755. /**
  39756. * In case of refraction, define the value of the indice of refraction.
  39757. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39758. */
  39759. indexOfRefraction: number;
  39760. /**
  39761. * Invert the refraction texture alongside the y axis.
  39762. * It can be useful with procedural textures or probe for instance.
  39763. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39764. */
  39765. invertRefractionY: boolean;
  39766. /**
  39767. * Defines the alpha limits in alpha test mode.
  39768. */
  39769. alphaCutOff: number;
  39770. private _useLightmapAsShadowmap;
  39771. /**
  39772. * In case of light mapping, define whether the map contains light or shadow informations.
  39773. */
  39774. useLightmapAsShadowmap: boolean;
  39775. private _diffuseFresnelParameters;
  39776. /**
  39777. * Define the diffuse fresnel parameters of the material.
  39778. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39779. */
  39780. diffuseFresnelParameters: FresnelParameters;
  39781. private _opacityFresnelParameters;
  39782. /**
  39783. * Define the opacity fresnel parameters of the material.
  39784. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39785. */
  39786. opacityFresnelParameters: FresnelParameters;
  39787. private _reflectionFresnelParameters;
  39788. /**
  39789. * Define the reflection fresnel parameters of the material.
  39790. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39791. */
  39792. reflectionFresnelParameters: FresnelParameters;
  39793. private _refractionFresnelParameters;
  39794. /**
  39795. * Define the refraction fresnel parameters of the material.
  39796. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39797. */
  39798. refractionFresnelParameters: FresnelParameters;
  39799. private _emissiveFresnelParameters;
  39800. /**
  39801. * Define the emissive fresnel parameters of the material.
  39802. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39803. */
  39804. emissiveFresnelParameters: FresnelParameters;
  39805. private _useReflectionFresnelFromSpecular;
  39806. /**
  39807. * If true automatically deducts the fresnels values from the material specularity.
  39808. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39809. */
  39810. useReflectionFresnelFromSpecular: boolean;
  39811. private _useGlossinessFromSpecularMapAlpha;
  39812. /**
  39813. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  39814. */
  39815. useGlossinessFromSpecularMapAlpha: boolean;
  39816. private _maxSimultaneousLights;
  39817. /**
  39818. * Defines the maximum number of lights that can be used in the material
  39819. */
  39820. maxSimultaneousLights: number;
  39821. private _invertNormalMapX;
  39822. /**
  39823. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  39824. */
  39825. invertNormalMapX: boolean;
  39826. private _invertNormalMapY;
  39827. /**
  39828. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  39829. */
  39830. invertNormalMapY: boolean;
  39831. private _twoSidedLighting;
  39832. /**
  39833. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  39834. */
  39835. twoSidedLighting: boolean;
  39836. /**
  39837. * Default configuration related to image processing available in the standard Material.
  39838. */
  39839. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  39840. /**
  39841. * Gets the image processing configuration used either in this material.
  39842. */
  39843. /**
  39844. * Sets the Default image processing configuration used either in the this material.
  39845. *
  39846. * If sets to null, the scene one is in use.
  39847. */
  39848. imageProcessingConfiguration: ImageProcessingConfiguration;
  39849. /**
  39850. * Keep track of the image processing observer to allow dispose and replace.
  39851. */
  39852. private _imageProcessingObserver;
  39853. /**
  39854. * Attaches a new image processing configuration to the Standard Material.
  39855. * @param configuration
  39856. */
  39857. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  39858. /**
  39859. * Gets wether the color curves effect is enabled.
  39860. */
  39861. /**
  39862. * Sets wether the color curves effect is enabled.
  39863. */
  39864. cameraColorCurvesEnabled: boolean;
  39865. /**
  39866. * Gets wether the color grading effect is enabled.
  39867. */
  39868. /**
  39869. * Gets wether the color grading effect is enabled.
  39870. */
  39871. cameraColorGradingEnabled: boolean;
  39872. /**
  39873. * Gets wether tonemapping is enabled or not.
  39874. */
  39875. /**
  39876. * Sets wether tonemapping is enabled or not
  39877. */
  39878. cameraToneMappingEnabled: boolean;
  39879. /**
  39880. * The camera exposure used on this material.
  39881. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  39882. * This corresponds to a photographic exposure.
  39883. */
  39884. /**
  39885. * The camera exposure used on this material.
  39886. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  39887. * This corresponds to a photographic exposure.
  39888. */
  39889. cameraExposure: number;
  39890. /**
  39891. * Gets The camera contrast used on this material.
  39892. */
  39893. /**
  39894. * Sets The camera contrast used on this material.
  39895. */
  39896. cameraContrast: number;
  39897. /**
  39898. * Gets the Color Grading 2D Lookup Texture.
  39899. */
  39900. /**
  39901. * Sets the Color Grading 2D Lookup Texture.
  39902. */
  39903. cameraColorGradingTexture: Nullable<BaseTexture>;
  39904. /**
  39905. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  39906. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  39907. * 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;
  39908. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  39909. */
  39910. /**
  39911. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  39912. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  39913. * 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;
  39914. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  39915. */
  39916. cameraColorCurves: Nullable<ColorCurves>;
  39917. /**
  39918. * Custom callback helping to override the default shader used in the material.
  39919. */
  39920. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  39921. protected _renderTargets: SmartArray<RenderTargetTexture>;
  39922. protected _worldViewProjectionMatrix: Matrix;
  39923. protected _globalAmbientColor: Color3;
  39924. protected _useLogarithmicDepth: boolean;
  39925. /**
  39926. * Instantiates a new standard material.
  39927. * This is the default material used in Babylon. It is the best trade off between quality
  39928. * and performances.
  39929. * @see http://doc.babylonjs.com/babylon101/materials
  39930. * @param name Define the name of the material in the scene
  39931. * @param scene Define the scene the material belong to
  39932. */
  39933. constructor(name: string, scene: Scene);
  39934. /**
  39935. * Gets a boolean indicating that current material needs to register RTT
  39936. */
  39937. readonly hasRenderTargetTextures: boolean;
  39938. /**
  39939. * Gets the current class name of the material e.g. "StandardMaterial"
  39940. * Mainly use in serialization.
  39941. * @returns the class name
  39942. */
  39943. getClassName(): string;
  39944. /**
  39945. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  39946. * You can try switching to logarithmic depth.
  39947. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  39948. */
  39949. useLogarithmicDepth: boolean;
  39950. /**
  39951. * Specifies if the material will require alpha blending
  39952. * @returns a boolean specifying if alpha blending is needed
  39953. */
  39954. needAlphaBlending(): boolean;
  39955. /**
  39956. * Specifies if this material should be rendered in alpha test mode
  39957. * @returns a boolean specifying if an alpha test is needed.
  39958. */
  39959. needAlphaTesting(): boolean;
  39960. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  39961. /**
  39962. * Get the texture used for alpha test purpose.
  39963. * @returns the diffuse texture in case of the standard material.
  39964. */
  39965. getAlphaTestTexture(): Nullable<BaseTexture>;
  39966. /**
  39967. * Get if the submesh is ready to be used and all its information available.
  39968. * Child classes can use it to update shaders
  39969. * @param mesh defines the mesh to check
  39970. * @param subMesh defines which submesh to check
  39971. * @param useInstances specifies that instances should be used
  39972. * @returns a boolean indicating that the submesh is ready or not
  39973. */
  39974. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  39975. /**
  39976. * Builds the material UBO layouts.
  39977. * Used internally during the effect preparation.
  39978. */
  39979. buildUniformLayout(): void;
  39980. /**
  39981. * Unbinds the material from the mesh
  39982. */
  39983. unbind(): void;
  39984. /**
  39985. * Binds the submesh to this material by preparing the effect and shader to draw
  39986. * @param world defines the world transformation matrix
  39987. * @param mesh defines the mesh containing the submesh
  39988. * @param subMesh defines the submesh to bind the material to
  39989. */
  39990. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  39991. /**
  39992. * Get the list of animatables in the material.
  39993. * @returns the list of animatables object used in the material
  39994. */
  39995. getAnimatables(): IAnimatable[];
  39996. /**
  39997. * Gets the active textures from the material
  39998. * @returns an array of textures
  39999. */
  40000. getActiveTextures(): BaseTexture[];
  40001. /**
  40002. * Specifies if the material uses a texture
  40003. * @param texture defines the texture to check against the material
  40004. * @returns a boolean specifying if the material uses the texture
  40005. */
  40006. hasTexture(texture: BaseTexture): boolean;
  40007. /**
  40008. * Disposes the material
  40009. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  40010. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  40011. */
  40012. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  40013. /**
  40014. * Makes a duplicate of the material, and gives it a new name
  40015. * @param name defines the new name for the duplicated material
  40016. * @returns the cloned material
  40017. */
  40018. clone(name: string): StandardMaterial;
  40019. /**
  40020. * Serializes this material in a JSON representation
  40021. * @returns the serialized material object
  40022. */
  40023. serialize(): any;
  40024. /**
  40025. * Creates a standard material from parsed material data
  40026. * @param source defines the JSON representation of the material
  40027. * @param scene defines the hosting scene
  40028. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  40029. * @returns a new standard material
  40030. */
  40031. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  40032. /**
  40033. * Are diffuse textures enabled in the application.
  40034. */
  40035. static DiffuseTextureEnabled: boolean;
  40036. /**
  40037. * Are ambient textures enabled in the application.
  40038. */
  40039. static AmbientTextureEnabled: boolean;
  40040. /**
  40041. * Are opacity textures enabled in the application.
  40042. */
  40043. static OpacityTextureEnabled: boolean;
  40044. /**
  40045. * Are reflection textures enabled in the application.
  40046. */
  40047. static ReflectionTextureEnabled: boolean;
  40048. /**
  40049. * Are emissive textures enabled in the application.
  40050. */
  40051. static EmissiveTextureEnabled: boolean;
  40052. /**
  40053. * Are specular textures enabled in the application.
  40054. */
  40055. static SpecularTextureEnabled: boolean;
  40056. /**
  40057. * Are bump textures enabled in the application.
  40058. */
  40059. static BumpTextureEnabled: boolean;
  40060. /**
  40061. * Are lightmap textures enabled in the application.
  40062. */
  40063. static LightmapTextureEnabled: boolean;
  40064. /**
  40065. * Are refraction textures enabled in the application.
  40066. */
  40067. static RefractionTextureEnabled: boolean;
  40068. /**
  40069. * Are color grading textures enabled in the application.
  40070. */
  40071. static ColorGradingTextureEnabled: boolean;
  40072. /**
  40073. * Are fresnels enabled in the application.
  40074. */
  40075. static FresnelEnabled: boolean;
  40076. }
  40077. }
  40078. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  40079. import { Scene } from "babylonjs/scene";
  40080. import { Texture } from "babylonjs/Materials/Textures/texture";
  40081. /**
  40082. * A class extending Texture allowing drawing on a texture
  40083. * @see http://doc.babylonjs.com/how_to/dynamictexture
  40084. */
  40085. export class DynamicTexture extends Texture {
  40086. private _generateMipMaps;
  40087. private _canvas;
  40088. private _context;
  40089. private _engine;
  40090. /**
  40091. * Creates a DynamicTexture
  40092. * @param name defines the name of the texture
  40093. * @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
  40094. * @param scene defines the scene where you want the texture
  40095. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  40096. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  40097. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  40098. */
  40099. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  40100. /**
  40101. * Get the current class name of the texture useful for serialization or dynamic coding.
  40102. * @returns "DynamicTexture"
  40103. */
  40104. getClassName(): string;
  40105. /**
  40106. * Gets the current state of canRescale
  40107. */
  40108. readonly canRescale: boolean;
  40109. private _recreate;
  40110. /**
  40111. * Scales the texture
  40112. * @param ratio the scale factor to apply to both width and height
  40113. */
  40114. scale(ratio: number): void;
  40115. /**
  40116. * Resizes the texture
  40117. * @param width the new width
  40118. * @param height the new height
  40119. */
  40120. scaleTo(width: number, height: number): void;
  40121. /**
  40122. * Gets the context of the canvas used by the texture
  40123. * @returns the canvas context of the dynamic texture
  40124. */
  40125. getContext(): CanvasRenderingContext2D;
  40126. /**
  40127. * Clears the texture
  40128. */
  40129. clear(): void;
  40130. /**
  40131. * Updates the texture
  40132. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  40133. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  40134. */
  40135. update(invertY?: boolean, premulAlpha?: boolean): void;
  40136. /**
  40137. * Draws text onto the texture
  40138. * @param text defines the text to be drawn
  40139. * @param x defines the placement of the text from the left
  40140. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  40141. * @param font defines the font to be used with font-style, font-size, font-name
  40142. * @param color defines the color used for the text
  40143. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  40144. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  40145. * @param update defines whether texture is immediately update (default is true)
  40146. */
  40147. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  40148. /**
  40149. * Clones the texture
  40150. * @returns the clone of the texture.
  40151. */
  40152. clone(): DynamicTexture;
  40153. /**
  40154. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  40155. * @returns a serialized dynamic texture object
  40156. */
  40157. serialize(): any;
  40158. /** @hidden */
  40159. _rebuild(): void;
  40160. }
  40161. }
  40162. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  40163. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  40164. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  40165. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  40166. /** @hidden */
  40167. export var imageProcessingPixelShader: {
  40168. name: string;
  40169. shader: string;
  40170. };
  40171. }
  40172. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  40173. import { Nullable } from "babylonjs/types";
  40174. import { Color4 } from "babylonjs/Maths/math";
  40175. import { Camera } from "babylonjs/Cameras/camera";
  40176. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  40177. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  40178. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  40179. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  40180. import { Engine } from "babylonjs/Engines/engine";
  40181. import "babylonjs/Shaders/imageProcessing.fragment";
  40182. import "babylonjs/Shaders/postprocess.vertex";
  40183. /**
  40184. * ImageProcessingPostProcess
  40185. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  40186. */
  40187. export class ImageProcessingPostProcess extends PostProcess {
  40188. /**
  40189. * Default configuration related to image processing available in the PBR Material.
  40190. */
  40191. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  40192. /**
  40193. * Gets the image processing configuration used either in this material.
  40194. */
  40195. /**
  40196. * Sets the Default image processing configuration used either in the this material.
  40197. *
  40198. * If sets to null, the scene one is in use.
  40199. */
  40200. imageProcessingConfiguration: ImageProcessingConfiguration;
  40201. /**
  40202. * Keep track of the image processing observer to allow dispose and replace.
  40203. */
  40204. private _imageProcessingObserver;
  40205. /**
  40206. * Attaches a new image processing configuration to the PBR Material.
  40207. * @param configuration
  40208. */
  40209. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  40210. /**
  40211. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  40212. */
  40213. /**
  40214. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  40215. */
  40216. colorCurves: Nullable<ColorCurves>;
  40217. /**
  40218. * Gets wether the color curves effect is enabled.
  40219. */
  40220. /**
  40221. * Sets wether the color curves effect is enabled.
  40222. */
  40223. colorCurvesEnabled: boolean;
  40224. /**
  40225. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  40226. */
  40227. /**
  40228. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  40229. */
  40230. colorGradingTexture: Nullable<BaseTexture>;
  40231. /**
  40232. * Gets wether the color grading effect is enabled.
  40233. */
  40234. /**
  40235. * Gets wether the color grading effect is enabled.
  40236. */
  40237. colorGradingEnabled: boolean;
  40238. /**
  40239. * Gets exposure used in the effect.
  40240. */
  40241. /**
  40242. * Sets exposure used in the effect.
  40243. */
  40244. exposure: number;
  40245. /**
  40246. * Gets wether tonemapping is enabled or not.
  40247. */
  40248. /**
  40249. * Sets wether tonemapping is enabled or not
  40250. */
  40251. toneMappingEnabled: boolean;
  40252. /**
  40253. * Gets the type of tone mapping effect.
  40254. */
  40255. /**
  40256. * Sets the type of tone mapping effect.
  40257. */
  40258. toneMappingType: number;
  40259. /**
  40260. * Gets contrast used in the effect.
  40261. */
  40262. /**
  40263. * Sets contrast used in the effect.
  40264. */
  40265. contrast: number;
  40266. /**
  40267. * Gets Vignette stretch size.
  40268. */
  40269. /**
  40270. * Sets Vignette stretch size.
  40271. */
  40272. vignetteStretch: number;
  40273. /**
  40274. * Gets Vignette centre X Offset.
  40275. */
  40276. /**
  40277. * Sets Vignette centre X Offset.
  40278. */
  40279. vignetteCentreX: number;
  40280. /**
  40281. * Gets Vignette centre Y Offset.
  40282. */
  40283. /**
  40284. * Sets Vignette centre Y Offset.
  40285. */
  40286. vignetteCentreY: number;
  40287. /**
  40288. * Gets Vignette weight or intensity of the vignette effect.
  40289. */
  40290. /**
  40291. * Sets Vignette weight or intensity of the vignette effect.
  40292. */
  40293. vignetteWeight: number;
  40294. /**
  40295. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  40296. * if vignetteEnabled is set to true.
  40297. */
  40298. /**
  40299. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  40300. * if vignetteEnabled is set to true.
  40301. */
  40302. vignetteColor: Color4;
  40303. /**
  40304. * Gets Camera field of view used by the Vignette effect.
  40305. */
  40306. /**
  40307. * Sets Camera field of view used by the Vignette effect.
  40308. */
  40309. vignetteCameraFov: number;
  40310. /**
  40311. * Gets the vignette blend mode allowing different kind of effect.
  40312. */
  40313. /**
  40314. * Sets the vignette blend mode allowing different kind of effect.
  40315. */
  40316. vignetteBlendMode: number;
  40317. /**
  40318. * Gets wether the vignette effect is enabled.
  40319. */
  40320. /**
  40321. * Sets wether the vignette effect is enabled.
  40322. */
  40323. vignetteEnabled: boolean;
  40324. private _fromLinearSpace;
  40325. /**
  40326. * Gets wether the input of the processing is in Gamma or Linear Space.
  40327. */
  40328. /**
  40329. * Sets wether the input of the processing is in Gamma or Linear Space.
  40330. */
  40331. fromLinearSpace: boolean;
  40332. /**
  40333. * Defines cache preventing GC.
  40334. */
  40335. private _defines;
  40336. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  40337. /**
  40338. * "ImageProcessingPostProcess"
  40339. * @returns "ImageProcessingPostProcess"
  40340. */
  40341. getClassName(): string;
  40342. protected _updateParameters(): void;
  40343. dispose(camera?: Camera): void;
  40344. }
  40345. }
  40346. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  40347. import { Scene } from "babylonjs/scene";
  40348. import { Color3 } from "babylonjs/Maths/math";
  40349. import { Mesh } from "babylonjs/Meshes/mesh";
  40350. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  40351. import { Nullable } from "babylonjs/types";
  40352. /**
  40353. * Class containing static functions to help procedurally build meshes
  40354. */
  40355. export class GroundBuilder {
  40356. /**
  40357. * Creates a ground mesh
  40358. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  40359. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  40360. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40361. * @param name defines the name of the mesh
  40362. * @param options defines the options used to create the mesh
  40363. * @param scene defines the hosting scene
  40364. * @returns the ground mesh
  40365. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  40366. */
  40367. static CreateGround(name: string, options: {
  40368. width?: number;
  40369. height?: number;
  40370. subdivisions?: number;
  40371. subdivisionsX?: number;
  40372. subdivisionsY?: number;
  40373. updatable?: boolean;
  40374. }, scene: any): Mesh;
  40375. /**
  40376. * Creates a tiled ground mesh
  40377. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  40378. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  40379. * * 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
  40380. * * 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
  40381. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40382. * @param name defines the name of the mesh
  40383. * @param options defines the options used to create the mesh
  40384. * @param scene defines the hosting scene
  40385. * @returns the tiled ground mesh
  40386. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  40387. */
  40388. static CreateTiledGround(name: string, options: {
  40389. xmin: number;
  40390. zmin: number;
  40391. xmax: number;
  40392. zmax: number;
  40393. subdivisions?: {
  40394. w: number;
  40395. h: number;
  40396. };
  40397. precision?: {
  40398. w: number;
  40399. h: number;
  40400. };
  40401. updatable?: boolean;
  40402. }, scene?: Nullable<Scene>): Mesh;
  40403. /**
  40404. * Creates a ground mesh from a height map
  40405. * * The parameter `url` sets the URL of the height map image resource.
  40406. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  40407. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  40408. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  40409. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  40410. * * 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.
  40411. * * 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).
  40412. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  40413. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40414. * @param name defines the name of the mesh
  40415. * @param url defines the url to the height map
  40416. * @param options defines the options used to create the mesh
  40417. * @param scene defines the hosting scene
  40418. * @returns the ground mesh
  40419. * @see https://doc.babylonjs.com/babylon101/height_map
  40420. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  40421. */
  40422. static CreateGroundFromHeightMap(name: string, url: string, options: {
  40423. width?: number;
  40424. height?: number;
  40425. subdivisions?: number;
  40426. minHeight?: number;
  40427. maxHeight?: number;
  40428. colorFilter?: Color3;
  40429. alphaFilter?: number;
  40430. updatable?: boolean;
  40431. onReady?: (mesh: GroundMesh) => void;
  40432. }, scene?: Nullable<Scene>): GroundMesh;
  40433. }
  40434. }
  40435. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  40436. import { Vector4 } from "babylonjs/Maths/math";
  40437. import { Mesh } from "babylonjs/Meshes/mesh";
  40438. /**
  40439. * Class containing static functions to help procedurally build meshes
  40440. */
  40441. export class TorusBuilder {
  40442. /**
  40443. * Creates a torus mesh
  40444. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  40445. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  40446. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  40447. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40448. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  40449. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40450. * @param name defines the name of the mesh
  40451. * @param options defines the options used to create the mesh
  40452. * @param scene defines the hosting scene
  40453. * @returns the torus mesh
  40454. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  40455. */
  40456. static CreateTorus(name: string, options: {
  40457. diameter?: number;
  40458. thickness?: number;
  40459. tessellation?: number;
  40460. updatable?: boolean;
  40461. sideOrientation?: number;
  40462. frontUVs?: Vector4;
  40463. backUVs?: Vector4;
  40464. }, scene: any): Mesh;
  40465. }
  40466. }
  40467. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  40468. import { Color4, Vector4 } from "babylonjs/Maths/math";
  40469. import { Mesh } from "babylonjs/Meshes/mesh";
  40470. /**
  40471. * Class containing static functions to help procedurally build meshes
  40472. */
  40473. export class CylinderBuilder {
  40474. /**
  40475. * Creates a cylinder or a cone mesh
  40476. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  40477. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  40478. * * 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.
  40479. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  40480. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  40481. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  40482. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  40483. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  40484. * * 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).
  40485. * * 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
  40486. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  40487. * * 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
  40488. * * 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.
  40489. * * If `enclose` is false, a ring surface is one element.
  40490. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  40491. * * 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
  40492. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40493. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  40494. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40495. * @param name defines the name of the mesh
  40496. * @param options defines the options used to create the mesh
  40497. * @param scene defines the hosting scene
  40498. * @returns the cylinder mesh
  40499. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  40500. */
  40501. static CreateCylinder(name: string, options: {
  40502. height?: number;
  40503. diameterTop?: number;
  40504. diameterBottom?: number;
  40505. diameter?: number;
  40506. tessellation?: number;
  40507. subdivisions?: number;
  40508. arc?: number;
  40509. faceColors?: Color4[];
  40510. faceUV?: Vector4[];
  40511. updatable?: boolean;
  40512. hasRings?: boolean;
  40513. enclose?: boolean;
  40514. sideOrientation?: number;
  40515. frontUVs?: Vector4;
  40516. backUVs?: Vector4;
  40517. }, scene: any): Mesh;
  40518. }
  40519. }
  40520. declare module "babylonjs/Gamepads/gamepadManager" {
  40521. import { Observable } from "babylonjs/Misc/observable";
  40522. import { Nullable } from "babylonjs/types";
  40523. import { Scene } from "babylonjs/scene";
  40524. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  40525. /**
  40526. * Manager for handling gamepads
  40527. */
  40528. export class GamepadManager {
  40529. private _scene?;
  40530. private _babylonGamepads;
  40531. private _oneGamepadConnected;
  40532. /** @hidden */
  40533. _isMonitoring: boolean;
  40534. private _gamepadEventSupported;
  40535. private _gamepadSupport;
  40536. /**
  40537. * observable to be triggered when the gamepad controller has been connected
  40538. */
  40539. onGamepadConnectedObservable: Observable<Gamepad>;
  40540. /**
  40541. * observable to be triggered when the gamepad controller has been disconnected
  40542. */
  40543. onGamepadDisconnectedObservable: Observable<Gamepad>;
  40544. private _onGamepadConnectedEvent;
  40545. private _onGamepadDisconnectedEvent;
  40546. /**
  40547. * Initializes the gamepad manager
  40548. * @param _scene BabylonJS scene
  40549. */
  40550. constructor(_scene?: Scene | undefined);
  40551. /**
  40552. * The gamepads in the game pad manager
  40553. */
  40554. readonly gamepads: Gamepad[];
  40555. /**
  40556. * Get the gamepad controllers based on type
  40557. * @param type The type of gamepad controller
  40558. * @returns Nullable gamepad
  40559. */
  40560. getGamepadByType(type?: number): Nullable<Gamepad>;
  40561. /**
  40562. * Disposes the gamepad manager
  40563. */
  40564. dispose(): void;
  40565. private _addNewGamepad;
  40566. private _startMonitoringGamepads;
  40567. private _stopMonitoringGamepads;
  40568. /** @hidden */
  40569. _checkGamepadsStatus(): void;
  40570. private _updateGamepadObjects;
  40571. }
  40572. }
  40573. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  40574. import { Nullable } from "babylonjs/types";
  40575. import { Scene } from "babylonjs/scene";
  40576. import { ISceneComponent } from "babylonjs/sceneComponent";
  40577. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  40578. module "babylonjs/scene" {
  40579. interface Scene {
  40580. /** @hidden */
  40581. _gamepadManager: Nullable<GamepadManager>;
  40582. /**
  40583. * Gets the gamepad manager associated with the scene
  40584. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  40585. */
  40586. gamepadManager: GamepadManager;
  40587. }
  40588. }
  40589. module "babylonjs/Cameras/freeCameraInputsManager" {
  40590. /**
  40591. * Interface representing a free camera inputs manager
  40592. */
  40593. interface FreeCameraInputsManager {
  40594. /**
  40595. * Adds gamepad input support to the FreeCameraInputsManager.
  40596. * @returns the FreeCameraInputsManager
  40597. */
  40598. addGamepad(): FreeCameraInputsManager;
  40599. }
  40600. }
  40601. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  40602. /**
  40603. * Interface representing an arc rotate camera inputs manager
  40604. */
  40605. interface ArcRotateCameraInputsManager {
  40606. /**
  40607. * Adds gamepad input support to the ArcRotateCamera InputManager.
  40608. * @returns the camera inputs manager
  40609. */
  40610. addGamepad(): ArcRotateCameraInputsManager;
  40611. }
  40612. }
  40613. /**
  40614. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  40615. */
  40616. export class GamepadSystemSceneComponent implements ISceneComponent {
  40617. /**
  40618. * The component name helpfull to identify the component in the list of scene components.
  40619. */
  40620. readonly name: string;
  40621. /**
  40622. * The scene the component belongs to.
  40623. */
  40624. scene: Scene;
  40625. /**
  40626. * Creates a new instance of the component for the given scene
  40627. * @param scene Defines the scene to register the component in
  40628. */
  40629. constructor(scene: Scene);
  40630. /**
  40631. * Registers the component in a given scene
  40632. */
  40633. register(): void;
  40634. /**
  40635. * Rebuilds the elements related to this component in case of
  40636. * context lost for instance.
  40637. */
  40638. rebuild(): void;
  40639. /**
  40640. * Disposes the component and the associated ressources
  40641. */
  40642. dispose(): void;
  40643. private _beforeCameraUpdate;
  40644. }
  40645. }
  40646. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  40647. import { Observable } from "babylonjs/Misc/observable";
  40648. import { Nullable } from "babylonjs/types";
  40649. import { Camera } from "babylonjs/Cameras/camera";
  40650. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  40651. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  40652. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  40653. import { Scene } from "babylonjs/scene";
  40654. import { Vector3, Color3 } from "babylonjs/Maths/math";
  40655. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  40656. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40657. import { Mesh } from "babylonjs/Meshes/mesh";
  40658. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  40659. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  40660. import "babylonjs/Meshes/Builders/groundBuilder";
  40661. import "babylonjs/Meshes/Builders/torusBuilder";
  40662. import "babylonjs/Meshes/Builders/cylinderBuilder";
  40663. import "babylonjs/Gamepads/gamepadSceneComponent";
  40664. import "babylonjs/Animations/animatable";
  40665. /**
  40666. * Options to modify the vr teleportation behavior.
  40667. */
  40668. export interface VRTeleportationOptions {
  40669. /**
  40670. * The name of the mesh which should be used as the teleportation floor. (default: null)
  40671. */
  40672. floorMeshName?: string;
  40673. /**
  40674. * A list of meshes to be used as the teleportation floor. (default: empty)
  40675. */
  40676. floorMeshes?: Mesh[];
  40677. }
  40678. /**
  40679. * Options to modify the vr experience helper's behavior.
  40680. */
  40681. export interface VRExperienceHelperOptions extends WebVROptions {
  40682. /**
  40683. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  40684. */
  40685. createDeviceOrientationCamera?: boolean;
  40686. /**
  40687. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  40688. */
  40689. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  40690. /**
  40691. * Uses the main button on the controller to toggle the laser casted. (default: true)
  40692. */
  40693. laserToggle?: boolean;
  40694. /**
  40695. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  40696. */
  40697. floorMeshes?: Mesh[];
  40698. /**
  40699. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  40700. */
  40701. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  40702. }
  40703. /**
  40704. * Event containing information after VR has been entered
  40705. */
  40706. export class OnAfterEnteringVRObservableEvent {
  40707. /**
  40708. * If entering vr was successful
  40709. */
  40710. success: boolean;
  40711. }
  40712. /**
  40713. * Helps to quickly add VR support to an existing scene.
  40714. * See http://doc.babylonjs.com/how_to/webvr_helper
  40715. */
  40716. export class VRExperienceHelper {
  40717. /** Options to modify the vr experience helper's behavior. */
  40718. webVROptions: VRExperienceHelperOptions;
  40719. private _scene;
  40720. private _position;
  40721. private _btnVR;
  40722. private _btnVRDisplayed;
  40723. private _webVRsupported;
  40724. private _webVRready;
  40725. private _webVRrequesting;
  40726. private _webVRpresenting;
  40727. private _hasEnteredVR;
  40728. private _fullscreenVRpresenting;
  40729. private _canvas;
  40730. private _webVRCamera;
  40731. private _vrDeviceOrientationCamera;
  40732. private _deviceOrientationCamera;
  40733. private _existingCamera;
  40734. private _onKeyDown;
  40735. private _onVrDisplayPresentChange;
  40736. private _onVRDisplayChanged;
  40737. private _onVRRequestPresentStart;
  40738. private _onVRRequestPresentComplete;
  40739. /**
  40740. * Observable raised right before entering VR.
  40741. */
  40742. onEnteringVRObservable: Observable<VRExperienceHelper>;
  40743. /**
  40744. * Observable raised when entering VR has completed.
  40745. */
  40746. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  40747. /**
  40748. * Observable raised when exiting VR.
  40749. */
  40750. onExitingVRObservable: Observable<VRExperienceHelper>;
  40751. /**
  40752. * Observable raised when controller mesh is loaded.
  40753. */
  40754. onControllerMeshLoadedObservable: Observable<WebVRController>;
  40755. /** Return this.onEnteringVRObservable
  40756. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  40757. */
  40758. readonly onEnteringVR: Observable<VRExperienceHelper>;
  40759. /** Return this.onExitingVRObservable
  40760. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  40761. */
  40762. readonly onExitingVR: Observable<VRExperienceHelper>;
  40763. /** Return this.onControllerMeshLoadedObservable
  40764. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  40765. */
  40766. readonly onControllerMeshLoaded: Observable<WebVRController>;
  40767. private _rayLength;
  40768. private _useCustomVRButton;
  40769. private _teleportationRequested;
  40770. private _teleportActive;
  40771. private _floorMeshName;
  40772. private _floorMeshesCollection;
  40773. private _rotationAllowed;
  40774. private _teleportBackwardsVector;
  40775. private _teleportationTarget;
  40776. private _isDefaultTeleportationTarget;
  40777. private _postProcessMove;
  40778. private _teleportationFillColor;
  40779. private _teleportationBorderColor;
  40780. private _rotationAngle;
  40781. private _haloCenter;
  40782. private _cameraGazer;
  40783. private _padSensibilityUp;
  40784. private _padSensibilityDown;
  40785. private _leftController;
  40786. private _rightController;
  40787. /**
  40788. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  40789. */
  40790. onNewMeshSelected: Observable<AbstractMesh>;
  40791. /**
  40792. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  40793. */
  40794. onNewMeshPicked: Observable<PickingInfo>;
  40795. private _circleEase;
  40796. /**
  40797. * Observable raised before camera teleportation
  40798. */
  40799. onBeforeCameraTeleport: Observable<Vector3>;
  40800. /**
  40801. * Observable raised after camera teleportation
  40802. */
  40803. onAfterCameraTeleport: Observable<Vector3>;
  40804. /**
  40805. * Observable raised when current selected mesh gets unselected
  40806. */
  40807. onSelectedMeshUnselected: Observable<AbstractMesh>;
  40808. private _raySelectionPredicate;
  40809. /**
  40810. * To be optionaly changed by user to define custom ray selection
  40811. */
  40812. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  40813. /**
  40814. * To be optionaly changed by user to define custom selection logic (after ray selection)
  40815. */
  40816. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  40817. /**
  40818. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  40819. */
  40820. teleportationEnabled: boolean;
  40821. private _defaultHeight;
  40822. private _teleportationInitialized;
  40823. private _interactionsEnabled;
  40824. private _interactionsRequested;
  40825. private _displayGaze;
  40826. private _displayLaserPointer;
  40827. /**
  40828. * The mesh used to display where the user is going to teleport.
  40829. */
  40830. /**
  40831. * Sets the mesh to be used to display where the user is going to teleport.
  40832. */
  40833. teleportationTarget: Mesh;
  40834. /**
  40835. * 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
  40836. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  40837. * See http://doc.babylonjs.com/resources/baking_transformations
  40838. */
  40839. gazeTrackerMesh: Mesh;
  40840. /**
  40841. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  40842. */
  40843. updateGazeTrackerScale: boolean;
  40844. /**
  40845. * If the gaze trackers color should be updated when selecting meshes
  40846. */
  40847. updateGazeTrackerColor: boolean;
  40848. /**
  40849. * The gaze tracking mesh corresponding to the left controller
  40850. */
  40851. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  40852. /**
  40853. * The gaze tracking mesh corresponding to the right controller
  40854. */
  40855. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  40856. /**
  40857. * If the ray of the gaze should be displayed.
  40858. */
  40859. /**
  40860. * Sets if the ray of the gaze should be displayed.
  40861. */
  40862. displayGaze: boolean;
  40863. /**
  40864. * If the ray of the LaserPointer should be displayed.
  40865. */
  40866. /**
  40867. * Sets if the ray of the LaserPointer should be displayed.
  40868. */
  40869. displayLaserPointer: boolean;
  40870. /**
  40871. * The deviceOrientationCamera used as the camera when not in VR.
  40872. */
  40873. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  40874. /**
  40875. * Based on the current WebVR support, returns the current VR camera used.
  40876. */
  40877. readonly currentVRCamera: Nullable<Camera>;
  40878. /**
  40879. * The webVRCamera which is used when in VR.
  40880. */
  40881. readonly webVRCamera: WebVRFreeCamera;
  40882. /**
  40883. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  40884. */
  40885. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  40886. private readonly _teleportationRequestInitiated;
  40887. /**
  40888. * Defines wether or not Pointer lock should be requested when switching to
  40889. * full screen.
  40890. */
  40891. requestPointerLockOnFullScreen: boolean;
  40892. /**
  40893. * Instantiates a VRExperienceHelper.
  40894. * Helps to quickly add VR support to an existing scene.
  40895. * @param scene The scene the VRExperienceHelper belongs to.
  40896. * @param webVROptions Options to modify the vr experience helper's behavior.
  40897. */
  40898. constructor(scene: Scene,
  40899. /** Options to modify the vr experience helper's behavior. */
  40900. webVROptions?: VRExperienceHelperOptions);
  40901. private _onDefaultMeshLoaded;
  40902. private _onResize;
  40903. private _onFullscreenChange;
  40904. /**
  40905. * Gets a value indicating if we are currently in VR mode.
  40906. */
  40907. readonly isInVRMode: boolean;
  40908. private onVrDisplayPresentChange;
  40909. private onVRDisplayChanged;
  40910. private moveButtonToBottomRight;
  40911. private displayVRButton;
  40912. private updateButtonVisibility;
  40913. private _cachedAngularSensibility;
  40914. /**
  40915. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  40916. * Otherwise, will use the fullscreen API.
  40917. */
  40918. enterVR(): void;
  40919. /**
  40920. * Attempt to exit VR, or fullscreen.
  40921. */
  40922. exitVR(): void;
  40923. /**
  40924. * The position of the vr experience helper.
  40925. */
  40926. /**
  40927. * Sets the position of the vr experience helper.
  40928. */
  40929. position: Vector3;
  40930. /**
  40931. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  40932. */
  40933. enableInteractions(): void;
  40934. private readonly _noControllerIsActive;
  40935. private beforeRender;
  40936. private _isTeleportationFloor;
  40937. /**
  40938. * Adds a floor mesh to be used for teleportation.
  40939. * @param floorMesh the mesh to be used for teleportation.
  40940. */
  40941. addFloorMesh(floorMesh: Mesh): void;
  40942. /**
  40943. * Removes a floor mesh from being used for teleportation.
  40944. * @param floorMesh the mesh to be removed.
  40945. */
  40946. removeFloorMesh(floorMesh: Mesh): void;
  40947. /**
  40948. * Enables interactions and teleportation using the VR controllers and gaze.
  40949. * @param vrTeleportationOptions options to modify teleportation behavior.
  40950. */
  40951. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  40952. private _onNewGamepadConnected;
  40953. private _tryEnableInteractionOnController;
  40954. private _onNewGamepadDisconnected;
  40955. private _enableInteractionOnController;
  40956. private _checkTeleportWithRay;
  40957. private _checkRotate;
  40958. private _checkTeleportBackwards;
  40959. private _enableTeleportationOnController;
  40960. private _createTeleportationCircles;
  40961. private _displayTeleportationTarget;
  40962. private _hideTeleportationTarget;
  40963. private _rotateCamera;
  40964. private _moveTeleportationSelectorTo;
  40965. private _workingVector;
  40966. private _workingQuaternion;
  40967. private _workingMatrix;
  40968. /**
  40969. * Teleports the users feet to the desired location
  40970. * @param location The location where the user's feet should be placed
  40971. */
  40972. teleportCamera(location: Vector3): void;
  40973. private _convertNormalToDirectionOfRay;
  40974. private _castRayAndSelectObject;
  40975. private _notifySelectedMeshUnselected;
  40976. /**
  40977. * Sets the color of the laser ray from the vr controllers.
  40978. * @param color new color for the ray.
  40979. */
  40980. changeLaserColor(color: Color3): void;
  40981. /**
  40982. * Sets the color of the ray from the vr headsets gaze.
  40983. * @param color new color for the ray.
  40984. */
  40985. changeGazeColor(color: Color3): void;
  40986. /**
  40987. * Exits VR and disposes of the vr experience helper
  40988. */
  40989. dispose(): void;
  40990. /**
  40991. * Gets the name of the VRExperienceHelper class
  40992. * @returns "VRExperienceHelper"
  40993. */
  40994. getClassName(): string;
  40995. }
  40996. }
  40997. declare module "babylonjs/Cameras/VR/index" {
  40998. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  40999. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  41000. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  41001. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  41002. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  41003. export * from "babylonjs/Cameras/VR/webVRCamera";
  41004. }
  41005. declare module "babylonjs/Cameras/XR/webXRSessionManager" {
  41006. import { Observable } from "babylonjs/Misc/observable";
  41007. import { Nullable } from "babylonjs/types";
  41008. import { IDisposable, Scene } from "babylonjs/scene";
  41009. import { Vector3 } from "babylonjs/Maths/math";
  41010. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  41011. import { Ray } from "babylonjs/Culling/ray";
  41012. /**
  41013. * Manages an XRSession
  41014. * @see https://doc.babylonjs.com/how_to/webxr
  41015. */
  41016. export class WebXRSessionManager implements IDisposable {
  41017. private scene;
  41018. /**
  41019. * Fires every time a new xrFrame arrives which can be used to update the camera
  41020. */
  41021. onXRFrameObservable: Observable<any>;
  41022. /**
  41023. * Fires when the xr session is ended either by the device or manually done
  41024. */
  41025. onXRSessionEnded: Observable<any>;
  41026. /** @hidden */
  41027. _xrSession: XRSession;
  41028. /** @hidden */
  41029. _frameOfReference: XRFrameOfReference;
  41030. /** @hidden */
  41031. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  41032. /** @hidden */
  41033. _currentXRFrame: Nullable<XRFrame>;
  41034. private _xrNavigator;
  41035. private _xrDevice;
  41036. private _tmpMatrix;
  41037. /**
  41038. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  41039. * @param scene The scene which the session should be created for
  41040. */
  41041. constructor(scene: Scene);
  41042. /**
  41043. * Initializes the manager
  41044. * After initialization enterXR can be called to start an XR session
  41045. * @returns Promise which resolves after it is initialized
  41046. */
  41047. initializeAsync(): Promise<void>;
  41048. /**
  41049. * Enters XR with the desired XR session options, this must be done with a user action (eg. button click event)
  41050. * @param sessionCreationOptions xr options to create the session with
  41051. * @param frameOfReferenceType option to configure how the xr pose is expressed
  41052. * @returns Promise which resolves after it enters XR
  41053. */
  41054. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReferenceType: string): Promise<void>;
  41055. /**
  41056. * Stops the xrSession and restores the renderloop
  41057. * @returns Promise which resolves after it exits XR
  41058. */
  41059. exitXRAsync(): Promise<void>;
  41060. /**
  41061. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  41062. * @param ray ray to cast into the environment
  41063. * @returns Promise which resolves with a collision point in the environment if it exists
  41064. */
  41065. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  41066. /**
  41067. * Checks if a session would be supported for the creation options specified
  41068. * @param options creation options to check if they are supported
  41069. * @returns true if supported
  41070. */
  41071. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  41072. /**
  41073. * @hidden
  41074. * Converts the render layer of xrSession to a render target
  41075. * @param session session to create render target for
  41076. * @param scene scene the new render target should be created for
  41077. */
  41078. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene): RenderTargetTexture;
  41079. /**
  41080. * Disposes of the session manager
  41081. */
  41082. dispose(): void;
  41083. }
  41084. }
  41085. declare module "babylonjs/Cameras/XR/webXRCamera" {
  41086. import { Scene } from "babylonjs/scene";
  41087. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  41088. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  41089. /**
  41090. * WebXR Camera which holds the views for the xrSession
  41091. * @see https://doc.babylonjs.com/how_to/webxr
  41092. */
  41093. export class WebXRCamera extends FreeCamera {
  41094. private static _TmpMatrix;
  41095. /**
  41096. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  41097. * @param name the name of the camera
  41098. * @param scene the scene to add the camera to
  41099. */
  41100. constructor(name: string, scene: Scene);
  41101. private _updateNumberOfRigCameras;
  41102. /** @hidden */
  41103. _updateForDualEyeDebugging(pupilDistance?: number): void;
  41104. /**
  41105. * Updates the cameras position from the current pose information of the XR session
  41106. * @param xrSessionManager the session containing pose information
  41107. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  41108. */
  41109. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  41110. }
  41111. }
  41112. declare module "babylonjs/Cameras/XR/webXRExperienceHelper" {
  41113. import { Nullable } from "babylonjs/types";
  41114. import { Observable } from "babylonjs/Misc/observable";
  41115. import { IDisposable, Scene } from "babylonjs/scene";
  41116. import { Quaternion, Vector3 } from "babylonjs/Maths/math";
  41117. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41118. import { Ray } from "babylonjs/Culling/ray";
  41119. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  41120. import { WebXRCamera } from "babylonjs/Cameras/XR/webXRCamera";
  41121. /**
  41122. * States of the webXR experience
  41123. */
  41124. export enum WebXRState {
  41125. /**
  41126. * Transitioning to being in XR mode
  41127. */
  41128. ENTERING_XR = 0,
  41129. /**
  41130. * Transitioning to non XR mode
  41131. */
  41132. EXITING_XR = 1,
  41133. /**
  41134. * In XR mode and presenting
  41135. */
  41136. IN_XR = 2,
  41137. /**
  41138. * Not entered XR mode
  41139. */
  41140. NOT_IN_XR = 3
  41141. }
  41142. /**
  41143. * Helper class used to enable XR
  41144. * @see https://doc.babylonjs.com/how_to/webxr
  41145. */
  41146. export class WebXRExperienceHelper implements IDisposable {
  41147. private scene;
  41148. /**
  41149. * 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
  41150. */
  41151. container: AbstractMesh;
  41152. /**
  41153. * Camera used to render xr content
  41154. */
  41155. camera: WebXRCamera;
  41156. /**
  41157. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  41158. */
  41159. state: WebXRState;
  41160. private _setState;
  41161. private static _TmpVector;
  41162. /**
  41163. * Fires when the state of the experience helper has changed
  41164. */
  41165. onStateChangedObservable: Observable<WebXRState>;
  41166. /** @hidden */
  41167. _sessionManager: WebXRSessionManager;
  41168. private _nonVRCamera;
  41169. private _originalSceneAutoClear;
  41170. private _supported;
  41171. /**
  41172. * Creates the experience helper
  41173. * @param scene the scene to attach the experience helper to
  41174. * @returns a promise for the experience helper
  41175. */
  41176. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  41177. /**
  41178. * Creates a WebXRExperienceHelper
  41179. * @param scene The scene the helper should be created in
  41180. */
  41181. private constructor();
  41182. /**
  41183. * Exits XR mode and returns the scene to its original state
  41184. * @returns promise that resolves after xr mode has exited
  41185. */
  41186. exitXRAsync(): Promise<void>;
  41187. /**
  41188. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  41189. * @param sessionCreationOptions options for the XR session
  41190. * @param frameOfReference frame of reference of the XR session
  41191. * @returns promise that resolves after xr mode has entered
  41192. */
  41193. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReference: string): Promise<void>;
  41194. /**
  41195. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  41196. * @param ray ray to cast into the environment
  41197. * @returns Promise which resolves with a collision point in the environment if it exists
  41198. */
  41199. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  41200. /**
  41201. * Updates the global position of the camera by moving the camera's container
  41202. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  41203. * @param position The desired global position of the camera
  41204. */
  41205. setPositionOfCameraUsingContainer(position: Vector3): void;
  41206. /**
  41207. * Rotates the xr camera by rotating the camera's container around the camera's position
  41208. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  41209. * @param rotation the desired quaternion rotation to apply to the camera
  41210. */
  41211. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  41212. /**
  41213. * Checks if the creation options are supported by the xr session
  41214. * @param options creation options
  41215. * @returns true if supported
  41216. */
  41217. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  41218. /**
  41219. * Disposes of the experience helper
  41220. */
  41221. dispose(): void;
  41222. }
  41223. }
  41224. declare module "babylonjs/Cameras/XR/webXREnterExitUI" {
  41225. import { Nullable } from "babylonjs/types";
  41226. import { Observable } from "babylonjs/Misc/observable";
  41227. import { IDisposable, Scene } from "babylonjs/scene";
  41228. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  41229. /**
  41230. * Button which can be used to enter a different mode of XR
  41231. */
  41232. export class WebXREnterExitUIButton {
  41233. /** button element */
  41234. element: HTMLElement;
  41235. /** XR initialization options for the button */
  41236. initializationOptions: XRSessionCreationOptions;
  41237. /**
  41238. * Creates a WebXREnterExitUIButton
  41239. * @param element button element
  41240. * @param initializationOptions XR initialization options for the button
  41241. */
  41242. constructor(
  41243. /** button element */
  41244. element: HTMLElement,
  41245. /** XR initialization options for the button */
  41246. initializationOptions: XRSessionCreationOptions);
  41247. /**
  41248. * Overwritable function which can be used to update the button's visuals when the state changes
  41249. * @param activeButton the current active button in the UI
  41250. */
  41251. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  41252. }
  41253. /**
  41254. * Options to create the webXR UI
  41255. */
  41256. export class WebXREnterExitUIOptions {
  41257. /**
  41258. * Context to enter xr with
  41259. */
  41260. outputCanvasContext?: Nullable<WebGLRenderingContext>;
  41261. /**
  41262. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  41263. */
  41264. customButtons?: Array<WebXREnterExitUIButton>;
  41265. }
  41266. /**
  41267. * UI to allow the user to enter/exit XR mode
  41268. */
  41269. export class WebXREnterExitUI implements IDisposable {
  41270. private scene;
  41271. private _overlay;
  41272. private _buttons;
  41273. private _activeButton;
  41274. /**
  41275. * Fired every time the active button is changed.
  41276. *
  41277. * When xr is entered via a button that launches xr that button will be the callback parameter
  41278. *
  41279. * When exiting xr the callback parameter will be null)
  41280. */
  41281. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  41282. /**
  41283. * Creates UI to allow the user to enter/exit XR mode
  41284. * @param scene the scene to add the ui to
  41285. * @param helper the xr experience helper to enter/exit xr with
  41286. * @param options options to configure the UI
  41287. * @returns the created ui
  41288. */
  41289. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  41290. private constructor();
  41291. private _updateButtons;
  41292. /**
  41293. * Disposes of the object
  41294. */
  41295. dispose(): void;
  41296. }
  41297. }
  41298. declare module "babylonjs/Cameras/XR/webXRInput" {
  41299. import { IDisposable, Scene } from "babylonjs/scene";
  41300. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41301. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  41302. /**
  41303. * Represents an XR input
  41304. */
  41305. export class WebXRController {
  41306. /**
  41307. * 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
  41308. */
  41309. grip?: AbstractMesh;
  41310. /**
  41311. * Pointer which can be used to select objects or attach a visible laser to
  41312. */
  41313. pointer: AbstractMesh;
  41314. /**
  41315. * Creates the controller
  41316. * @see https://doc.babylonjs.com/how_to/webxr
  41317. * @param scene the scene which the controller should be associated to
  41318. */
  41319. constructor(scene: Scene);
  41320. /**
  41321. * Disposes of the object
  41322. */
  41323. dispose(): void;
  41324. }
  41325. /**
  41326. * XR input used to track XR inputs such as controllers/rays
  41327. */
  41328. export class WebXRInput implements IDisposable {
  41329. private helper;
  41330. /**
  41331. * XR controllers being tracked
  41332. */
  41333. controllers: Array<WebXRController>;
  41334. private _tmpMatrix;
  41335. private _frameObserver;
  41336. /**
  41337. * Initializes the WebXRInput
  41338. * @param helper experience helper which the input should be created for
  41339. */
  41340. constructor(helper: WebXRExperienceHelper);
  41341. /**
  41342. * Disposes of the object
  41343. */
  41344. dispose(): void;
  41345. }
  41346. }
  41347. declare module "babylonjs/Cameras/XR/webXRManagedOutputCanvas" {
  41348. import { Nullable } from "babylonjs/types";
  41349. import { IDisposable } from "babylonjs/scene";
  41350. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  41351. /**
  41352. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  41353. */
  41354. export class WebXRManagedOutputCanvas implements IDisposable {
  41355. private _canvas;
  41356. /**
  41357. * xrpresent context of the canvas which can be used to display/mirror xr content
  41358. */
  41359. canvasContext: Nullable<WebGLRenderingContext>;
  41360. /**
  41361. * Initializes the canvas to be added/removed upon entering/exiting xr
  41362. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  41363. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  41364. */
  41365. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  41366. /**
  41367. * Disposes of the object
  41368. */
  41369. dispose(): void;
  41370. private _setManagedOutputCanvas;
  41371. private _addCanvas;
  41372. private _removeCanvas;
  41373. }
  41374. }
  41375. declare module "babylonjs/Cameras/XR/index" {
  41376. export * from "babylonjs/Cameras/XR/webXRCamera";
  41377. export * from "babylonjs/Cameras/XR/webXREnterExitUI";
  41378. export * from "babylonjs/Cameras/XR/webXRExperienceHelper";
  41379. export * from "babylonjs/Cameras/XR/webXRInput";
  41380. export * from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  41381. export * from "babylonjs/Cameras/XR/webXRSessionManager";
  41382. }
  41383. declare module "babylonjs/Cameras/RigModes/index" {
  41384. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  41385. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  41386. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  41387. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  41388. }
  41389. declare module "babylonjs/Cameras/index" {
  41390. export * from "babylonjs/Cameras/Inputs/index";
  41391. export * from "babylonjs/Cameras/cameraInputsManager";
  41392. export * from "babylonjs/Cameras/camera";
  41393. export * from "babylonjs/Cameras/targetCamera";
  41394. export * from "babylonjs/Cameras/freeCamera";
  41395. export * from "babylonjs/Cameras/freeCameraInputsManager";
  41396. export * from "babylonjs/Cameras/touchCamera";
  41397. export * from "babylonjs/Cameras/arcRotateCamera";
  41398. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  41399. export * from "babylonjs/Cameras/deviceOrientationCamera";
  41400. export * from "babylonjs/Cameras/flyCamera";
  41401. export * from "babylonjs/Cameras/flyCameraInputsManager";
  41402. export * from "babylonjs/Cameras/followCamera";
  41403. export * from "babylonjs/Cameras/gamepadCamera";
  41404. export * from "babylonjs/Cameras/Stereoscopic/index";
  41405. export * from "babylonjs/Cameras/universalCamera";
  41406. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  41407. export * from "babylonjs/Cameras/VR/index";
  41408. export * from "babylonjs/Cameras/XR/index";
  41409. export * from "babylonjs/Cameras/RigModes/index";
  41410. }
  41411. declare module "babylonjs/Collisions/index" {
  41412. export * from "babylonjs/Collisions/collider";
  41413. export * from "babylonjs/Collisions/collisionCoordinator";
  41414. export * from "babylonjs/Collisions/pickingInfo";
  41415. export * from "babylonjs/Collisions/intersectionInfo";
  41416. }
  41417. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  41418. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  41419. import { Vector3, Plane } from "babylonjs/Maths/math";
  41420. import { Ray } from "babylonjs/Culling/ray";
  41421. /**
  41422. * Contains an array of blocks representing the octree
  41423. */
  41424. export interface IOctreeContainer<T> {
  41425. /**
  41426. * Blocks within the octree
  41427. */
  41428. blocks: Array<OctreeBlock<T>>;
  41429. }
  41430. /**
  41431. * Class used to store a cell in an octree
  41432. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41433. */
  41434. export class OctreeBlock<T> {
  41435. /**
  41436. * Gets the content of the current block
  41437. */
  41438. entries: T[];
  41439. /**
  41440. * Gets the list of block children
  41441. */
  41442. blocks: Array<OctreeBlock<T>>;
  41443. private _depth;
  41444. private _maxDepth;
  41445. private _capacity;
  41446. private _minPoint;
  41447. private _maxPoint;
  41448. private _boundingVectors;
  41449. private _creationFunc;
  41450. /**
  41451. * Creates a new block
  41452. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  41453. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  41454. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  41455. * @param depth defines the current depth of this block in the octree
  41456. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  41457. * @param creationFunc defines a callback to call when an element is added to the block
  41458. */
  41459. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  41460. /**
  41461. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  41462. */
  41463. readonly capacity: number;
  41464. /**
  41465. * Gets the minimum vector (in world space) of the block's bounding box
  41466. */
  41467. readonly minPoint: Vector3;
  41468. /**
  41469. * Gets the maximum vector (in world space) of the block's bounding box
  41470. */
  41471. readonly maxPoint: Vector3;
  41472. /**
  41473. * Add a new element to this block
  41474. * @param entry defines the element to add
  41475. */
  41476. addEntry(entry: T): void;
  41477. /**
  41478. * Remove an element from this block
  41479. * @param entry defines the element to remove
  41480. */
  41481. removeEntry(entry: T): void;
  41482. /**
  41483. * Add an array of elements to this block
  41484. * @param entries defines the array of elements to add
  41485. */
  41486. addEntries(entries: T[]): void;
  41487. /**
  41488. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  41489. * @param frustumPlanes defines the frustum planes to test
  41490. * @param selection defines the array to store current content if selection is positive
  41491. * @param allowDuplicate defines if the selection array can contains duplicated entries
  41492. */
  41493. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  41494. /**
  41495. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  41496. * @param sphereCenter defines the bounding sphere center
  41497. * @param sphereRadius defines the bounding sphere radius
  41498. * @param selection defines the array to store current content if selection is positive
  41499. * @param allowDuplicate defines if the selection array can contains duplicated entries
  41500. */
  41501. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  41502. /**
  41503. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  41504. * @param ray defines the ray to test with
  41505. * @param selection defines the array to store current content if selection is positive
  41506. */
  41507. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  41508. /**
  41509. * Subdivide the content into child blocks (this block will then be empty)
  41510. */
  41511. createInnerBlocks(): void;
  41512. /**
  41513. * @hidden
  41514. */
  41515. 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;
  41516. }
  41517. }
  41518. declare module "babylonjs/Culling/Octrees/octree" {
  41519. import { SmartArray } from "babylonjs/Misc/smartArray";
  41520. import { Vector3, Plane } from "babylonjs/Maths/math";
  41521. import { SubMesh } from "babylonjs/Meshes/subMesh";
  41522. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41523. import { Ray } from "babylonjs/Culling/ray";
  41524. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  41525. /**
  41526. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  41527. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41528. */
  41529. export class Octree<T> {
  41530. /** 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.) */
  41531. maxDepth: number;
  41532. /**
  41533. * Blocks within the octree containing objects
  41534. */
  41535. blocks: Array<OctreeBlock<T>>;
  41536. /**
  41537. * Content stored in the octree
  41538. */
  41539. dynamicContent: T[];
  41540. private _maxBlockCapacity;
  41541. private _selectionContent;
  41542. private _creationFunc;
  41543. /**
  41544. * Creates a octree
  41545. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41546. * @param creationFunc function to be used to instatiate the octree
  41547. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  41548. * @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.)
  41549. */
  41550. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  41551. /** 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.) */
  41552. maxDepth?: number);
  41553. /**
  41554. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  41555. * @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);
  41556. * @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);
  41557. * @param entries meshes to be added to the octree blocks
  41558. */
  41559. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  41560. /**
  41561. * Adds a mesh to the octree
  41562. * @param entry Mesh to add to the octree
  41563. */
  41564. addMesh(entry: T): void;
  41565. /**
  41566. * Remove an element from the octree
  41567. * @param entry defines the element to remove
  41568. */
  41569. removeMesh(entry: T): void;
  41570. /**
  41571. * Selects an array of meshes within the frustum
  41572. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  41573. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  41574. * @returns array of meshes within the frustum
  41575. */
  41576. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  41577. /**
  41578. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  41579. * @param sphereCenter defines the bounding sphere center
  41580. * @param sphereRadius defines the bounding sphere radius
  41581. * @param allowDuplicate defines if the selection array can contains duplicated entries
  41582. * @returns an array of objects that intersect the sphere
  41583. */
  41584. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  41585. /**
  41586. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  41587. * @param ray defines the ray to test with
  41588. * @returns array of intersected objects
  41589. */
  41590. intersectsRay(ray: Ray): SmartArray<T>;
  41591. /**
  41592. * Adds a mesh into the octree block if it intersects the block
  41593. */
  41594. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  41595. /**
  41596. * Adds a submesh into the octree block if it intersects the block
  41597. */
  41598. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  41599. }
  41600. }
  41601. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  41602. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  41603. import { Scene } from "babylonjs/scene";
  41604. import { SubMesh } from "babylonjs/Meshes/subMesh";
  41605. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41606. import { Ray } from "babylonjs/Culling/ray";
  41607. import { Octree } from "babylonjs/Culling/Octrees/octree";
  41608. import { Collider } from "babylonjs/Collisions/collider";
  41609. module "babylonjs/scene" {
  41610. interface Scene {
  41611. /**
  41612. * @hidden
  41613. * Backing Filed
  41614. */
  41615. _selectionOctree: Octree<AbstractMesh>;
  41616. /**
  41617. * Gets the octree used to boost mesh selection (picking)
  41618. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41619. */
  41620. selectionOctree: Octree<AbstractMesh>;
  41621. /**
  41622. * Creates or updates the octree used to boost selection (picking)
  41623. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41624. * @param maxCapacity defines the maximum capacity per leaf
  41625. * @param maxDepth defines the maximum depth of the octree
  41626. * @returns an octree of AbstractMesh
  41627. */
  41628. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  41629. }
  41630. }
  41631. module "babylonjs/Meshes/abstractMesh" {
  41632. interface AbstractMesh {
  41633. /**
  41634. * @hidden
  41635. * Backing Field
  41636. */
  41637. _submeshesOctree: Octree<SubMesh>;
  41638. /**
  41639. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  41640. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  41641. * @param maxCapacity defines the maximum size of each block (64 by default)
  41642. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  41643. * @returns the new octree
  41644. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  41645. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41646. */
  41647. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  41648. }
  41649. }
  41650. /**
  41651. * Defines the octree scene component responsible to manage any octrees
  41652. * in a given scene.
  41653. */
  41654. export class OctreeSceneComponent {
  41655. /**
  41656. * The component name helpfull to identify the component in the list of scene components.
  41657. */
  41658. readonly name: string;
  41659. /**
  41660. * The scene the component belongs to.
  41661. */
  41662. scene: Scene;
  41663. /**
  41664. * Indicates if the meshes have been checked to make sure they are isEnabled()
  41665. */
  41666. readonly checksIsEnabled: boolean;
  41667. /**
  41668. * Creates a new instance of the component for the given scene
  41669. * @param scene Defines the scene to register the component in
  41670. */
  41671. constructor(scene: Scene);
  41672. /**
  41673. * Registers the component in a given scene
  41674. */
  41675. register(): void;
  41676. /**
  41677. * Return the list of active meshes
  41678. * @returns the list of active meshes
  41679. */
  41680. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  41681. /**
  41682. * Return the list of active sub meshes
  41683. * @param mesh The mesh to get the candidates sub meshes from
  41684. * @returns the list of active sub meshes
  41685. */
  41686. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  41687. private _tempRay;
  41688. /**
  41689. * Return the list of sub meshes intersecting with a given local ray
  41690. * @param mesh defines the mesh to find the submesh for
  41691. * @param localRay defines the ray in local space
  41692. * @returns the list of intersecting sub meshes
  41693. */
  41694. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  41695. /**
  41696. * Return the list of sub meshes colliding with a collider
  41697. * @param mesh defines the mesh to find the submesh for
  41698. * @param collider defines the collider to evaluate the collision against
  41699. * @returns the list of colliding sub meshes
  41700. */
  41701. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  41702. /**
  41703. * Rebuilds the elements related to this component in case of
  41704. * context lost for instance.
  41705. */
  41706. rebuild(): void;
  41707. /**
  41708. * Disposes the component and the associated ressources.
  41709. */
  41710. dispose(): void;
  41711. }
  41712. }
  41713. declare module "babylonjs/Culling/Octrees/index" {
  41714. export * from "babylonjs/Culling/Octrees/octree";
  41715. export * from "babylonjs/Culling/Octrees/octreeBlock";
  41716. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  41717. }
  41718. declare module "babylonjs/Culling/index" {
  41719. export * from "babylonjs/Culling/boundingBox";
  41720. export * from "babylonjs/Culling/boundingInfo";
  41721. export * from "babylonjs/Culling/boundingSphere";
  41722. export * from "babylonjs/Culling/Octrees/index";
  41723. export * from "babylonjs/Culling/ray";
  41724. }
  41725. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  41726. import { IDisposable, Scene } from "babylonjs/scene";
  41727. import { Nullable } from "babylonjs/types";
  41728. import { Observable } from "babylonjs/Misc/observable";
  41729. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41730. import { HemisphericLight } from "babylonjs/Lights/hemisphericLight";
  41731. /**
  41732. * Renders a layer on top of an existing scene
  41733. */
  41734. export class UtilityLayerRenderer implements IDisposable {
  41735. /** the original scene that will be rendered on top of */
  41736. originalScene: Scene;
  41737. private _pointerCaptures;
  41738. private _lastPointerEvents;
  41739. private static _DefaultUtilityLayer;
  41740. private static _DefaultKeepDepthUtilityLayer;
  41741. private _sharedGizmoLight;
  41742. /**
  41743. * @hidden
  41744. * Light which used by gizmos to get light shading
  41745. */
  41746. _getSharedGizmoLight(): HemisphericLight;
  41747. /**
  41748. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  41749. */
  41750. pickUtilitySceneFirst: boolean;
  41751. /**
  41752. * 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)
  41753. */
  41754. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  41755. /**
  41756. * 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)
  41757. */
  41758. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  41759. /**
  41760. * The scene that is rendered on top of the original scene
  41761. */
  41762. utilityLayerScene: Scene;
  41763. /**
  41764. * If the utility layer should automatically be rendered on top of existing scene
  41765. */
  41766. shouldRender: boolean;
  41767. /**
  41768. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  41769. */
  41770. onlyCheckPointerDownEvents: boolean;
  41771. /**
  41772. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  41773. */
  41774. processAllEvents: boolean;
  41775. /**
  41776. * Observable raised when the pointer move from the utility layer scene to the main scene
  41777. */
  41778. onPointerOutObservable: Observable<number>;
  41779. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  41780. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  41781. private _afterRenderObserver;
  41782. private _sceneDisposeObserver;
  41783. private _originalPointerObserver;
  41784. /**
  41785. * Instantiates a UtilityLayerRenderer
  41786. * @param originalScene the original scene that will be rendered on top of
  41787. * @param handleEvents boolean indicating if the utility layer should handle events
  41788. */
  41789. constructor(
  41790. /** the original scene that will be rendered on top of */
  41791. originalScene: Scene, handleEvents?: boolean);
  41792. private _notifyObservers;
  41793. /**
  41794. * Renders the utility layers scene on top of the original scene
  41795. */
  41796. render(): void;
  41797. /**
  41798. * Disposes of the renderer
  41799. */
  41800. dispose(): void;
  41801. private _updateCamera;
  41802. }
  41803. }
  41804. declare module "babylonjs/Gizmos/gizmo" {
  41805. import { Nullable } from "babylonjs/types";
  41806. import { IDisposable } from "babylonjs/scene";
  41807. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41808. import { Mesh } from "babylonjs/Meshes/mesh";
  41809. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  41810. /**
  41811. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  41812. */
  41813. export class Gizmo implements IDisposable {
  41814. /** The utility layer the gizmo will be added to */
  41815. gizmoLayer: UtilityLayerRenderer;
  41816. /**
  41817. * The root mesh of the gizmo
  41818. */
  41819. _rootMesh: Mesh;
  41820. private _attachedMesh;
  41821. /**
  41822. * Ratio for the scale of the gizmo (Default: 1)
  41823. */
  41824. scaleRatio: number;
  41825. private _tmpMatrix;
  41826. /**
  41827. * If a custom mesh has been set (Default: false)
  41828. */
  41829. protected _customMeshSet: boolean;
  41830. /**
  41831. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  41832. * * When set, interactions will be enabled
  41833. */
  41834. attachedMesh: Nullable<AbstractMesh>;
  41835. /**
  41836. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  41837. * @param mesh The mesh to replace the default mesh of the gizmo
  41838. */
  41839. setCustomMesh(mesh: Mesh): void;
  41840. /**
  41841. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  41842. */
  41843. updateGizmoRotationToMatchAttachedMesh: boolean;
  41844. /**
  41845. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  41846. */
  41847. updateGizmoPositionToMatchAttachedMesh: boolean;
  41848. /**
  41849. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  41850. */
  41851. protected _updateScale: boolean;
  41852. protected _interactionsEnabled: boolean;
  41853. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  41854. private _beforeRenderObserver;
  41855. /**
  41856. * Creates a gizmo
  41857. * @param gizmoLayer The utility layer the gizmo will be added to
  41858. */
  41859. constructor(
  41860. /** The utility layer the gizmo will be added to */
  41861. gizmoLayer?: UtilityLayerRenderer);
  41862. private _tempVector;
  41863. /**
  41864. * @hidden
  41865. * Updates the gizmo to match the attached mesh's position/rotation
  41866. */
  41867. protected _update(): void;
  41868. /**
  41869. * Disposes of the gizmo
  41870. */
  41871. dispose(): void;
  41872. }
  41873. }
  41874. declare module "babylonjs/Gizmos/axisDragGizmo" {
  41875. import { Observable } from "babylonjs/Misc/observable";
  41876. import { Nullable } from "babylonjs/types";
  41877. import { Vector3, Color3 } from "babylonjs/Maths/math";
  41878. import { TransformNode } from "babylonjs/Meshes/transformNode";
  41879. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41880. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  41881. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  41882. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  41883. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  41884. import { Scene } from "babylonjs/scene";
  41885. /**
  41886. * Single axis drag gizmo
  41887. */
  41888. export class AxisDragGizmo extends Gizmo {
  41889. /**
  41890. * Drag behavior responsible for the gizmos dragging interactions
  41891. */
  41892. dragBehavior: PointerDragBehavior;
  41893. private _pointerObserver;
  41894. /**
  41895. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  41896. */
  41897. snapDistance: number;
  41898. /**
  41899. * Event that fires each time the gizmo snaps to a new location.
  41900. * * snapDistance is the the change in distance
  41901. */
  41902. onSnapObservable: Observable<{
  41903. snapDistance: number;
  41904. }>;
  41905. /** @hidden */
  41906. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  41907. /** @hidden */
  41908. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  41909. /**
  41910. * Creates an AxisDragGizmo
  41911. * @param gizmoLayer The utility layer the gizmo will be added to
  41912. * @param dragAxis The axis which the gizmo will be able to drag on
  41913. * @param color The color of the gizmo
  41914. */
  41915. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  41916. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  41917. /**
  41918. * Disposes of the gizmo
  41919. */
  41920. dispose(): void;
  41921. }
  41922. }
  41923. declare module "babylonjs/Debug/axesViewer" {
  41924. import { Vector3 } from "babylonjs/Maths/math";
  41925. import { Nullable } from "babylonjs/types";
  41926. import { Scene } from "babylonjs/scene";
  41927. import { TransformNode } from "babylonjs/Meshes/transformNode";
  41928. /**
  41929. * The Axes viewer will show 3 axes in a specific point in space
  41930. */
  41931. export class AxesViewer {
  41932. private _xAxis;
  41933. private _yAxis;
  41934. private _zAxis;
  41935. private _scaleLinesFactor;
  41936. private _instanced;
  41937. /**
  41938. * Gets the hosting scene
  41939. */
  41940. scene: Scene;
  41941. /**
  41942. * Gets or sets a number used to scale line length
  41943. */
  41944. scaleLines: number;
  41945. /** Gets the node hierarchy used to render x-axis */
  41946. readonly xAxis: TransformNode;
  41947. /** Gets the node hierarchy used to render y-axis */
  41948. readonly yAxis: TransformNode;
  41949. /** Gets the node hierarchy used to render z-axis */
  41950. readonly zAxis: TransformNode;
  41951. /**
  41952. * Creates a new AxesViewer
  41953. * @param scene defines the hosting scene
  41954. * @param scaleLines defines a number used to scale line length (1 by default)
  41955. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  41956. * @param xAxis defines the node hierarchy used to render the x-axis
  41957. * @param yAxis defines the node hierarchy used to render the y-axis
  41958. * @param zAxis defines the node hierarchy used to render the z-axis
  41959. */
  41960. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  41961. /**
  41962. * Force the viewer to update
  41963. * @param position defines the position of the viewer
  41964. * @param xaxis defines the x axis of the viewer
  41965. * @param yaxis defines the y axis of the viewer
  41966. * @param zaxis defines the z axis of the viewer
  41967. */
  41968. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  41969. /**
  41970. * Creates an instance of this axes viewer.
  41971. * @returns a new axes viewer with instanced meshes
  41972. */
  41973. createInstance(): AxesViewer;
  41974. /** Releases resources */
  41975. dispose(): void;
  41976. private static _SetRenderingGroupId;
  41977. }
  41978. }
  41979. declare module "babylonjs/Debug/boneAxesViewer" {
  41980. import { Nullable } from "babylonjs/types";
  41981. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  41982. import { Vector3 } from "babylonjs/Maths/math";
  41983. import { Mesh } from "babylonjs/Meshes/mesh";
  41984. import { Bone } from "babylonjs/Bones/bone";
  41985. import { Scene } from "babylonjs/scene";
  41986. /**
  41987. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  41988. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  41989. */
  41990. export class BoneAxesViewer extends AxesViewer {
  41991. /**
  41992. * Gets or sets the target mesh where to display the axes viewer
  41993. */
  41994. mesh: Nullable<Mesh>;
  41995. /**
  41996. * Gets or sets the target bone where to display the axes viewer
  41997. */
  41998. bone: Nullable<Bone>;
  41999. /** Gets current position */
  42000. pos: Vector3;
  42001. /** Gets direction of X axis */
  42002. xaxis: Vector3;
  42003. /** Gets direction of Y axis */
  42004. yaxis: Vector3;
  42005. /** Gets direction of Z axis */
  42006. zaxis: Vector3;
  42007. /**
  42008. * Creates a new BoneAxesViewer
  42009. * @param scene defines the hosting scene
  42010. * @param bone defines the target bone
  42011. * @param mesh defines the target mesh
  42012. * @param scaleLines defines a scaling factor for line length (1 by default)
  42013. */
  42014. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  42015. /**
  42016. * Force the viewer to update
  42017. */
  42018. update(): void;
  42019. /** Releases resources */
  42020. dispose(): void;
  42021. }
  42022. }
  42023. declare module "babylonjs/Debug/debugLayer" {
  42024. import { Observable } from "babylonjs/Misc/observable";
  42025. import { Scene } from "babylonjs/scene";
  42026. /**
  42027. * Interface used to define scene explorer extensibility option
  42028. */
  42029. export interface IExplorerExtensibilityOption {
  42030. /**
  42031. * Define the option label
  42032. */
  42033. label: string;
  42034. /**
  42035. * Defines the action to execute on click
  42036. */
  42037. action: (entity: any) => void;
  42038. }
  42039. /**
  42040. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  42041. */
  42042. export interface IExplorerExtensibilityGroup {
  42043. /**
  42044. * Defines a predicate to test if a given type mut be extended
  42045. */
  42046. predicate: (entity: any) => boolean;
  42047. /**
  42048. * Gets the list of options added to a type
  42049. */
  42050. entries: IExplorerExtensibilityOption[];
  42051. }
  42052. /**
  42053. * Interface used to define the options to use to create the Inspector
  42054. */
  42055. export interface IInspectorOptions {
  42056. /**
  42057. * Display in overlay mode (default: false)
  42058. */
  42059. overlay?: boolean;
  42060. /**
  42061. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  42062. */
  42063. globalRoot?: HTMLElement;
  42064. /**
  42065. * Display the Scene explorer
  42066. */
  42067. showExplorer?: boolean;
  42068. /**
  42069. * Display the property inspector
  42070. */
  42071. showInspector?: boolean;
  42072. /**
  42073. * Display in embed mode (both panes on the right)
  42074. */
  42075. embedMode?: boolean;
  42076. /**
  42077. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  42078. */
  42079. handleResize?: boolean;
  42080. /**
  42081. * Allow the panes to popup (default: true)
  42082. */
  42083. enablePopup?: boolean;
  42084. /**
  42085. * Allow the panes to be closed by users (default: true)
  42086. */
  42087. enableClose?: boolean;
  42088. /**
  42089. * Optional list of extensibility entries
  42090. */
  42091. explorerExtensibility?: IExplorerExtensibilityGroup[];
  42092. /**
  42093. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  42094. */
  42095. inspectorURL?: string;
  42096. }
  42097. module "babylonjs/scene" {
  42098. interface Scene {
  42099. /**
  42100. * @hidden
  42101. * Backing field
  42102. */
  42103. _debugLayer: DebugLayer;
  42104. /**
  42105. * Gets the debug layer (aka Inspector) associated with the scene
  42106. * @see http://doc.babylonjs.com/features/playground_debuglayer
  42107. */
  42108. debugLayer: DebugLayer;
  42109. }
  42110. }
  42111. /**
  42112. * The debug layer (aka Inspector) is the go to tool in order to better understand
  42113. * what is happening in your scene
  42114. * @see http://doc.babylonjs.com/features/playground_debuglayer
  42115. */
  42116. export class DebugLayer {
  42117. /**
  42118. * Define the url to get the inspector script from.
  42119. * By default it uses the babylonjs CDN.
  42120. * @ignoreNaming
  42121. */
  42122. static InspectorURL: string;
  42123. private _scene;
  42124. private BJSINSPECTOR;
  42125. /**
  42126. * Observable triggered when a property is changed through the inspector.
  42127. */
  42128. onPropertyChangedObservable: Observable<{
  42129. object: any;
  42130. property: string;
  42131. value: any;
  42132. initialValue: any;
  42133. }>;
  42134. /**
  42135. * Instantiates a new debug layer.
  42136. * The debug layer (aka Inspector) is the go to tool in order to better understand
  42137. * what is happening in your scene
  42138. * @see http://doc.babylonjs.com/features/playground_debuglayer
  42139. * @param scene Defines the scene to inspect
  42140. */
  42141. constructor(scene: Scene);
  42142. /** Creates the inspector window. */
  42143. private _createInspector;
  42144. /**
  42145. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  42146. * @param entity defines the entity to select
  42147. * @param lineContainerTitle defines the specific block to highlight
  42148. */
  42149. select(entity: any, lineContainerTitle?: string): void;
  42150. /** Get the inspector from bundle or global */
  42151. private _getGlobalInspector;
  42152. /**
  42153. * Get if the inspector is visible or not.
  42154. * @returns true if visible otherwise, false
  42155. */
  42156. isVisible(): boolean;
  42157. /**
  42158. * Hide the inspector and close its window.
  42159. */
  42160. hide(): void;
  42161. /**
  42162. * Launch the debugLayer.
  42163. * @param config Define the configuration of the inspector
  42164. * @return a promise fulfilled when the debug layer is visible
  42165. */
  42166. show(config?: IInspectorOptions): Promise<DebugLayer>;
  42167. }
  42168. }
  42169. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  42170. import { Nullable } from "babylonjs/types";
  42171. import { Scene } from "babylonjs/scene";
  42172. import { Vector4, Color4 } from "babylonjs/Maths/math";
  42173. import { Mesh } from "babylonjs/Meshes/mesh";
  42174. /**
  42175. * Class containing static functions to help procedurally build meshes
  42176. */
  42177. export class BoxBuilder {
  42178. /**
  42179. * Creates a box mesh
  42180. * * The parameter `size` sets the size (float) of each box side (default 1)
  42181. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  42182. * * 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)
  42183. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  42184. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42185. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  42186. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42187. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  42188. * @param name defines the name of the mesh
  42189. * @param options defines the options used to create the mesh
  42190. * @param scene defines the hosting scene
  42191. * @returns the box mesh
  42192. */
  42193. static CreateBox(name: string, options: {
  42194. size?: number;
  42195. width?: number;
  42196. height?: number;
  42197. depth?: number;
  42198. faceUV?: Vector4[];
  42199. faceColors?: Color4[];
  42200. sideOrientation?: number;
  42201. frontUVs?: Vector4;
  42202. backUVs?: Vector4;
  42203. updatable?: boolean;
  42204. }, scene?: Nullable<Scene>): Mesh;
  42205. }
  42206. }
  42207. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  42208. import { Vector4 } from "babylonjs/Maths/math";
  42209. import { Mesh } from "babylonjs/Meshes/mesh";
  42210. /**
  42211. * Class containing static functions to help procedurally build meshes
  42212. */
  42213. export class SphereBuilder {
  42214. /**
  42215. * Creates a sphere mesh
  42216. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  42217. * * 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`)
  42218. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  42219. * * 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
  42220. * * 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)
  42221. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42222. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  42223. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42224. * @param name defines the name of the mesh
  42225. * @param options defines the options used to create the mesh
  42226. * @param scene defines the hosting scene
  42227. * @returns the sphere mesh
  42228. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  42229. */
  42230. static CreateSphere(name: string, options: {
  42231. segments?: number;
  42232. diameter?: number;
  42233. diameterX?: number;
  42234. diameterY?: number;
  42235. diameterZ?: number;
  42236. arc?: number;
  42237. slice?: number;
  42238. sideOrientation?: number;
  42239. frontUVs?: Vector4;
  42240. backUVs?: Vector4;
  42241. updatable?: boolean;
  42242. }, scene: any): Mesh;
  42243. }
  42244. }
  42245. declare module "babylonjs/Debug/physicsViewer" {
  42246. import { Nullable } from "babylonjs/types";
  42247. import { Scene } from "babylonjs/scene";
  42248. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42249. import { Mesh } from "babylonjs/Meshes/mesh";
  42250. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  42251. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  42252. /**
  42253. * Used to show the physics impostor around the specific mesh
  42254. */
  42255. export class PhysicsViewer {
  42256. /** @hidden */
  42257. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  42258. /** @hidden */
  42259. protected _meshes: Array<Nullable<AbstractMesh>>;
  42260. /** @hidden */
  42261. protected _scene: Nullable<Scene>;
  42262. /** @hidden */
  42263. protected _numMeshes: number;
  42264. /** @hidden */
  42265. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  42266. private _renderFunction;
  42267. private _utilityLayer;
  42268. private _debugBoxMesh;
  42269. private _debugSphereMesh;
  42270. private _debugCylinderMesh;
  42271. private _debugMaterial;
  42272. private _debugMeshMeshes;
  42273. /**
  42274. * Creates a new PhysicsViewer
  42275. * @param scene defines the hosting scene
  42276. */
  42277. constructor(scene: Scene);
  42278. /** @hidden */
  42279. protected _updateDebugMeshes(): void;
  42280. /**
  42281. * Renders a specified physic impostor
  42282. * @param impostor defines the impostor to render
  42283. * @param targetMesh defines the mesh represented by the impostor
  42284. * @returns the new debug mesh used to render the impostor
  42285. */
  42286. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  42287. /**
  42288. * Hides a specified physic impostor
  42289. * @param impostor defines the impostor to hide
  42290. */
  42291. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  42292. private _getDebugMaterial;
  42293. private _getDebugBoxMesh;
  42294. private _getDebugSphereMesh;
  42295. private _getDebugCylinderMesh;
  42296. private _getDebugMeshMesh;
  42297. private _getDebugMesh;
  42298. /** Releases all resources */
  42299. dispose(): void;
  42300. }
  42301. }
  42302. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  42303. import { Vector3, Color4 } from "babylonjs/Maths/math";
  42304. import { Nullable } from "babylonjs/types";
  42305. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  42306. import { Scene } from "babylonjs/scene";
  42307. /**
  42308. * Class containing static functions to help procedurally build meshes
  42309. */
  42310. export class LinesBuilder {
  42311. /**
  42312. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  42313. * * 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
  42314. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  42315. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  42316. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  42317. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  42318. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  42319. * * 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
  42320. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  42321. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42322. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  42323. * @param name defines the name of the new line system
  42324. * @param options defines the options used to create the line system
  42325. * @param scene defines the hosting scene
  42326. * @returns a new line system mesh
  42327. */
  42328. static CreateLineSystem(name: string, options: {
  42329. lines: Vector3[][];
  42330. updatable?: boolean;
  42331. instance?: Nullable<LinesMesh>;
  42332. colors?: Nullable<Color4[][]>;
  42333. useVertexAlpha?: boolean;
  42334. }, scene: Nullable<Scene>): LinesMesh;
  42335. /**
  42336. * Creates a line mesh
  42337. * 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
  42338. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  42339. * * The parameter `points` is an array successive Vector3
  42340. * * 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
  42341. * * The optional parameter `colors` is an array of successive Color4, one per line point
  42342. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  42343. * * When updating an instance, remember that only point positions can change, not the number of points
  42344. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42345. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  42346. * @param name defines the name of the new line system
  42347. * @param options defines the options used to create the line system
  42348. * @param scene defines the hosting scene
  42349. * @returns a new line mesh
  42350. */
  42351. static CreateLines(name: string, options: {
  42352. points: Vector3[];
  42353. updatable?: boolean;
  42354. instance?: Nullable<LinesMesh>;
  42355. colors?: Color4[];
  42356. useVertexAlpha?: boolean;
  42357. }, scene?: Nullable<Scene>): LinesMesh;
  42358. /**
  42359. * Creates a dashed line mesh
  42360. * * 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
  42361. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  42362. * * The parameter `points` is an array successive Vector3
  42363. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  42364. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  42365. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  42366. * * 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
  42367. * * When updating an instance, remember that only point positions can change, not the number of points
  42368. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42369. * @param name defines the name of the mesh
  42370. * @param options defines the options used to create the mesh
  42371. * @param scene defines the hosting scene
  42372. * @returns the dashed line mesh
  42373. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  42374. */
  42375. static CreateDashedLines(name: string, options: {
  42376. points: Vector3[];
  42377. dashSize?: number;
  42378. gapSize?: number;
  42379. dashNb?: number;
  42380. updatable?: boolean;
  42381. instance?: LinesMesh;
  42382. }, scene?: Nullable<Scene>): LinesMesh;
  42383. }
  42384. }
  42385. declare module "babylonjs/Debug/rayHelper" {
  42386. import { Nullable } from "babylonjs/types";
  42387. import { Ray } from "babylonjs/Culling/ray";
  42388. import { Vector3, Color3 } from "babylonjs/Maths/math";
  42389. import { Scene } from "babylonjs/scene";
  42390. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42391. import "babylonjs/Meshes/Builders/linesBuilder";
  42392. /**
  42393. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  42394. * in order to better appreciate the issue one might have.
  42395. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  42396. */
  42397. export class RayHelper {
  42398. /**
  42399. * Defines the ray we are currently tryin to visualize.
  42400. */
  42401. ray: Nullable<Ray>;
  42402. private _renderPoints;
  42403. private _renderLine;
  42404. private _renderFunction;
  42405. private _scene;
  42406. private _updateToMeshFunction;
  42407. private _attachedToMesh;
  42408. private _meshSpaceDirection;
  42409. private _meshSpaceOrigin;
  42410. /**
  42411. * Helper function to create a colored helper in a scene in one line.
  42412. * @param ray Defines the ray we are currently tryin to visualize
  42413. * @param scene Defines the scene the ray is used in
  42414. * @param color Defines the color we want to see the ray in
  42415. * @returns The newly created ray helper.
  42416. */
  42417. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  42418. /**
  42419. * Instantiate a new ray helper.
  42420. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  42421. * in order to better appreciate the issue one might have.
  42422. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  42423. * @param ray Defines the ray we are currently tryin to visualize
  42424. */
  42425. constructor(ray: Ray);
  42426. /**
  42427. * Shows the ray we are willing to debug.
  42428. * @param scene Defines the scene the ray needs to be rendered in
  42429. * @param color Defines the color the ray needs to be rendered in
  42430. */
  42431. show(scene: Scene, color?: Color3): void;
  42432. /**
  42433. * Hides the ray we are debugging.
  42434. */
  42435. hide(): void;
  42436. private _render;
  42437. /**
  42438. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  42439. * @param mesh Defines the mesh we want the helper attached to
  42440. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  42441. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  42442. * @param length Defines the length of the ray
  42443. */
  42444. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  42445. /**
  42446. * Detach the ray helper from the mesh it has previously been attached to.
  42447. */
  42448. detachFromMesh(): void;
  42449. private _updateToMesh;
  42450. /**
  42451. * Dispose the helper and release its associated resources.
  42452. */
  42453. dispose(): void;
  42454. }
  42455. }
  42456. declare module "babylonjs/Debug/skeletonViewer" {
  42457. import { Color3 } from "babylonjs/Maths/math";
  42458. import { Scene } from "babylonjs/scene";
  42459. import { Nullable } from "babylonjs/types";
  42460. import { Skeleton } from "babylonjs/Bones/skeleton";
  42461. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42462. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  42463. /**
  42464. * Class used to render a debug view of a given skeleton
  42465. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  42466. */
  42467. export class SkeletonViewer {
  42468. /** defines the skeleton to render */
  42469. skeleton: Skeleton;
  42470. /** defines the mesh attached to the skeleton */
  42471. mesh: AbstractMesh;
  42472. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  42473. autoUpdateBonesMatrices: boolean;
  42474. /** defines the rendering group id to use with the viewer */
  42475. renderingGroupId: number;
  42476. /** Gets or sets the color used to render the skeleton */
  42477. color: Color3;
  42478. private _scene;
  42479. private _debugLines;
  42480. private _debugMesh;
  42481. private _isEnabled;
  42482. private _renderFunction;
  42483. private _utilityLayer;
  42484. /**
  42485. * Returns the mesh used to render the bones
  42486. */
  42487. readonly debugMesh: Nullable<LinesMesh>;
  42488. /**
  42489. * Creates a new SkeletonViewer
  42490. * @param skeleton defines the skeleton to render
  42491. * @param mesh defines the mesh attached to the skeleton
  42492. * @param scene defines the hosting scene
  42493. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  42494. * @param renderingGroupId defines the rendering group id to use with the viewer
  42495. */
  42496. constructor(
  42497. /** defines the skeleton to render */
  42498. skeleton: Skeleton,
  42499. /** defines the mesh attached to the skeleton */
  42500. mesh: AbstractMesh, scene: Scene,
  42501. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  42502. autoUpdateBonesMatrices?: boolean,
  42503. /** defines the rendering group id to use with the viewer */
  42504. renderingGroupId?: number);
  42505. /** Gets or sets a boolean indicating if the viewer is enabled */
  42506. isEnabled: boolean;
  42507. private _getBonePosition;
  42508. private _getLinesForBonesWithLength;
  42509. private _getLinesForBonesNoLength;
  42510. /** Update the viewer to sync with current skeleton state */
  42511. update(): void;
  42512. /** Release associated resources */
  42513. dispose(): void;
  42514. }
  42515. }
  42516. declare module "babylonjs/Debug/index" {
  42517. export * from "babylonjs/Debug/axesViewer";
  42518. export * from "babylonjs/Debug/boneAxesViewer";
  42519. export * from "babylonjs/Debug/debugLayer";
  42520. export * from "babylonjs/Debug/physicsViewer";
  42521. export * from "babylonjs/Debug/rayHelper";
  42522. export * from "babylonjs/Debug/skeletonViewer";
  42523. }
  42524. declare module "babylonjs/Engines/nullEngine" {
  42525. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  42526. import { Scene } from "babylonjs/scene";
  42527. import { Matrix, Color3, Color4, Viewport } from "babylonjs/Maths/math";
  42528. import { Engine } from "babylonjs/Engines/engine";
  42529. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  42530. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  42531. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  42532. import { Effect } from "babylonjs/Materials/effect";
  42533. /**
  42534. * Options to create the null engine
  42535. */
  42536. export class NullEngineOptions {
  42537. /**
  42538. * Render width (Default: 512)
  42539. */
  42540. renderWidth: number;
  42541. /**
  42542. * Render height (Default: 256)
  42543. */
  42544. renderHeight: number;
  42545. /**
  42546. * Texture size (Default: 512)
  42547. */
  42548. textureSize: number;
  42549. /**
  42550. * If delta time between frames should be constant
  42551. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42552. */
  42553. deterministicLockstep: boolean;
  42554. /**
  42555. * Maximum about of steps between frames (Default: 4)
  42556. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42557. */
  42558. lockstepMaxSteps: number;
  42559. }
  42560. /**
  42561. * The null engine class provides support for headless version of babylon.js.
  42562. * This can be used in server side scenario or for testing purposes
  42563. */
  42564. export class NullEngine extends Engine {
  42565. private _options;
  42566. /**
  42567. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42568. */
  42569. isDeterministicLockStep(): boolean;
  42570. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  42571. getLockstepMaxSteps(): number;
  42572. /**
  42573. * Sets hardware scaling, used to save performance if needed
  42574. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  42575. */
  42576. getHardwareScalingLevel(): number;
  42577. constructor(options?: NullEngineOptions);
  42578. createVertexBuffer(vertices: FloatArray): WebGLBuffer;
  42579. createIndexBuffer(indices: IndicesArray): WebGLBuffer;
  42580. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  42581. getRenderWidth(useScreen?: boolean): number;
  42582. getRenderHeight(useScreen?: boolean): number;
  42583. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  42584. createShaderProgram(vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  42585. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): WebGLUniformLocation[];
  42586. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  42587. bindSamplers(effect: Effect): void;
  42588. enableEffect(effect: Effect): void;
  42589. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  42590. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  42591. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  42592. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  42593. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  42594. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  42595. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  42596. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  42597. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  42598. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  42599. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  42600. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  42601. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  42602. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  42603. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  42604. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  42605. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  42606. setFloat(uniform: WebGLUniformLocation, value: number): void;
  42607. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  42608. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  42609. setBool(uniform: WebGLUniformLocation, bool: number): void;
  42610. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  42611. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  42612. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  42613. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  42614. bindBuffers(vertexBuffers: {
  42615. [key: string]: VertexBuffer;
  42616. }, indexBuffer: WebGLBuffer, effect: Effect): void;
  42617. wipeCaches(bruteForce?: boolean): void;
  42618. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  42619. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  42620. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  42621. /** @hidden */
  42622. _createTexture(): WebGLTexture;
  42623. /** @hidden */
  42624. _releaseTexture(texture: InternalTexture): void;
  42625. 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;
  42626. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  42627. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  42628. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  42629. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  42630. createDynamicVertexBuffer(vertices: FloatArray): WebGLBuffer;
  42631. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  42632. areAllEffectsReady(): boolean;
  42633. /**
  42634. * @hidden
  42635. * Get the current error code of the webGL context
  42636. * @returns the error code
  42637. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  42638. */
  42639. getError(): number;
  42640. /** @hidden */
  42641. _getUnpackAlignement(): number;
  42642. /** @hidden */
  42643. _unpackFlipY(value: boolean): void;
  42644. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  42645. /**
  42646. * Updates a dynamic vertex buffer.
  42647. * @param vertexBuffer the vertex buffer to update
  42648. * @param data the data used to update the vertex buffer
  42649. * @param byteOffset the byte offset of the data (optional)
  42650. * @param byteLength the byte length of the data (optional)
  42651. */
  42652. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  42653. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  42654. /** @hidden */
  42655. _bindTexture(channel: number, texture: InternalTexture): void;
  42656. /** @hidden */
  42657. _releaseBuffer(buffer: WebGLBuffer): boolean;
  42658. releaseEffects(): void;
  42659. displayLoadingUI(): void;
  42660. hideLoadingUI(): void;
  42661. /** @hidden */
  42662. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  42663. /** @hidden */
  42664. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  42665. /** @hidden */
  42666. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  42667. /** @hidden */
  42668. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  42669. }
  42670. }
  42671. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  42672. import { Nullable, int } from "babylonjs/types";
  42673. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  42674. /** @hidden */
  42675. export class _OcclusionDataStorage {
  42676. /** @hidden */
  42677. occlusionInternalRetryCounter: number;
  42678. /** @hidden */
  42679. isOcclusionQueryInProgress: boolean;
  42680. /** @hidden */
  42681. isOccluded: boolean;
  42682. /** @hidden */
  42683. occlusionRetryCount: number;
  42684. /** @hidden */
  42685. occlusionType: number;
  42686. /** @hidden */
  42687. occlusionQueryAlgorithmType: number;
  42688. }
  42689. module "babylonjs/Engines/engine" {
  42690. interface Engine {
  42691. /**
  42692. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  42693. * @return the new query
  42694. */
  42695. createQuery(): WebGLQuery;
  42696. /**
  42697. * Delete and release a webGL query
  42698. * @param query defines the query to delete
  42699. * @return the current engine
  42700. */
  42701. deleteQuery(query: WebGLQuery): Engine;
  42702. /**
  42703. * Check if a given query has resolved and got its value
  42704. * @param query defines the query to check
  42705. * @returns true if the query got its value
  42706. */
  42707. isQueryResultAvailable(query: WebGLQuery): boolean;
  42708. /**
  42709. * Gets the value of a given query
  42710. * @param query defines the query to check
  42711. * @returns the value of the query
  42712. */
  42713. getQueryResult(query: WebGLQuery): number;
  42714. /**
  42715. * Initiates an occlusion query
  42716. * @param algorithmType defines the algorithm to use
  42717. * @param query defines the query to use
  42718. * @returns the current engine
  42719. * @see http://doc.babylonjs.com/features/occlusionquery
  42720. */
  42721. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  42722. /**
  42723. * Ends an occlusion query
  42724. * @see http://doc.babylonjs.com/features/occlusionquery
  42725. * @param algorithmType defines the algorithm to use
  42726. * @returns the current engine
  42727. */
  42728. endOcclusionQuery(algorithmType: number): Engine;
  42729. /**
  42730. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  42731. * Please note that only one query can be issued at a time
  42732. * @returns a time token used to track the time span
  42733. */
  42734. startTimeQuery(): Nullable<_TimeToken>;
  42735. /**
  42736. * Ends a time query
  42737. * @param token defines the token used to measure the time span
  42738. * @returns the time spent (in ns)
  42739. */
  42740. endTimeQuery(token: _TimeToken): int;
  42741. /** @hidden */
  42742. _currentNonTimestampToken: Nullable<_TimeToken>;
  42743. /** @hidden */
  42744. _createTimeQuery(): WebGLQuery;
  42745. /** @hidden */
  42746. _deleteTimeQuery(query: WebGLQuery): void;
  42747. /** @hidden */
  42748. _getGlAlgorithmType(algorithmType: number): number;
  42749. /** @hidden */
  42750. _getTimeQueryResult(query: WebGLQuery): any;
  42751. /** @hidden */
  42752. _getTimeQueryAvailability(query: WebGLQuery): any;
  42753. }
  42754. }
  42755. module "babylonjs/Meshes/abstractMesh" {
  42756. interface AbstractMesh {
  42757. /**
  42758. * Backing filed
  42759. * @hidden
  42760. */
  42761. __occlusionDataStorage: _OcclusionDataStorage;
  42762. /**
  42763. * Access property
  42764. * @hidden
  42765. */
  42766. _occlusionDataStorage: _OcclusionDataStorage;
  42767. /**
  42768. * 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.
  42769. * The default value is -1 which means don't break the query and wait till the result
  42770. * @see http://doc.babylonjs.com/features/occlusionquery
  42771. */
  42772. occlusionRetryCount: number;
  42773. /**
  42774. * 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:
  42775. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  42776. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  42777. * * 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.
  42778. * @see http://doc.babylonjs.com/features/occlusionquery
  42779. */
  42780. occlusionType: number;
  42781. /**
  42782. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  42783. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  42784. * * 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.
  42785. * @see http://doc.babylonjs.com/features/occlusionquery
  42786. */
  42787. occlusionQueryAlgorithmType: number;
  42788. /**
  42789. * 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
  42790. * @see http://doc.babylonjs.com/features/occlusionquery
  42791. */
  42792. isOccluded: boolean;
  42793. /**
  42794. * Flag to check the progress status of the query
  42795. * @see http://doc.babylonjs.com/features/occlusionquery
  42796. */
  42797. isOcclusionQueryInProgress: boolean;
  42798. }
  42799. }
  42800. }
  42801. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  42802. import { Nullable } from "babylonjs/types";
  42803. /** @hidden */
  42804. export var _forceTransformFeedbackToBundle: boolean;
  42805. module "babylonjs/Engines/engine" {
  42806. interface Engine {
  42807. /**
  42808. * Creates a webGL transform feedback object
  42809. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  42810. * @returns the webGL transform feedback object
  42811. */
  42812. createTransformFeedback(): WebGLTransformFeedback;
  42813. /**
  42814. * Delete a webGL transform feedback object
  42815. * @param value defines the webGL transform feedback object to delete
  42816. */
  42817. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  42818. /**
  42819. * Bind a webGL transform feedback object to the webgl context
  42820. * @param value defines the webGL transform feedback object to bind
  42821. */
  42822. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  42823. /**
  42824. * Begins a transform feedback operation
  42825. * @param usePoints defines if points or triangles must be used
  42826. */
  42827. beginTransformFeedback(usePoints: boolean): void;
  42828. /**
  42829. * Ends a transform feedback operation
  42830. */
  42831. endTransformFeedback(): void;
  42832. /**
  42833. * Specify the varyings to use with transform feedback
  42834. * @param program defines the associated webGL program
  42835. * @param value defines the list of strings representing the varying names
  42836. */
  42837. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  42838. /**
  42839. * Bind a webGL buffer for a transform feedback operation
  42840. * @param value defines the webGL buffer to bind
  42841. */
  42842. bindTransformFeedbackBuffer(value: Nullable<WebGLBuffer>): void;
  42843. }
  42844. }
  42845. }
  42846. declare module "babylonjs/Engines/Extensions/index" {
  42847. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  42848. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  42849. export * from "babylonjs/Engines/Extensions/engine.multiview";
  42850. }
  42851. declare module "babylonjs/Engines/index" {
  42852. export * from "babylonjs/Engines/constants";
  42853. export * from "babylonjs/Engines/engine";
  42854. export * from "babylonjs/Engines/engineStore";
  42855. export * from "babylonjs/Engines/nullEngine";
  42856. export * from "babylonjs/Engines/Extensions/index";
  42857. }
  42858. declare module "babylonjs/Events/clipboardEvents" {
  42859. /**
  42860. * Gather the list of clipboard event types as constants.
  42861. */
  42862. export class ClipboardEventTypes {
  42863. /**
  42864. * The clipboard event is fired when a copy command is active (pressed).
  42865. */
  42866. static readonly COPY: number;
  42867. /**
  42868. * The clipboard event is fired when a cut command is active (pressed).
  42869. */
  42870. static readonly CUT: number;
  42871. /**
  42872. * The clipboard event is fired when a paste command is active (pressed).
  42873. */
  42874. static readonly PASTE: number;
  42875. }
  42876. /**
  42877. * This class is used to store clipboard related info for the onClipboardObservable event.
  42878. */
  42879. export class ClipboardInfo {
  42880. /**
  42881. * Defines the type of event (BABYLON.ClipboardEventTypes)
  42882. */
  42883. type: number;
  42884. /**
  42885. * Defines the related dom event
  42886. */
  42887. event: ClipboardEvent;
  42888. /**
  42889. *Creates an instance of ClipboardInfo.
  42890. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  42891. * @param event Defines the related dom event
  42892. */
  42893. constructor(
  42894. /**
  42895. * Defines the type of event (BABYLON.ClipboardEventTypes)
  42896. */
  42897. type: number,
  42898. /**
  42899. * Defines the related dom event
  42900. */
  42901. event: ClipboardEvent);
  42902. /**
  42903. * Get the clipboard event's type from the keycode.
  42904. * @param keyCode Defines the keyCode for the current keyboard event.
  42905. * @return {number}
  42906. */
  42907. static GetTypeFromCharacter(keyCode: number): number;
  42908. }
  42909. }
  42910. declare module "babylonjs/Events/index" {
  42911. export * from "babylonjs/Events/keyboardEvents";
  42912. export * from "babylonjs/Events/pointerEvents";
  42913. export * from "babylonjs/Events/clipboardEvents";
  42914. }
  42915. declare module "babylonjs/Loading/sceneLoader" {
  42916. import { Observable } from "babylonjs/Misc/observable";
  42917. import { Nullable } from "babylonjs/types";
  42918. import { Scene } from "babylonjs/scene";
  42919. import { Engine } from "babylonjs/Engines/engine";
  42920. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42921. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  42922. import { AssetContainer } from "babylonjs/assetContainer";
  42923. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  42924. import { Skeleton } from "babylonjs/Bones/skeleton";
  42925. /**
  42926. * Class used to represent data loading progression
  42927. */
  42928. export class SceneLoaderProgressEvent {
  42929. /** defines if data length to load can be evaluated */
  42930. readonly lengthComputable: boolean;
  42931. /** defines the loaded data length */
  42932. readonly loaded: number;
  42933. /** defines the data length to load */
  42934. readonly total: number;
  42935. /**
  42936. * Create a new progress event
  42937. * @param lengthComputable defines if data length to load can be evaluated
  42938. * @param loaded defines the loaded data length
  42939. * @param total defines the data length to load
  42940. */
  42941. constructor(
  42942. /** defines if data length to load can be evaluated */
  42943. lengthComputable: boolean,
  42944. /** defines the loaded data length */
  42945. loaded: number,
  42946. /** defines the data length to load */
  42947. total: number);
  42948. /**
  42949. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  42950. * @param event defines the source event
  42951. * @returns a new SceneLoaderProgressEvent
  42952. */
  42953. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  42954. }
  42955. /**
  42956. * Interface used by SceneLoader plugins to define supported file extensions
  42957. */
  42958. export interface ISceneLoaderPluginExtensions {
  42959. /**
  42960. * Defines the list of supported extensions
  42961. */
  42962. [extension: string]: {
  42963. isBinary: boolean;
  42964. };
  42965. }
  42966. /**
  42967. * Interface used by SceneLoader plugin factory
  42968. */
  42969. export interface ISceneLoaderPluginFactory {
  42970. /**
  42971. * Defines the name of the factory
  42972. */
  42973. name: string;
  42974. /**
  42975. * Function called to create a new plugin
  42976. * @return the new plugin
  42977. */
  42978. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  42979. /**
  42980. * Boolean indicating if the plugin can direct load specific data
  42981. */
  42982. canDirectLoad?: (data: string) => boolean;
  42983. }
  42984. /**
  42985. * Interface used to define a SceneLoader plugin
  42986. */
  42987. export interface ISceneLoaderPlugin {
  42988. /**
  42989. * The friendly name of this plugin.
  42990. */
  42991. name: string;
  42992. /**
  42993. * The file extensions supported by this plugin.
  42994. */
  42995. extensions: string | ISceneLoaderPluginExtensions;
  42996. /**
  42997. * Import meshes into a scene.
  42998. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42999. * @param scene The scene to import into
  43000. * @param data The data to import
  43001. * @param rootUrl The root url for scene and resources
  43002. * @param meshes The meshes array to import into
  43003. * @param particleSystems The particle systems array to import into
  43004. * @param skeletons The skeletons array to import into
  43005. * @param onError The callback when import fails
  43006. * @returns True if successful or false otherwise
  43007. */
  43008. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  43009. /**
  43010. * Load into a scene.
  43011. * @param scene The scene to load into
  43012. * @param data The data to import
  43013. * @param rootUrl The root url for scene and resources
  43014. * @param onError The callback when import fails
  43015. * @returns true if successful or false otherwise
  43016. */
  43017. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  43018. /**
  43019. * The callback that returns true if the data can be directly loaded.
  43020. */
  43021. canDirectLoad?: (data: string) => boolean;
  43022. /**
  43023. * The callback that allows custom handling of the root url based on the response url.
  43024. */
  43025. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  43026. /**
  43027. * Load into an asset container.
  43028. * @param scene The scene to load into
  43029. * @param data The data to import
  43030. * @param rootUrl The root url for scene and resources
  43031. * @param onError The callback when import fails
  43032. * @returns The loaded asset container
  43033. */
  43034. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  43035. }
  43036. /**
  43037. * Interface used to define an async SceneLoader plugin
  43038. */
  43039. export interface ISceneLoaderPluginAsync {
  43040. /**
  43041. * The friendly name of this plugin.
  43042. */
  43043. name: string;
  43044. /**
  43045. * The file extensions supported by this plugin.
  43046. */
  43047. extensions: string | ISceneLoaderPluginExtensions;
  43048. /**
  43049. * Import meshes into a scene.
  43050. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43051. * @param scene The scene to import into
  43052. * @param data The data to import
  43053. * @param rootUrl The root url for scene and resources
  43054. * @param onProgress The callback when the load progresses
  43055. * @param fileName Defines the name of the file to load
  43056. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  43057. */
  43058. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  43059. meshes: AbstractMesh[];
  43060. particleSystems: IParticleSystem[];
  43061. skeletons: Skeleton[];
  43062. animationGroups: AnimationGroup[];
  43063. }>;
  43064. /**
  43065. * Load into a scene.
  43066. * @param scene The scene to load into
  43067. * @param data The data to import
  43068. * @param rootUrl The root url for scene and resources
  43069. * @param onProgress The callback when the load progresses
  43070. * @param fileName Defines the name of the file to load
  43071. * @returns Nothing
  43072. */
  43073. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  43074. /**
  43075. * The callback that returns true if the data can be directly loaded.
  43076. */
  43077. canDirectLoad?: (data: string) => boolean;
  43078. /**
  43079. * The callback that allows custom handling of the root url based on the response url.
  43080. */
  43081. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  43082. /**
  43083. * Load into an asset container.
  43084. * @param scene The scene to load into
  43085. * @param data The data to import
  43086. * @param rootUrl The root url for scene and resources
  43087. * @param onProgress The callback when the load progresses
  43088. * @param fileName Defines the name of the file to load
  43089. * @returns The loaded asset container
  43090. */
  43091. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  43092. }
  43093. /**
  43094. * Class used to load scene from various file formats using registered plugins
  43095. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  43096. */
  43097. export class SceneLoader {
  43098. /**
  43099. * No logging while loading
  43100. */
  43101. static readonly NO_LOGGING: number;
  43102. /**
  43103. * Minimal logging while loading
  43104. */
  43105. static readonly MINIMAL_LOGGING: number;
  43106. /**
  43107. * Summary logging while loading
  43108. */
  43109. static readonly SUMMARY_LOGGING: number;
  43110. /**
  43111. * Detailled logging while loading
  43112. */
  43113. static readonly DETAILED_LOGGING: number;
  43114. /**
  43115. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  43116. */
  43117. static ForceFullSceneLoadingForIncremental: boolean;
  43118. /**
  43119. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  43120. */
  43121. static ShowLoadingScreen: boolean;
  43122. /**
  43123. * Defines the current logging level (while loading the scene)
  43124. * @ignorenaming
  43125. */
  43126. static loggingLevel: number;
  43127. /**
  43128. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  43129. */
  43130. static CleanBoneMatrixWeights: boolean;
  43131. /**
  43132. * Event raised when a plugin is used to load a scene
  43133. */
  43134. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  43135. private static _registeredPlugins;
  43136. private static _getDefaultPlugin;
  43137. private static _getPluginForExtension;
  43138. private static _getPluginForDirectLoad;
  43139. private static _getPluginForFilename;
  43140. private static _getDirectLoad;
  43141. private static _loadData;
  43142. private static _getFileInfo;
  43143. /**
  43144. * Gets a plugin that can load the given extension
  43145. * @param extension defines the extension to load
  43146. * @returns a plugin or null if none works
  43147. */
  43148. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  43149. /**
  43150. * Gets a boolean indicating that the given extension can be loaded
  43151. * @param extension defines the extension to load
  43152. * @returns true if the extension is supported
  43153. */
  43154. static IsPluginForExtensionAvailable(extension: string): boolean;
  43155. /**
  43156. * Adds a new plugin to the list of registered plugins
  43157. * @param plugin defines the plugin to add
  43158. */
  43159. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  43160. /**
  43161. * Import meshes into a scene
  43162. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43163. * @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)
  43164. * @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)
  43165. * @param scene the instance of BABYLON.Scene to append to
  43166. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  43167. * @param onProgress a callback with a progress event for each file being loaded
  43168. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43169. * @param pluginExtension the extension used to determine the plugin
  43170. * @returns The loaded plugin
  43171. */
  43172. 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>;
  43173. /**
  43174. * Import meshes into a scene
  43175. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43176. * @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)
  43177. * @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)
  43178. * @param scene the instance of BABYLON.Scene to append to
  43179. * @param onProgress a callback with a progress event for each file being loaded
  43180. * @param pluginExtension the extension used to determine the plugin
  43181. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  43182. */
  43183. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  43184. meshes: AbstractMesh[];
  43185. particleSystems: IParticleSystem[];
  43186. skeletons: Skeleton[];
  43187. animationGroups: AnimationGroup[];
  43188. }>;
  43189. /**
  43190. * Load a scene
  43191. * @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)
  43192. * @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)
  43193. * @param engine is the instance of BABYLON.Engine to use to create the scene
  43194. * @param onSuccess a callback with the scene when import succeeds
  43195. * @param onProgress a callback with a progress event for each file being loaded
  43196. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43197. * @param pluginExtension the extension used to determine the plugin
  43198. * @returns The loaded plugin
  43199. */
  43200. 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>;
  43201. /**
  43202. * Load a scene
  43203. * @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)
  43204. * @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)
  43205. * @param engine is the instance of BABYLON.Engine to use to create the scene
  43206. * @param onProgress a callback with a progress event for each file being loaded
  43207. * @param pluginExtension the extension used to determine the plugin
  43208. * @returns The loaded scene
  43209. */
  43210. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  43211. /**
  43212. * Append a scene
  43213. * @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)
  43214. * @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)
  43215. * @param scene is the instance of BABYLON.Scene to append to
  43216. * @param onSuccess a callback with the scene when import succeeds
  43217. * @param onProgress a callback with a progress event for each file being loaded
  43218. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43219. * @param pluginExtension the extension used to determine the plugin
  43220. * @returns The loaded plugin
  43221. */
  43222. 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>;
  43223. /**
  43224. * Append a scene
  43225. * @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)
  43226. * @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)
  43227. * @param scene is the instance of BABYLON.Scene to append to
  43228. * @param onProgress a callback with a progress event for each file being loaded
  43229. * @param pluginExtension the extension used to determine the plugin
  43230. * @returns The given scene
  43231. */
  43232. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  43233. /**
  43234. * Load a scene into an asset container
  43235. * @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)
  43236. * @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)
  43237. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  43238. * @param onSuccess a callback with the scene when import succeeds
  43239. * @param onProgress a callback with a progress event for each file being loaded
  43240. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43241. * @param pluginExtension the extension used to determine the plugin
  43242. * @returns The loaded plugin
  43243. */
  43244. 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>;
  43245. /**
  43246. * Load a scene into an asset container
  43247. * @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)
  43248. * @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)
  43249. * @param scene is the instance of Scene to append to
  43250. * @param onProgress a callback with a progress event for each file being loaded
  43251. * @param pluginExtension the extension used to determine the plugin
  43252. * @returns The loaded asset container
  43253. */
  43254. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  43255. }
  43256. }
  43257. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  43258. import { Scene } from "babylonjs/scene";
  43259. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43260. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43261. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43262. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43263. /**
  43264. * Google Daydream controller
  43265. */
  43266. export class DaydreamController extends WebVRController {
  43267. /**
  43268. * Base Url for the controller model.
  43269. */
  43270. static MODEL_BASE_URL: string;
  43271. /**
  43272. * File name for the controller model.
  43273. */
  43274. static MODEL_FILENAME: string;
  43275. /**
  43276. * Gamepad Id prefix used to identify Daydream Controller.
  43277. */
  43278. static readonly GAMEPAD_ID_PREFIX: string;
  43279. /**
  43280. * Creates a new DaydreamController from a gamepad
  43281. * @param vrGamepad the gamepad that the controller should be created from
  43282. */
  43283. constructor(vrGamepad: any);
  43284. /**
  43285. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43286. * @param scene scene in which to add meshes
  43287. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43288. */
  43289. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43290. /**
  43291. * Called once for each button that changed state since the last frame
  43292. * @param buttonIdx Which button index changed
  43293. * @param state New state of the button
  43294. * @param changes Which properties on the state changed since last frame
  43295. */
  43296. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43297. }
  43298. }
  43299. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  43300. import { Scene } from "babylonjs/scene";
  43301. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43302. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43303. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43304. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43305. /**
  43306. * Gear VR Controller
  43307. */
  43308. export class GearVRController extends WebVRController {
  43309. /**
  43310. * Base Url for the controller model.
  43311. */
  43312. static MODEL_BASE_URL: string;
  43313. /**
  43314. * File name for the controller model.
  43315. */
  43316. static MODEL_FILENAME: string;
  43317. /**
  43318. * Gamepad Id prefix used to identify this controller.
  43319. */
  43320. static readonly GAMEPAD_ID_PREFIX: string;
  43321. private readonly _buttonIndexToObservableNameMap;
  43322. /**
  43323. * Creates a new GearVRController from a gamepad
  43324. * @param vrGamepad the gamepad that the controller should be created from
  43325. */
  43326. constructor(vrGamepad: any);
  43327. /**
  43328. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43329. * @param scene scene in which to add meshes
  43330. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43331. */
  43332. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43333. /**
  43334. * Called once for each button that changed state since the last frame
  43335. * @param buttonIdx Which button index changed
  43336. * @param state New state of the button
  43337. * @param changes Which properties on the state changed since last frame
  43338. */
  43339. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43340. }
  43341. }
  43342. declare module "babylonjs/Gamepads/Controllers/genericController" {
  43343. import { Scene } from "babylonjs/scene";
  43344. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43345. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43346. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43347. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43348. /**
  43349. * Generic Controller
  43350. */
  43351. export class GenericController extends WebVRController {
  43352. /**
  43353. * Base Url for the controller model.
  43354. */
  43355. static readonly MODEL_BASE_URL: string;
  43356. /**
  43357. * File name for the controller model.
  43358. */
  43359. static readonly MODEL_FILENAME: string;
  43360. /**
  43361. * Creates a new GenericController from a gamepad
  43362. * @param vrGamepad the gamepad that the controller should be created from
  43363. */
  43364. constructor(vrGamepad: any);
  43365. /**
  43366. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43367. * @param scene scene in which to add meshes
  43368. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43369. */
  43370. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43371. /**
  43372. * Called once for each button that changed state since the last frame
  43373. * @param buttonIdx Which button index changed
  43374. * @param state New state of the button
  43375. * @param changes Which properties on the state changed since last frame
  43376. */
  43377. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43378. }
  43379. }
  43380. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  43381. import { Observable } from "babylonjs/Misc/observable";
  43382. import { Scene } from "babylonjs/scene";
  43383. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43384. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43385. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43386. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43387. /**
  43388. * Oculus Touch Controller
  43389. */
  43390. export class OculusTouchController extends WebVRController {
  43391. /**
  43392. * Base Url for the controller model.
  43393. */
  43394. static MODEL_BASE_URL: string;
  43395. /**
  43396. * File name for the left controller model.
  43397. */
  43398. static MODEL_LEFT_FILENAME: string;
  43399. /**
  43400. * File name for the right controller model.
  43401. */
  43402. static MODEL_RIGHT_FILENAME: string;
  43403. /**
  43404. * Fired when the secondary trigger on this controller is modified
  43405. */
  43406. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  43407. /**
  43408. * Fired when the thumb rest on this controller is modified
  43409. */
  43410. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  43411. /**
  43412. * Creates a new OculusTouchController from a gamepad
  43413. * @param vrGamepad the gamepad that the controller should be created from
  43414. */
  43415. constructor(vrGamepad: any);
  43416. /**
  43417. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43418. * @param scene scene in which to add meshes
  43419. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43420. */
  43421. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43422. /**
  43423. * Fired when the A button on this controller is modified
  43424. */
  43425. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43426. /**
  43427. * Fired when the B button on this controller is modified
  43428. */
  43429. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43430. /**
  43431. * Fired when the X button on this controller is modified
  43432. */
  43433. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43434. /**
  43435. * Fired when the Y button on this controller is modified
  43436. */
  43437. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43438. /**
  43439. * Called once for each button that changed state since the last frame
  43440. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  43441. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  43442. * 2) secondary trigger (same)
  43443. * 3) A (right) X (left), touch, pressed = value
  43444. * 4) B / Y
  43445. * 5) thumb rest
  43446. * @param buttonIdx Which button index changed
  43447. * @param state New state of the button
  43448. * @param changes Which properties on the state changed since last frame
  43449. */
  43450. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43451. }
  43452. }
  43453. declare module "babylonjs/Gamepads/Controllers/viveController" {
  43454. import { Scene } from "babylonjs/scene";
  43455. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43456. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43457. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43458. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43459. import { Observable } from "babylonjs/Misc/observable";
  43460. /**
  43461. * Vive Controller
  43462. */
  43463. export class ViveController extends WebVRController {
  43464. /**
  43465. * Base Url for the controller model.
  43466. */
  43467. static MODEL_BASE_URL: string;
  43468. /**
  43469. * File name for the controller model.
  43470. */
  43471. static MODEL_FILENAME: string;
  43472. /**
  43473. * Creates a new ViveController from a gamepad
  43474. * @param vrGamepad the gamepad that the controller should be created from
  43475. */
  43476. constructor(vrGamepad: any);
  43477. /**
  43478. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43479. * @param scene scene in which to add meshes
  43480. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43481. */
  43482. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43483. /**
  43484. * Fired when the left button on this controller is modified
  43485. */
  43486. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43487. /**
  43488. * Fired when the right button on this controller is modified
  43489. */
  43490. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43491. /**
  43492. * Fired when the menu button on this controller is modified
  43493. */
  43494. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43495. /**
  43496. * Called once for each button that changed state since the last frame
  43497. * Vive mapping:
  43498. * 0: touchpad
  43499. * 1: trigger
  43500. * 2: left AND right buttons
  43501. * 3: menu button
  43502. * @param buttonIdx Which button index changed
  43503. * @param state New state of the button
  43504. * @param changes Which properties on the state changed since last frame
  43505. */
  43506. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43507. }
  43508. }
  43509. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  43510. import { Observable } from "babylonjs/Misc/observable";
  43511. import { Scene } from "babylonjs/scene";
  43512. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43513. import { Ray } from "babylonjs/Culling/ray";
  43514. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43515. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43516. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43517. /**
  43518. * Defines the WindowsMotionController object that the state of the windows motion controller
  43519. */
  43520. export class WindowsMotionController extends WebVRController {
  43521. /**
  43522. * The base url used to load the left and right controller models
  43523. */
  43524. static MODEL_BASE_URL: string;
  43525. /**
  43526. * The name of the left controller model file
  43527. */
  43528. static MODEL_LEFT_FILENAME: string;
  43529. /**
  43530. * The name of the right controller model file
  43531. */
  43532. static MODEL_RIGHT_FILENAME: string;
  43533. /**
  43534. * The controller name prefix for this controller type
  43535. */
  43536. static readonly GAMEPAD_ID_PREFIX: string;
  43537. /**
  43538. * The controller id pattern for this controller type
  43539. */
  43540. private static readonly GAMEPAD_ID_PATTERN;
  43541. private _loadedMeshInfo;
  43542. private readonly _mapping;
  43543. /**
  43544. * Fired when the trackpad on this controller is clicked
  43545. */
  43546. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  43547. /**
  43548. * Fired when the trackpad on this controller is modified
  43549. */
  43550. onTrackpadValuesChangedObservable: Observable<StickValues>;
  43551. /**
  43552. * The current x and y values of this controller's trackpad
  43553. */
  43554. trackpad: StickValues;
  43555. /**
  43556. * Creates a new WindowsMotionController from a gamepad
  43557. * @param vrGamepad the gamepad that the controller should be created from
  43558. */
  43559. constructor(vrGamepad: any);
  43560. /**
  43561. * Fired when the trigger on this controller is modified
  43562. */
  43563. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43564. /**
  43565. * Fired when the menu button on this controller is modified
  43566. */
  43567. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43568. /**
  43569. * Fired when the grip button on this controller is modified
  43570. */
  43571. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43572. /**
  43573. * Fired when the thumbstick button on this controller is modified
  43574. */
  43575. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43576. /**
  43577. * Fired when the touchpad button on this controller is modified
  43578. */
  43579. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43580. /**
  43581. * Fired when the touchpad values on this controller are modified
  43582. */
  43583. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  43584. private _updateTrackpad;
  43585. /**
  43586. * Called once per frame by the engine.
  43587. */
  43588. update(): void;
  43589. /**
  43590. * Called once for each button that changed state since the last frame
  43591. * @param buttonIdx Which button index changed
  43592. * @param state New state of the button
  43593. * @param changes Which properties on the state changed since last frame
  43594. */
  43595. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43596. /**
  43597. * Moves the buttons on the controller mesh based on their current state
  43598. * @param buttonName the name of the button to move
  43599. * @param buttonValue the value of the button which determines the buttons new position
  43600. */
  43601. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  43602. /**
  43603. * Moves the axis on the controller mesh based on its current state
  43604. * @param axis the index of the axis
  43605. * @param axisValue the value of the axis which determines the meshes new position
  43606. * @hidden
  43607. */
  43608. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  43609. /**
  43610. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43611. * @param scene scene in which to add meshes
  43612. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43613. */
  43614. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  43615. /**
  43616. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  43617. * can be transformed by button presses and axes values, based on this._mapping.
  43618. *
  43619. * @param scene scene in which the meshes exist
  43620. * @param meshes list of meshes that make up the controller model to process
  43621. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  43622. */
  43623. private processModel;
  43624. private createMeshInfo;
  43625. /**
  43626. * Gets the ray of the controller in the direction the controller is pointing
  43627. * @param length the length the resulting ray should be
  43628. * @returns a ray in the direction the controller is pointing
  43629. */
  43630. getForwardRay(length?: number): Ray;
  43631. /**
  43632. * Disposes of the controller
  43633. */
  43634. dispose(): void;
  43635. }
  43636. }
  43637. declare module "babylonjs/Gamepads/Controllers/index" {
  43638. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  43639. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  43640. export * from "babylonjs/Gamepads/Controllers/genericController";
  43641. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  43642. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43643. export * from "babylonjs/Gamepads/Controllers/viveController";
  43644. export * from "babylonjs/Gamepads/Controllers/webVRController";
  43645. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  43646. }
  43647. declare module "babylonjs/Gamepads/index" {
  43648. export * from "babylonjs/Gamepads/Controllers/index";
  43649. export * from "babylonjs/Gamepads/gamepad";
  43650. export * from "babylonjs/Gamepads/gamepadManager";
  43651. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  43652. export * from "babylonjs/Gamepads/xboxGamepad";
  43653. }
  43654. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  43655. import { Observable } from "babylonjs/Misc/observable";
  43656. import { Nullable } from "babylonjs/types";
  43657. import { Vector3, Color3 } from "babylonjs/Maths/math";
  43658. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43659. import { Mesh } from "babylonjs/Meshes/mesh";
  43660. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  43661. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  43662. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43663. /**
  43664. * Single axis scale gizmo
  43665. */
  43666. export class AxisScaleGizmo extends Gizmo {
  43667. private _coloredMaterial;
  43668. /**
  43669. * Drag behavior responsible for the gizmos dragging interactions
  43670. */
  43671. dragBehavior: PointerDragBehavior;
  43672. private _pointerObserver;
  43673. /**
  43674. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43675. */
  43676. snapDistance: number;
  43677. /**
  43678. * Event that fires each time the gizmo snaps to a new location.
  43679. * * snapDistance is the the change in distance
  43680. */
  43681. onSnapObservable: Observable<{
  43682. snapDistance: number;
  43683. }>;
  43684. /**
  43685. * If the scaling operation should be done on all axis (default: false)
  43686. */
  43687. uniformScaling: boolean;
  43688. /**
  43689. * Creates an AxisScaleGizmo
  43690. * @param gizmoLayer The utility layer the gizmo will be added to
  43691. * @param dragAxis The axis which the gizmo will be able to scale on
  43692. * @param color The color of the gizmo
  43693. */
  43694. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  43695. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  43696. /**
  43697. * Disposes of the gizmo
  43698. */
  43699. dispose(): void;
  43700. /**
  43701. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  43702. * @param mesh The mesh to replace the default mesh of the gizmo
  43703. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  43704. */
  43705. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  43706. }
  43707. }
  43708. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  43709. import { Observable } from "babylonjs/Misc/observable";
  43710. import { Nullable } from "babylonjs/types";
  43711. import { Vector3, Color3 } from "babylonjs/Maths/math";
  43712. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43713. import { Mesh } from "babylonjs/Meshes/mesh";
  43714. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  43715. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43716. import "babylonjs/Meshes/Builders/boxBuilder";
  43717. /**
  43718. * Bounding box gizmo
  43719. */
  43720. export class BoundingBoxGizmo extends Gizmo {
  43721. private _lineBoundingBox;
  43722. private _rotateSpheresParent;
  43723. private _scaleBoxesParent;
  43724. private _boundingDimensions;
  43725. private _renderObserver;
  43726. private _pointerObserver;
  43727. private _scaleDragSpeed;
  43728. private _tmpQuaternion;
  43729. private _tmpVector;
  43730. private _tmpRotationMatrix;
  43731. /**
  43732. * 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)
  43733. */
  43734. ignoreChildren: boolean;
  43735. /**
  43736. * 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)
  43737. */
  43738. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  43739. /**
  43740. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  43741. */
  43742. rotationSphereSize: number;
  43743. /**
  43744. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  43745. */
  43746. scaleBoxSize: number;
  43747. /**
  43748. * 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)
  43749. */
  43750. fixedDragMeshScreenSize: boolean;
  43751. /**
  43752. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  43753. */
  43754. fixedDragMeshScreenSizeDistanceFactor: number;
  43755. /**
  43756. * Fired when a rotation sphere or scale box is dragged
  43757. */
  43758. onDragStartObservable: Observable<{}>;
  43759. /**
  43760. * Fired when a scale box is dragged
  43761. */
  43762. onScaleBoxDragObservable: Observable<{}>;
  43763. /**
  43764. * Fired when a scale box drag is ended
  43765. */
  43766. onScaleBoxDragEndObservable: Observable<{}>;
  43767. /**
  43768. * Fired when a rotation sphere is dragged
  43769. */
  43770. onRotationSphereDragObservable: Observable<{}>;
  43771. /**
  43772. * Fired when a rotation sphere drag is ended
  43773. */
  43774. onRotationSphereDragEndObservable: Observable<{}>;
  43775. /**
  43776. * 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)
  43777. */
  43778. scalePivot: Nullable<Vector3>;
  43779. private _anchorMesh;
  43780. private _existingMeshScale;
  43781. private _dragMesh;
  43782. private pointerDragBehavior;
  43783. private coloredMaterial;
  43784. private hoverColoredMaterial;
  43785. /**
  43786. * Sets the color of the bounding box gizmo
  43787. * @param color the color to set
  43788. */
  43789. setColor(color: Color3): void;
  43790. /**
  43791. * Creates an BoundingBoxGizmo
  43792. * @param gizmoLayer The utility layer the gizmo will be added to
  43793. * @param color The color of the gizmo
  43794. */
  43795. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  43796. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  43797. private _selectNode;
  43798. /**
  43799. * Updates the bounding box information for the Gizmo
  43800. */
  43801. updateBoundingBox(): void;
  43802. private _updateRotationSpheres;
  43803. private _updateScaleBoxes;
  43804. /**
  43805. * Enables rotation on the specified axis and disables rotation on the others
  43806. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  43807. */
  43808. setEnabledRotationAxis(axis: string): void;
  43809. /**
  43810. * Enables/disables scaling
  43811. * @param enable if scaling should be enabled
  43812. */
  43813. setEnabledScaling(enable: boolean): void;
  43814. private _updateDummy;
  43815. /**
  43816. * Enables a pointer drag behavior on the bounding box of the gizmo
  43817. */
  43818. enableDragBehavior(): void;
  43819. /**
  43820. * Disposes of the gizmo
  43821. */
  43822. dispose(): void;
  43823. /**
  43824. * 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)
  43825. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  43826. * @returns the bounding box mesh with the passed in mesh as a child
  43827. */
  43828. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  43829. /**
  43830. * CustomMeshes are not supported by this gizmo
  43831. * @param mesh The mesh to replace the default mesh of the gizmo
  43832. */
  43833. setCustomMesh(mesh: Mesh): void;
  43834. }
  43835. }
  43836. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  43837. import { Observable } from "babylonjs/Misc/observable";
  43838. import { Nullable } from "babylonjs/types";
  43839. import { Vector3, Color3 } from "babylonjs/Maths/math";
  43840. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43841. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  43842. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  43843. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43844. import "babylonjs/Meshes/Builders/linesBuilder";
  43845. /**
  43846. * Single plane rotation gizmo
  43847. */
  43848. export class PlaneRotationGizmo extends Gizmo {
  43849. /**
  43850. * Drag behavior responsible for the gizmos dragging interactions
  43851. */
  43852. dragBehavior: PointerDragBehavior;
  43853. private _pointerObserver;
  43854. /**
  43855. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  43856. */
  43857. snapDistance: number;
  43858. /**
  43859. * Event that fires each time the gizmo snaps to a new location.
  43860. * * snapDistance is the the change in distance
  43861. */
  43862. onSnapObservable: Observable<{
  43863. snapDistance: number;
  43864. }>;
  43865. /**
  43866. * Creates a PlaneRotationGizmo
  43867. * @param gizmoLayer The utility layer the gizmo will be added to
  43868. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  43869. * @param color The color of the gizmo
  43870. * @param tessellation Amount of tessellation to be used when creating rotation circles
  43871. */
  43872. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  43873. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  43874. /**
  43875. * Disposes of the gizmo
  43876. */
  43877. dispose(): void;
  43878. }
  43879. }
  43880. declare module "babylonjs/Gizmos/rotationGizmo" {
  43881. import { Observable } from "babylonjs/Misc/observable";
  43882. import { Nullable } from "babylonjs/types";
  43883. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43884. import { Mesh } from "babylonjs/Meshes/mesh";
  43885. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  43886. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  43887. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43888. /**
  43889. * Gizmo that enables rotating a mesh along 3 axis
  43890. */
  43891. export class RotationGizmo extends Gizmo {
  43892. /**
  43893. * Internal gizmo used for interactions on the x axis
  43894. */
  43895. xGizmo: PlaneRotationGizmo;
  43896. /**
  43897. * Internal gizmo used for interactions on the y axis
  43898. */
  43899. yGizmo: PlaneRotationGizmo;
  43900. /**
  43901. * Internal gizmo used for interactions on the z axis
  43902. */
  43903. zGizmo: PlaneRotationGizmo;
  43904. /** Fires an event when any of it's sub gizmos are dragged */
  43905. onDragStartObservable: Observable<{}>;
  43906. /** Fires an event when any of it's sub gizmos are released from dragging */
  43907. onDragEndObservable: Observable<{}>;
  43908. attachedMesh: Nullable<AbstractMesh>;
  43909. /**
  43910. * Creates a RotationGizmo
  43911. * @param gizmoLayer The utility layer the gizmo will be added to
  43912. * @param tessellation Amount of tessellation to be used when creating rotation circles
  43913. */
  43914. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  43915. updateGizmoRotationToMatchAttachedMesh: boolean;
  43916. /**
  43917. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43918. */
  43919. snapDistance: number;
  43920. /**
  43921. * Ratio for the scale of the gizmo (Default: 1)
  43922. */
  43923. scaleRatio: number;
  43924. /**
  43925. * Disposes of the gizmo
  43926. */
  43927. dispose(): void;
  43928. /**
  43929. * CustomMeshes are not supported by this gizmo
  43930. * @param mesh The mesh to replace the default mesh of the gizmo
  43931. */
  43932. setCustomMesh(mesh: Mesh): void;
  43933. }
  43934. }
  43935. declare module "babylonjs/Gizmos/positionGizmo" {
  43936. import { Observable } from "babylonjs/Misc/observable";
  43937. import { Nullable } from "babylonjs/types";
  43938. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43939. import { Mesh } from "babylonjs/Meshes/mesh";
  43940. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  43941. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  43942. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43943. /**
  43944. * Gizmo that enables dragging a mesh along 3 axis
  43945. */
  43946. export class PositionGizmo extends Gizmo {
  43947. /**
  43948. * Internal gizmo used for interactions on the x axis
  43949. */
  43950. xGizmo: AxisDragGizmo;
  43951. /**
  43952. * Internal gizmo used for interactions on the y axis
  43953. */
  43954. yGizmo: AxisDragGizmo;
  43955. /**
  43956. * Internal gizmo used for interactions on the z axis
  43957. */
  43958. zGizmo: AxisDragGizmo;
  43959. /** Fires an event when any of it's sub gizmos are dragged */
  43960. onDragStartObservable: Observable<{}>;
  43961. /** Fires an event when any of it's sub gizmos are released from dragging */
  43962. onDragEndObservable: Observable<{}>;
  43963. attachedMesh: Nullable<AbstractMesh>;
  43964. /**
  43965. * Creates a PositionGizmo
  43966. * @param gizmoLayer The utility layer the gizmo will be added to
  43967. */
  43968. constructor(gizmoLayer?: UtilityLayerRenderer);
  43969. updateGizmoRotationToMatchAttachedMesh: boolean;
  43970. /**
  43971. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43972. */
  43973. snapDistance: number;
  43974. /**
  43975. * Ratio for the scale of the gizmo (Default: 1)
  43976. */
  43977. scaleRatio: number;
  43978. /**
  43979. * Disposes of the gizmo
  43980. */
  43981. dispose(): void;
  43982. /**
  43983. * CustomMeshes are not supported by this gizmo
  43984. * @param mesh The mesh to replace the default mesh of the gizmo
  43985. */
  43986. setCustomMesh(mesh: Mesh): void;
  43987. }
  43988. }
  43989. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  43990. import { Scene } from "babylonjs/scene";
  43991. import { Color4, Vector4 } from "babylonjs/Maths/math";
  43992. import { Mesh } from "babylonjs/Meshes/mesh";
  43993. import { Nullable } from "babylonjs/types";
  43994. /**
  43995. * Class containing static functions to help procedurally build meshes
  43996. */
  43997. export class PolyhedronBuilder {
  43998. /**
  43999. * Creates a polyhedron mesh
  44000. * * 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
  44001. * * The parameter `size` (positive float, default 1) sets the polygon size
  44002. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  44003. * * 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`
  44004. * * 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
  44005. * * 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)`)
  44006. * * 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
  44007. * * 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
  44008. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  44009. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  44010. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44011. * @param name defines the name of the mesh
  44012. * @param options defines the options used to create the mesh
  44013. * @param scene defines the hosting scene
  44014. * @returns the polyhedron mesh
  44015. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  44016. */
  44017. static CreatePolyhedron(name: string, options: {
  44018. type?: number;
  44019. size?: number;
  44020. sizeX?: number;
  44021. sizeY?: number;
  44022. sizeZ?: number;
  44023. custom?: any;
  44024. faceUV?: Vector4[];
  44025. faceColors?: Color4[];
  44026. flat?: boolean;
  44027. updatable?: boolean;
  44028. sideOrientation?: number;
  44029. frontUVs?: Vector4;
  44030. backUVs?: Vector4;
  44031. }, scene?: Nullable<Scene>): Mesh;
  44032. }
  44033. }
  44034. declare module "babylonjs/Gizmos/scaleGizmo" {
  44035. import { Observable } from "babylonjs/Misc/observable";
  44036. import { Nullable } from "babylonjs/types";
  44037. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44038. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44039. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  44040. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44041. /**
  44042. * Gizmo that enables scaling a mesh along 3 axis
  44043. */
  44044. export class ScaleGizmo extends Gizmo {
  44045. /**
  44046. * Internal gizmo used for interactions on the x axis
  44047. */
  44048. xGizmo: AxisScaleGizmo;
  44049. /**
  44050. * Internal gizmo used for interactions on the y axis
  44051. */
  44052. yGizmo: AxisScaleGizmo;
  44053. /**
  44054. * Internal gizmo used for interactions on the z axis
  44055. */
  44056. zGizmo: AxisScaleGizmo;
  44057. /**
  44058. * Internal gizmo used to scale all axis equally
  44059. */
  44060. uniformScaleGizmo: AxisScaleGizmo;
  44061. /** Fires an event when any of it's sub gizmos are dragged */
  44062. onDragStartObservable: Observable<{}>;
  44063. /** Fires an event when any of it's sub gizmos are released from dragging */
  44064. onDragEndObservable: Observable<{}>;
  44065. attachedMesh: Nullable<AbstractMesh>;
  44066. /**
  44067. * Creates a ScaleGizmo
  44068. * @param gizmoLayer The utility layer the gizmo will be added to
  44069. */
  44070. constructor(gizmoLayer?: UtilityLayerRenderer);
  44071. updateGizmoRotationToMatchAttachedMesh: boolean;
  44072. /**
  44073. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44074. */
  44075. snapDistance: number;
  44076. /**
  44077. * Ratio for the scale of the gizmo (Default: 1)
  44078. */
  44079. scaleRatio: number;
  44080. /**
  44081. * Disposes of the gizmo
  44082. */
  44083. dispose(): void;
  44084. }
  44085. }
  44086. declare module "babylonjs/Gizmos/gizmoManager" {
  44087. import { Observable } from "babylonjs/Misc/observable";
  44088. import { Nullable } from "babylonjs/types";
  44089. import { Scene, IDisposable } from "babylonjs/scene";
  44090. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44091. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  44092. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  44093. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  44094. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  44095. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  44096. /**
  44097. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  44098. */
  44099. export class GizmoManager implements IDisposable {
  44100. private scene;
  44101. /**
  44102. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  44103. */
  44104. gizmos: {
  44105. positionGizmo: Nullable<PositionGizmo>;
  44106. rotationGizmo: Nullable<RotationGizmo>;
  44107. scaleGizmo: Nullable<ScaleGizmo>;
  44108. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  44109. };
  44110. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  44111. clearGizmoOnEmptyPointerEvent: boolean;
  44112. /** Fires an event when the manager is attached to a mesh */
  44113. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  44114. private _gizmosEnabled;
  44115. private _pointerObserver;
  44116. private _attachedMesh;
  44117. private _boundingBoxColor;
  44118. private _defaultUtilityLayer;
  44119. private _defaultKeepDepthUtilityLayer;
  44120. /**
  44121. * When bounding box gizmo is enabled, this can be used to track drag/end events
  44122. */
  44123. boundingBoxDragBehavior: SixDofDragBehavior;
  44124. /**
  44125. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  44126. */
  44127. attachableMeshes: Nullable<Array<AbstractMesh>>;
  44128. /**
  44129. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  44130. */
  44131. usePointerToAttachGizmos: boolean;
  44132. /**
  44133. * Instatiates a gizmo manager
  44134. * @param scene the scene to overlay the gizmos on top of
  44135. */
  44136. constructor(scene: Scene);
  44137. /**
  44138. * Attaches a set of gizmos to the specified mesh
  44139. * @param mesh The mesh the gizmo's should be attached to
  44140. */
  44141. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  44142. /**
  44143. * If the position gizmo is enabled
  44144. */
  44145. positionGizmoEnabled: boolean;
  44146. /**
  44147. * If the rotation gizmo is enabled
  44148. */
  44149. rotationGizmoEnabled: boolean;
  44150. /**
  44151. * If the scale gizmo is enabled
  44152. */
  44153. scaleGizmoEnabled: boolean;
  44154. /**
  44155. * If the boundingBox gizmo is enabled
  44156. */
  44157. boundingBoxGizmoEnabled: boolean;
  44158. /**
  44159. * Disposes of the gizmo manager
  44160. */
  44161. dispose(): void;
  44162. }
  44163. }
  44164. declare module "babylonjs/Lights/directionalLight" {
  44165. import { Camera } from "babylonjs/Cameras/camera";
  44166. import { Scene } from "babylonjs/scene";
  44167. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  44168. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44169. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  44170. import { Effect } from "babylonjs/Materials/effect";
  44171. /**
  44172. * A directional light is defined by a direction (what a surprise!).
  44173. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  44174. * 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.
  44175. * Documentation: https://doc.babylonjs.com/babylon101/lights
  44176. */
  44177. export class DirectionalLight extends ShadowLight {
  44178. private _shadowFrustumSize;
  44179. /**
  44180. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  44181. */
  44182. /**
  44183. * Specifies a fix frustum size for the shadow generation.
  44184. */
  44185. shadowFrustumSize: number;
  44186. private _shadowOrthoScale;
  44187. /**
  44188. * Gets the shadow projection scale against the optimal computed one.
  44189. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  44190. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  44191. */
  44192. /**
  44193. * Sets the shadow projection scale against the optimal computed one.
  44194. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  44195. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  44196. */
  44197. shadowOrthoScale: number;
  44198. /**
  44199. * Automatically compute the projection matrix to best fit (including all the casters)
  44200. * on each frame.
  44201. */
  44202. autoUpdateExtends: boolean;
  44203. private _orthoLeft;
  44204. private _orthoRight;
  44205. private _orthoTop;
  44206. private _orthoBottom;
  44207. /**
  44208. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  44209. * The directional light is emitted from everywhere in the given direction.
  44210. * It can cast shadows.
  44211. * Documentation : https://doc.babylonjs.com/babylon101/lights
  44212. * @param name The friendly name of the light
  44213. * @param direction The direction of the light
  44214. * @param scene The scene the light belongs to
  44215. */
  44216. constructor(name: string, direction: Vector3, scene: Scene);
  44217. /**
  44218. * Returns the string "DirectionalLight".
  44219. * @return The class name
  44220. */
  44221. getClassName(): string;
  44222. /**
  44223. * Returns the integer 1.
  44224. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  44225. */
  44226. getTypeID(): number;
  44227. /**
  44228. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  44229. * Returns the DirectionalLight Shadow projection matrix.
  44230. */
  44231. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  44232. /**
  44233. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  44234. * Returns the DirectionalLight Shadow projection matrix.
  44235. */
  44236. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  44237. /**
  44238. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  44239. * Returns the DirectionalLight Shadow projection matrix.
  44240. */
  44241. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  44242. protected _buildUniformLayout(): void;
  44243. /**
  44244. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  44245. * @param effect The effect to update
  44246. * @param lightIndex The index of the light in the effect to update
  44247. * @returns The directional light
  44248. */
  44249. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  44250. /**
  44251. * Gets the minZ used for shadow according to both the scene and the light.
  44252. *
  44253. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  44254. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  44255. * @param activeCamera The camera we are returning the min for
  44256. * @returns the depth min z
  44257. */
  44258. getDepthMinZ(activeCamera: Camera): number;
  44259. /**
  44260. * Gets the maxZ used for shadow according to both the scene and the light.
  44261. *
  44262. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  44263. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  44264. * @param activeCamera The camera we are returning the max for
  44265. * @returns the depth max z
  44266. */
  44267. getDepthMaxZ(activeCamera: Camera): number;
  44268. /**
  44269. * Prepares the list of defines specific to the light type.
  44270. * @param defines the list of defines
  44271. * @param lightIndex defines the index of the light for the effect
  44272. */
  44273. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  44274. }
  44275. }
  44276. declare module "babylonjs/Meshes/Builders/hemisphereBuilder" {
  44277. import { Mesh } from "babylonjs/Meshes/mesh";
  44278. /**
  44279. * Class containing static functions to help procedurally build meshes
  44280. */
  44281. export class HemisphereBuilder {
  44282. /**
  44283. * Creates a hemisphere mesh
  44284. * @param name defines the name of the mesh
  44285. * @param options defines the options used to create the mesh
  44286. * @param scene defines the hosting scene
  44287. * @returns the hemisphere mesh
  44288. */
  44289. static CreateHemisphere(name: string, options: {
  44290. segments?: number;
  44291. diameter?: number;
  44292. sideOrientation?: number;
  44293. }, scene: any): Mesh;
  44294. }
  44295. }
  44296. declare module "babylonjs/Lights/spotLight" {
  44297. import { Nullable } from "babylonjs/types";
  44298. import { Scene } from "babylonjs/scene";
  44299. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  44300. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44301. import { Effect } from "babylonjs/Materials/effect";
  44302. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  44303. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  44304. /**
  44305. * A spot light is defined by a position, a direction, an angle, and an exponent.
  44306. * These values define a cone of light starting from the position, emitting toward the direction.
  44307. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  44308. * and the exponent defines the speed of the decay of the light with distance (reach).
  44309. * Documentation: https://doc.babylonjs.com/babylon101/lights
  44310. */
  44311. export class SpotLight extends ShadowLight {
  44312. private _angle;
  44313. private _innerAngle;
  44314. private _cosHalfAngle;
  44315. private _lightAngleScale;
  44316. private _lightAngleOffset;
  44317. /**
  44318. * Gets the cone angle of the spot light in Radians.
  44319. */
  44320. /**
  44321. * Sets the cone angle of the spot light in Radians.
  44322. */
  44323. angle: number;
  44324. /**
  44325. * Only used in gltf falloff mode, this defines the angle where
  44326. * the directional falloff will start before cutting at angle which could be seen
  44327. * as outer angle.
  44328. */
  44329. /**
  44330. * Only used in gltf falloff mode, this defines the angle where
  44331. * the directional falloff will start before cutting at angle which could be seen
  44332. * as outer angle.
  44333. */
  44334. innerAngle: number;
  44335. private _shadowAngleScale;
  44336. /**
  44337. * Allows scaling the angle of the light for shadow generation only.
  44338. */
  44339. /**
  44340. * Allows scaling the angle of the light for shadow generation only.
  44341. */
  44342. shadowAngleScale: number;
  44343. /**
  44344. * The light decay speed with the distance from the emission spot.
  44345. */
  44346. exponent: number;
  44347. private _projectionTextureMatrix;
  44348. /**
  44349. * Allows reading the projecton texture
  44350. */
  44351. readonly projectionTextureMatrix: Matrix;
  44352. protected _projectionTextureLightNear: number;
  44353. /**
  44354. * Gets the near clip of the Spotlight for texture projection.
  44355. */
  44356. /**
  44357. * Sets the near clip of the Spotlight for texture projection.
  44358. */
  44359. projectionTextureLightNear: number;
  44360. protected _projectionTextureLightFar: number;
  44361. /**
  44362. * Gets the far clip of the Spotlight for texture projection.
  44363. */
  44364. /**
  44365. * Sets the far clip of the Spotlight for texture projection.
  44366. */
  44367. projectionTextureLightFar: number;
  44368. protected _projectionTextureUpDirection: Vector3;
  44369. /**
  44370. * Gets the Up vector of the Spotlight for texture projection.
  44371. */
  44372. /**
  44373. * Sets the Up vector of the Spotlight for texture projection.
  44374. */
  44375. projectionTextureUpDirection: Vector3;
  44376. private _projectionTexture;
  44377. /**
  44378. * Gets the projection texture of the light.
  44379. */
  44380. /**
  44381. * Sets the projection texture of the light.
  44382. */
  44383. projectionTexture: Nullable<BaseTexture>;
  44384. private _projectionTextureViewLightDirty;
  44385. private _projectionTextureProjectionLightDirty;
  44386. private _projectionTextureDirty;
  44387. private _projectionTextureViewTargetVector;
  44388. private _projectionTextureViewLightMatrix;
  44389. private _projectionTextureProjectionLightMatrix;
  44390. private _projectionTextureScalingMatrix;
  44391. /**
  44392. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  44393. * It can cast shadows.
  44394. * Documentation : https://doc.babylonjs.com/babylon101/lights
  44395. * @param name The light friendly name
  44396. * @param position The position of the spot light in the scene
  44397. * @param direction The direction of the light in the scene
  44398. * @param angle The cone angle of the light in Radians
  44399. * @param exponent The light decay speed with the distance from the emission spot
  44400. * @param scene The scene the lights belongs to
  44401. */
  44402. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  44403. /**
  44404. * Returns the string "SpotLight".
  44405. * @returns the class name
  44406. */
  44407. getClassName(): string;
  44408. /**
  44409. * Returns the integer 2.
  44410. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  44411. */
  44412. getTypeID(): number;
  44413. /**
  44414. * Overrides the direction setter to recompute the projection texture view light Matrix.
  44415. */
  44416. protected _setDirection(value: Vector3): void;
  44417. /**
  44418. * Overrides the position setter to recompute the projection texture view light Matrix.
  44419. */
  44420. protected _setPosition(value: Vector3): void;
  44421. /**
  44422. * 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.
  44423. * Returns the SpotLight.
  44424. */
  44425. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  44426. protected _computeProjectionTextureViewLightMatrix(): void;
  44427. protected _computeProjectionTextureProjectionLightMatrix(): void;
  44428. /**
  44429. * Main function for light texture projection matrix computing.
  44430. */
  44431. protected _computeProjectionTextureMatrix(): void;
  44432. protected _buildUniformLayout(): void;
  44433. private _computeAngleValues;
  44434. /**
  44435. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  44436. * @param effect The effect to update
  44437. * @param lightIndex The index of the light in the effect to update
  44438. * @returns The spot light
  44439. */
  44440. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  44441. /**
  44442. * Disposes the light and the associated resources.
  44443. */
  44444. dispose(): void;
  44445. /**
  44446. * Prepares the list of defines specific to the light type.
  44447. * @param defines the list of defines
  44448. * @param lightIndex defines the index of the light for the effect
  44449. */
  44450. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  44451. }
  44452. }
  44453. declare module "babylonjs/Gizmos/lightGizmo" {
  44454. import { Nullable } from "babylonjs/types";
  44455. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44456. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44457. import { Light } from "babylonjs/Lights/light";
  44458. /**
  44459. * Gizmo that enables viewing a light
  44460. */
  44461. export class LightGizmo extends Gizmo {
  44462. private _lightMesh;
  44463. private _material;
  44464. /**
  44465. * Creates a LightGizmo
  44466. * @param gizmoLayer The utility layer the gizmo will be added to
  44467. */
  44468. constructor(gizmoLayer?: UtilityLayerRenderer);
  44469. private _light;
  44470. /**
  44471. * The light that the gizmo is attached to
  44472. */
  44473. light: Nullable<Light>;
  44474. /**
  44475. * @hidden
  44476. * Updates the gizmo to match the attached mesh's position/rotation
  44477. */
  44478. protected _update(): void;
  44479. private static _Scale;
  44480. /**
  44481. * Creates the lines for a light mesh
  44482. */
  44483. private static _createLightLines;
  44484. private static _CreateHemisphericLightMesh;
  44485. private static _CreatePointLightMesh;
  44486. private static _CreateSpotLightMesh;
  44487. private static _CreateDirectionalLightMesh;
  44488. }
  44489. }
  44490. declare module "babylonjs/Gizmos/index" {
  44491. export * from "babylonjs/Gizmos/axisDragGizmo";
  44492. export * from "babylonjs/Gizmos/axisScaleGizmo";
  44493. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  44494. export * from "babylonjs/Gizmos/gizmo";
  44495. export * from "babylonjs/Gizmos/gizmoManager";
  44496. export * from "babylonjs/Gizmos/planeRotationGizmo";
  44497. export * from "babylonjs/Gizmos/positionGizmo";
  44498. export * from "babylonjs/Gizmos/rotationGizmo";
  44499. export * from "babylonjs/Gizmos/scaleGizmo";
  44500. export * from "babylonjs/Gizmos/lightGizmo";
  44501. }
  44502. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  44503. /** @hidden */
  44504. export var backgroundFragmentDeclaration: {
  44505. name: string;
  44506. shader: string;
  44507. };
  44508. }
  44509. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  44510. /** @hidden */
  44511. export var backgroundUboDeclaration: {
  44512. name: string;
  44513. shader: string;
  44514. };
  44515. }
  44516. declare module "babylonjs/Shaders/background.fragment" {
  44517. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  44518. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  44519. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  44520. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  44521. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  44522. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  44523. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  44524. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  44525. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  44526. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  44527. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  44528. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  44529. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  44530. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  44531. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  44532. /** @hidden */
  44533. export var backgroundPixelShader: {
  44534. name: string;
  44535. shader: string;
  44536. };
  44537. }
  44538. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  44539. /** @hidden */
  44540. export var backgroundVertexDeclaration: {
  44541. name: string;
  44542. shader: string;
  44543. };
  44544. }
  44545. declare module "babylonjs/Shaders/background.vertex" {
  44546. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  44547. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  44548. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  44549. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  44550. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  44551. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  44552. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  44553. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  44554. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  44555. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  44556. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  44557. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  44558. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  44559. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  44560. /** @hidden */
  44561. export var backgroundVertexShader: {
  44562. name: string;
  44563. shader: string;
  44564. };
  44565. }
  44566. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  44567. import { Nullable, int, float } from "babylonjs/types";
  44568. import { Scene } from "babylonjs/scene";
  44569. import { Matrix, Vector3, Color3 } from "babylonjs/Maths/math";
  44570. import { SubMesh } from "babylonjs/Meshes/subMesh";
  44571. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44572. import { Mesh } from "babylonjs/Meshes/mesh";
  44573. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  44574. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  44575. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  44576. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  44577. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  44578. import "babylonjs/Shaders/background.fragment";
  44579. import "babylonjs/Shaders/background.vertex";
  44580. /**
  44581. * Background material used to create an efficient environement around your scene.
  44582. */
  44583. export class BackgroundMaterial extends PushMaterial {
  44584. /**
  44585. * Standard reflectance value at parallel view angle.
  44586. */
  44587. static StandardReflectance0: number;
  44588. /**
  44589. * Standard reflectance value at grazing angle.
  44590. */
  44591. static StandardReflectance90: number;
  44592. protected _primaryColor: Color3;
  44593. /**
  44594. * Key light Color (multiply against the environement texture)
  44595. */
  44596. primaryColor: Color3;
  44597. protected __perceptualColor: Nullable<Color3>;
  44598. /**
  44599. * Experimental Internal Use Only.
  44600. *
  44601. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  44602. * This acts as a helper to set the primary color to a more "human friendly" value.
  44603. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  44604. * output color as close as possible from the chosen value.
  44605. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  44606. * part of lighting setup.)
  44607. */
  44608. _perceptualColor: Nullable<Color3>;
  44609. protected _primaryColorShadowLevel: float;
  44610. /**
  44611. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  44612. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  44613. */
  44614. primaryColorShadowLevel: float;
  44615. protected _primaryColorHighlightLevel: float;
  44616. /**
  44617. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  44618. * The primary color is used at the level chosen to define what the white area would look.
  44619. */
  44620. primaryColorHighlightLevel: float;
  44621. protected _reflectionTexture: Nullable<BaseTexture>;
  44622. /**
  44623. * Reflection Texture used in the material.
  44624. * Should be author in a specific way for the best result (refer to the documentation).
  44625. */
  44626. reflectionTexture: Nullable<BaseTexture>;
  44627. protected _reflectionBlur: float;
  44628. /**
  44629. * Reflection Texture level of blur.
  44630. *
  44631. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  44632. * texture twice.
  44633. */
  44634. reflectionBlur: float;
  44635. protected _diffuseTexture: Nullable<BaseTexture>;
  44636. /**
  44637. * Diffuse Texture used in the material.
  44638. * Should be author in a specific way for the best result (refer to the documentation).
  44639. */
  44640. diffuseTexture: Nullable<BaseTexture>;
  44641. protected _shadowLights: Nullable<IShadowLight[]>;
  44642. /**
  44643. * Specify the list of lights casting shadow on the material.
  44644. * All scene shadow lights will be included if null.
  44645. */
  44646. shadowLights: Nullable<IShadowLight[]>;
  44647. protected _shadowLevel: float;
  44648. /**
  44649. * Helps adjusting the shadow to a softer level if required.
  44650. * 0 means black shadows and 1 means no shadows.
  44651. */
  44652. shadowLevel: float;
  44653. protected _sceneCenter: Vector3;
  44654. /**
  44655. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  44656. * It is usually zero but might be interesting to modify according to your setup.
  44657. */
  44658. sceneCenter: Vector3;
  44659. protected _opacityFresnel: boolean;
  44660. /**
  44661. * This helps specifying that the material is falling off to the sky box at grazing angle.
  44662. * This helps ensuring a nice transition when the camera goes under the ground.
  44663. */
  44664. opacityFresnel: boolean;
  44665. protected _reflectionFresnel: boolean;
  44666. /**
  44667. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  44668. * This helps adding a mirror texture on the ground.
  44669. */
  44670. reflectionFresnel: boolean;
  44671. protected _reflectionFalloffDistance: number;
  44672. /**
  44673. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  44674. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  44675. */
  44676. reflectionFalloffDistance: number;
  44677. protected _reflectionAmount: number;
  44678. /**
  44679. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  44680. */
  44681. reflectionAmount: number;
  44682. protected _reflectionReflectance0: number;
  44683. /**
  44684. * This specifies the weight of the reflection at grazing angle.
  44685. */
  44686. reflectionReflectance0: number;
  44687. protected _reflectionReflectance90: number;
  44688. /**
  44689. * This specifies the weight of the reflection at a perpendicular point of view.
  44690. */
  44691. reflectionReflectance90: number;
  44692. /**
  44693. * Sets the reflection reflectance fresnel values according to the default standard
  44694. * empirically know to work well :-)
  44695. */
  44696. reflectionStandardFresnelWeight: number;
  44697. protected _useRGBColor: boolean;
  44698. /**
  44699. * Helps to directly use the maps channels instead of their level.
  44700. */
  44701. useRGBColor: boolean;
  44702. protected _enableNoise: boolean;
  44703. /**
  44704. * This helps reducing the banding effect that could occur on the background.
  44705. */
  44706. enableNoise: boolean;
  44707. /**
  44708. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  44709. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  44710. * Recommended to be keep at 1.0 except for special cases.
  44711. */
  44712. fovMultiplier: number;
  44713. private _fovMultiplier;
  44714. /**
  44715. * Enable the FOV adjustment feature controlled by fovMultiplier.
  44716. */
  44717. useEquirectangularFOV: boolean;
  44718. private _maxSimultaneousLights;
  44719. /**
  44720. * Number of Simultaneous lights allowed on the material.
  44721. */
  44722. maxSimultaneousLights: int;
  44723. /**
  44724. * Default configuration related to image processing available in the Background Material.
  44725. */
  44726. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  44727. /**
  44728. * Keep track of the image processing observer to allow dispose and replace.
  44729. */
  44730. private _imageProcessingObserver;
  44731. /**
  44732. * Attaches a new image processing configuration to the PBR Material.
  44733. * @param configuration (if null the scene configuration will be use)
  44734. */
  44735. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  44736. /**
  44737. * Gets the image processing configuration used either in this material.
  44738. */
  44739. /**
  44740. * Sets the Default image processing configuration used either in the this material.
  44741. *
  44742. * If sets to null, the scene one is in use.
  44743. */
  44744. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  44745. /**
  44746. * Gets wether the color curves effect is enabled.
  44747. */
  44748. /**
  44749. * Sets wether the color curves effect is enabled.
  44750. */
  44751. cameraColorCurvesEnabled: boolean;
  44752. /**
  44753. * Gets wether the color grading effect is enabled.
  44754. */
  44755. /**
  44756. * Gets wether the color grading effect is enabled.
  44757. */
  44758. cameraColorGradingEnabled: boolean;
  44759. /**
  44760. * Gets wether tonemapping is enabled or not.
  44761. */
  44762. /**
  44763. * Sets wether tonemapping is enabled or not
  44764. */
  44765. cameraToneMappingEnabled: boolean;
  44766. /**
  44767. * The camera exposure used on this material.
  44768. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  44769. * This corresponds to a photographic exposure.
  44770. */
  44771. /**
  44772. * The camera exposure used on this material.
  44773. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  44774. * This corresponds to a photographic exposure.
  44775. */
  44776. cameraExposure: float;
  44777. /**
  44778. * Gets The camera contrast used on this material.
  44779. */
  44780. /**
  44781. * Sets The camera contrast used on this material.
  44782. */
  44783. cameraContrast: float;
  44784. /**
  44785. * Gets the Color Grading 2D Lookup Texture.
  44786. */
  44787. /**
  44788. * Sets the Color Grading 2D Lookup Texture.
  44789. */
  44790. cameraColorGradingTexture: Nullable<BaseTexture>;
  44791. /**
  44792. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  44793. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  44794. * 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;
  44795. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  44796. */
  44797. /**
  44798. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  44799. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  44800. * 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;
  44801. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  44802. */
  44803. cameraColorCurves: Nullable<ColorCurves>;
  44804. /**
  44805. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  44806. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  44807. */
  44808. switchToBGR: boolean;
  44809. private _renderTargets;
  44810. private _reflectionControls;
  44811. private _white;
  44812. private _primaryShadowColor;
  44813. private _primaryHighlightColor;
  44814. /**
  44815. * Instantiates a Background Material in the given scene
  44816. * @param name The friendly name of the material
  44817. * @param scene The scene to add the material to
  44818. */
  44819. constructor(name: string, scene: Scene);
  44820. /**
  44821. * Gets a boolean indicating that current material needs to register RTT
  44822. */
  44823. readonly hasRenderTargetTextures: boolean;
  44824. /**
  44825. * The entire material has been created in order to prevent overdraw.
  44826. * @returns false
  44827. */
  44828. needAlphaTesting(): boolean;
  44829. /**
  44830. * The entire material has been created in order to prevent overdraw.
  44831. * @returns true if blending is enable
  44832. */
  44833. needAlphaBlending(): boolean;
  44834. /**
  44835. * Checks wether the material is ready to be rendered for a given mesh.
  44836. * @param mesh The mesh to render
  44837. * @param subMesh The submesh to check against
  44838. * @param useInstances Specify wether or not the material is used with instances
  44839. * @returns true if all the dependencies are ready (Textures, Effects...)
  44840. */
  44841. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  44842. /**
  44843. * Compute the primary color according to the chosen perceptual color.
  44844. */
  44845. private _computePrimaryColorFromPerceptualColor;
  44846. /**
  44847. * Compute the highlights and shadow colors according to their chosen levels.
  44848. */
  44849. private _computePrimaryColors;
  44850. /**
  44851. * Build the uniform buffer used in the material.
  44852. */
  44853. buildUniformLayout(): void;
  44854. /**
  44855. * Unbind the material.
  44856. */
  44857. unbind(): void;
  44858. /**
  44859. * Bind only the world matrix to the material.
  44860. * @param world The world matrix to bind.
  44861. */
  44862. bindOnlyWorldMatrix(world: Matrix): void;
  44863. /**
  44864. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  44865. * @param world The world matrix to bind.
  44866. * @param subMesh The submesh to bind for.
  44867. */
  44868. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  44869. /**
  44870. * Dispose the material.
  44871. * @param forceDisposeEffect Force disposal of the associated effect.
  44872. * @param forceDisposeTextures Force disposal of the associated textures.
  44873. */
  44874. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  44875. /**
  44876. * Clones the material.
  44877. * @param name The cloned name.
  44878. * @returns The cloned material.
  44879. */
  44880. clone(name: string): BackgroundMaterial;
  44881. /**
  44882. * Serializes the current material to its JSON representation.
  44883. * @returns The JSON representation.
  44884. */
  44885. serialize(): any;
  44886. /**
  44887. * Gets the class name of the material
  44888. * @returns "BackgroundMaterial"
  44889. */
  44890. getClassName(): string;
  44891. /**
  44892. * Parse a JSON input to create back a background material.
  44893. * @param source The JSON data to parse
  44894. * @param scene The scene to create the parsed material in
  44895. * @param rootUrl The root url of the assets the material depends upon
  44896. * @returns the instantiated BackgroundMaterial.
  44897. */
  44898. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  44899. }
  44900. }
  44901. declare module "babylonjs/Helpers/environmentHelper" {
  44902. import { Observable } from "babylonjs/Misc/observable";
  44903. import { Nullable } from "babylonjs/types";
  44904. import { Scene } from "babylonjs/scene";
  44905. import { Vector3, Color3 } from "babylonjs/Maths/math";
  44906. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44907. import { Mesh } from "babylonjs/Meshes/mesh";
  44908. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  44909. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  44910. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  44911. import "babylonjs/Meshes/Builders/planeBuilder";
  44912. import "babylonjs/Meshes/Builders/boxBuilder";
  44913. /**
  44914. * Represents the different options available during the creation of
  44915. * a Environment helper.
  44916. *
  44917. * This can control the default ground, skybox and image processing setup of your scene.
  44918. */
  44919. export interface IEnvironmentHelperOptions {
  44920. /**
  44921. * Specifies wether or not to create a ground.
  44922. * True by default.
  44923. */
  44924. createGround: boolean;
  44925. /**
  44926. * Specifies the ground size.
  44927. * 15 by default.
  44928. */
  44929. groundSize: number;
  44930. /**
  44931. * The texture used on the ground for the main color.
  44932. * Comes from the BabylonJS CDN by default.
  44933. *
  44934. * Remarks: Can be either a texture or a url.
  44935. */
  44936. groundTexture: string | BaseTexture;
  44937. /**
  44938. * The color mixed in the ground texture by default.
  44939. * BabylonJS clearColor by default.
  44940. */
  44941. groundColor: Color3;
  44942. /**
  44943. * Specifies the ground opacity.
  44944. * 1 by default.
  44945. */
  44946. groundOpacity: number;
  44947. /**
  44948. * Enables the ground to receive shadows.
  44949. * True by default.
  44950. */
  44951. enableGroundShadow: boolean;
  44952. /**
  44953. * Helps preventing the shadow to be fully black on the ground.
  44954. * 0.5 by default.
  44955. */
  44956. groundShadowLevel: number;
  44957. /**
  44958. * Creates a mirror texture attach to the ground.
  44959. * false by default.
  44960. */
  44961. enableGroundMirror: boolean;
  44962. /**
  44963. * Specifies the ground mirror size ratio.
  44964. * 0.3 by default as the default kernel is 64.
  44965. */
  44966. groundMirrorSizeRatio: number;
  44967. /**
  44968. * Specifies the ground mirror blur kernel size.
  44969. * 64 by default.
  44970. */
  44971. groundMirrorBlurKernel: number;
  44972. /**
  44973. * Specifies the ground mirror visibility amount.
  44974. * 1 by default
  44975. */
  44976. groundMirrorAmount: number;
  44977. /**
  44978. * Specifies the ground mirror reflectance weight.
  44979. * This uses the standard weight of the background material to setup the fresnel effect
  44980. * of the mirror.
  44981. * 1 by default.
  44982. */
  44983. groundMirrorFresnelWeight: number;
  44984. /**
  44985. * Specifies the ground mirror Falloff distance.
  44986. * This can helps reducing the size of the reflection.
  44987. * 0 by Default.
  44988. */
  44989. groundMirrorFallOffDistance: number;
  44990. /**
  44991. * Specifies the ground mirror texture type.
  44992. * Unsigned Int by Default.
  44993. */
  44994. groundMirrorTextureType: number;
  44995. /**
  44996. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  44997. * the shown objects.
  44998. */
  44999. groundYBias: number;
  45000. /**
  45001. * Specifies wether or not to create a skybox.
  45002. * True by default.
  45003. */
  45004. createSkybox: boolean;
  45005. /**
  45006. * Specifies the skybox size.
  45007. * 20 by default.
  45008. */
  45009. skyboxSize: number;
  45010. /**
  45011. * The texture used on the skybox for the main color.
  45012. * Comes from the BabylonJS CDN by default.
  45013. *
  45014. * Remarks: Can be either a texture or a url.
  45015. */
  45016. skyboxTexture: string | BaseTexture;
  45017. /**
  45018. * The color mixed in the skybox texture by default.
  45019. * BabylonJS clearColor by default.
  45020. */
  45021. skyboxColor: Color3;
  45022. /**
  45023. * The background rotation around the Y axis of the scene.
  45024. * This helps aligning the key lights of your scene with the background.
  45025. * 0 by default.
  45026. */
  45027. backgroundYRotation: number;
  45028. /**
  45029. * Compute automatically the size of the elements to best fit with the scene.
  45030. */
  45031. sizeAuto: boolean;
  45032. /**
  45033. * Default position of the rootMesh if autoSize is not true.
  45034. */
  45035. rootPosition: Vector3;
  45036. /**
  45037. * Sets up the image processing in the scene.
  45038. * true by default.
  45039. */
  45040. setupImageProcessing: boolean;
  45041. /**
  45042. * The texture used as your environment texture in the scene.
  45043. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  45044. *
  45045. * Remarks: Can be either a texture or a url.
  45046. */
  45047. environmentTexture: string | BaseTexture;
  45048. /**
  45049. * The value of the exposure to apply to the scene.
  45050. * 0.6 by default if setupImageProcessing is true.
  45051. */
  45052. cameraExposure: number;
  45053. /**
  45054. * The value of the contrast to apply to the scene.
  45055. * 1.6 by default if setupImageProcessing is true.
  45056. */
  45057. cameraContrast: number;
  45058. /**
  45059. * Specifies wether or not tonemapping should be enabled in the scene.
  45060. * true by default if setupImageProcessing is true.
  45061. */
  45062. toneMappingEnabled: boolean;
  45063. }
  45064. /**
  45065. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  45066. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  45067. * It also helps with the default setup of your imageProcessing configuration.
  45068. */
  45069. export class EnvironmentHelper {
  45070. /**
  45071. * Default ground texture URL.
  45072. */
  45073. private static _groundTextureCDNUrl;
  45074. /**
  45075. * Default skybox texture URL.
  45076. */
  45077. private static _skyboxTextureCDNUrl;
  45078. /**
  45079. * Default environment texture URL.
  45080. */
  45081. private static _environmentTextureCDNUrl;
  45082. /**
  45083. * Creates the default options for the helper.
  45084. */
  45085. private static _getDefaultOptions;
  45086. private _rootMesh;
  45087. /**
  45088. * Gets the root mesh created by the helper.
  45089. */
  45090. readonly rootMesh: Mesh;
  45091. private _skybox;
  45092. /**
  45093. * Gets the skybox created by the helper.
  45094. */
  45095. readonly skybox: Nullable<Mesh>;
  45096. private _skyboxTexture;
  45097. /**
  45098. * Gets the skybox texture created by the helper.
  45099. */
  45100. readonly skyboxTexture: Nullable<BaseTexture>;
  45101. private _skyboxMaterial;
  45102. /**
  45103. * Gets the skybox material created by the helper.
  45104. */
  45105. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  45106. private _ground;
  45107. /**
  45108. * Gets the ground mesh created by the helper.
  45109. */
  45110. readonly ground: Nullable<Mesh>;
  45111. private _groundTexture;
  45112. /**
  45113. * Gets the ground texture created by the helper.
  45114. */
  45115. readonly groundTexture: Nullable<BaseTexture>;
  45116. private _groundMirror;
  45117. /**
  45118. * Gets the ground mirror created by the helper.
  45119. */
  45120. readonly groundMirror: Nullable<MirrorTexture>;
  45121. /**
  45122. * Gets the ground mirror render list to helps pushing the meshes
  45123. * you wish in the ground reflection.
  45124. */
  45125. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  45126. private _groundMaterial;
  45127. /**
  45128. * Gets the ground material created by the helper.
  45129. */
  45130. readonly groundMaterial: Nullable<BackgroundMaterial>;
  45131. /**
  45132. * Stores the creation options.
  45133. */
  45134. private readonly _scene;
  45135. private _options;
  45136. /**
  45137. * This observable will be notified with any error during the creation of the environment,
  45138. * mainly texture creation errors.
  45139. */
  45140. onErrorObservable: Observable<{
  45141. message?: string;
  45142. exception?: any;
  45143. }>;
  45144. /**
  45145. * constructor
  45146. * @param options Defines the options we want to customize the helper
  45147. * @param scene The scene to add the material to
  45148. */
  45149. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  45150. /**
  45151. * Updates the background according to the new options
  45152. * @param options
  45153. */
  45154. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  45155. /**
  45156. * Sets the primary color of all the available elements.
  45157. * @param color the main color to affect to the ground and the background
  45158. */
  45159. setMainColor(color: Color3): void;
  45160. /**
  45161. * Setup the image processing according to the specified options.
  45162. */
  45163. private _setupImageProcessing;
  45164. /**
  45165. * Setup the environment texture according to the specified options.
  45166. */
  45167. private _setupEnvironmentTexture;
  45168. /**
  45169. * Setup the background according to the specified options.
  45170. */
  45171. private _setupBackground;
  45172. /**
  45173. * Get the scene sizes according to the setup.
  45174. */
  45175. private _getSceneSize;
  45176. /**
  45177. * Setup the ground according to the specified options.
  45178. */
  45179. private _setupGround;
  45180. /**
  45181. * Setup the ground material according to the specified options.
  45182. */
  45183. private _setupGroundMaterial;
  45184. /**
  45185. * Setup the ground diffuse texture according to the specified options.
  45186. */
  45187. private _setupGroundDiffuseTexture;
  45188. /**
  45189. * Setup the ground mirror texture according to the specified options.
  45190. */
  45191. private _setupGroundMirrorTexture;
  45192. /**
  45193. * Setup the ground to receive the mirror texture.
  45194. */
  45195. private _setupMirrorInGroundMaterial;
  45196. /**
  45197. * Setup the skybox according to the specified options.
  45198. */
  45199. private _setupSkybox;
  45200. /**
  45201. * Setup the skybox material according to the specified options.
  45202. */
  45203. private _setupSkyboxMaterial;
  45204. /**
  45205. * Setup the skybox reflection texture according to the specified options.
  45206. */
  45207. private _setupSkyboxReflectionTexture;
  45208. private _errorHandler;
  45209. /**
  45210. * Dispose all the elements created by the Helper.
  45211. */
  45212. dispose(): void;
  45213. }
  45214. }
  45215. declare module "babylonjs/Helpers/photoDome" {
  45216. import { Observable } from "babylonjs/Misc/observable";
  45217. import { Nullable } from "babylonjs/types";
  45218. import { Scene } from "babylonjs/scene";
  45219. import { TransformNode } from "babylonjs/Meshes/transformNode";
  45220. import { Mesh } from "babylonjs/Meshes/mesh";
  45221. import { Texture } from "babylonjs/Materials/Textures/texture";
  45222. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  45223. import "babylonjs/Meshes/Builders/sphereBuilder";
  45224. /**
  45225. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  45226. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  45227. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  45228. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  45229. */
  45230. export class PhotoDome extends TransformNode {
  45231. private _useDirectMapping;
  45232. /**
  45233. * The texture being displayed on the sphere
  45234. */
  45235. protected _photoTexture: Texture;
  45236. /**
  45237. * Gets or sets the texture being displayed on the sphere
  45238. */
  45239. photoTexture: Texture;
  45240. /**
  45241. * Observable raised when an error occured while loading the 360 image
  45242. */
  45243. onLoadErrorObservable: Observable<string>;
  45244. /**
  45245. * The skybox material
  45246. */
  45247. protected _material: BackgroundMaterial;
  45248. /**
  45249. * The surface used for the skybox
  45250. */
  45251. protected _mesh: Mesh;
  45252. /**
  45253. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  45254. * Also see the options.resolution property.
  45255. */
  45256. fovMultiplier: number;
  45257. /**
  45258. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  45259. * @param name Element's name, child elements will append suffixes for their own names.
  45260. * @param urlsOfPhoto defines the url of the photo to display
  45261. * @param options defines an object containing optional or exposed sub element properties
  45262. * @param onError defines a callback called when an error occured while loading the texture
  45263. */
  45264. constructor(name: string, urlOfPhoto: string, options: {
  45265. resolution?: number;
  45266. size?: number;
  45267. useDirectMapping?: boolean;
  45268. faceForward?: boolean;
  45269. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  45270. /**
  45271. * Releases resources associated with this node.
  45272. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  45273. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  45274. */
  45275. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  45276. }
  45277. }
  45278. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  45279. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  45280. /** @hidden */
  45281. export var rgbdDecodePixelShader: {
  45282. name: string;
  45283. shader: string;
  45284. };
  45285. }
  45286. declare module "babylonjs/Misc/brdfTextureTools" {
  45287. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45288. import { Scene } from "babylonjs/scene";
  45289. import "babylonjs/Shaders/rgbdDecode.fragment";
  45290. /**
  45291. * Class used to host texture specific utilities
  45292. */
  45293. export class BRDFTextureTools {
  45294. /**
  45295. * Expand the BRDF Texture from RGBD to Half Float if necessary.
  45296. * @param texture the texture to expand.
  45297. */
  45298. private static _ExpandDefaultBRDFTexture;
  45299. /**
  45300. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  45301. * @param scene defines the hosting scene
  45302. * @returns the environment BRDF texture
  45303. */
  45304. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  45305. private static _environmentBRDFBase64Texture;
  45306. }
  45307. }
  45308. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  45309. import { Nullable } from "babylonjs/types";
  45310. import { IAnimatable } from "babylonjs/Misc/tools";
  45311. import { Color3 } from "babylonjs/Maths/math";
  45312. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45313. import { EffectFallbacks } from "babylonjs/Materials/effect";
  45314. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  45315. import { Engine } from "babylonjs/Engines/engine";
  45316. import { Scene } from "babylonjs/scene";
  45317. /**
  45318. * @hidden
  45319. */
  45320. export interface IMaterialClearCoatDefines {
  45321. CLEARCOAT: boolean;
  45322. CLEARCOAT_DEFAULTIOR: boolean;
  45323. CLEARCOAT_TEXTURE: boolean;
  45324. CLEARCOAT_TEXTUREDIRECTUV: number;
  45325. CLEARCOAT_BUMP: boolean;
  45326. CLEARCOAT_BUMPDIRECTUV: number;
  45327. CLEARCOAT_TINT: boolean;
  45328. CLEARCOAT_TINT_TEXTURE: boolean;
  45329. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  45330. /** @hidden */
  45331. _areTexturesDirty: boolean;
  45332. }
  45333. /**
  45334. * Define the code related to the clear coat parameters of the pbr material.
  45335. */
  45336. export class PBRClearCoatConfiguration {
  45337. /**
  45338. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  45339. * The default fits with a polyurethane material.
  45340. */
  45341. private static readonly _DefaultIndiceOfRefraction;
  45342. private _isEnabled;
  45343. /**
  45344. * Defines if the clear coat is enabled in the material.
  45345. */
  45346. isEnabled: boolean;
  45347. /**
  45348. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  45349. */
  45350. intensity: number;
  45351. /**
  45352. * Defines the clear coat layer roughness.
  45353. */
  45354. roughness: number;
  45355. private _indiceOfRefraction;
  45356. /**
  45357. * Defines the indice of refraction of the clear coat.
  45358. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  45359. * The default fits with a polyurethane material.
  45360. * Changing the default value is more performance intensive.
  45361. */
  45362. indiceOfRefraction: number;
  45363. private _texture;
  45364. /**
  45365. * Stores the clear coat values in a texture.
  45366. */
  45367. texture: Nullable<BaseTexture>;
  45368. private _bumpTexture;
  45369. /**
  45370. * Define the clear coat specific bump texture.
  45371. */
  45372. bumpTexture: Nullable<BaseTexture>;
  45373. private _isTintEnabled;
  45374. /**
  45375. * Defines if the clear coat tint is enabled in the material.
  45376. */
  45377. isTintEnabled: boolean;
  45378. /**
  45379. * Defines the clear coat tint of the material.
  45380. * This is only use if tint is enabled
  45381. */
  45382. tintColor: Color3;
  45383. /**
  45384. * Defines the distance at which the tint color should be found in the
  45385. * clear coat media.
  45386. * This is only use if tint is enabled
  45387. */
  45388. tintColorAtDistance: number;
  45389. /**
  45390. * Defines the clear coat layer thickness.
  45391. * This is only use if tint is enabled
  45392. */
  45393. tintThickness: number;
  45394. private _tintTexture;
  45395. /**
  45396. * Stores the clear tint values in a texture.
  45397. * rgb is tint
  45398. * a is a thickness factor
  45399. */
  45400. tintTexture: Nullable<BaseTexture>;
  45401. /** @hidden */
  45402. private _internalMarkAllSubMeshesAsTexturesDirty;
  45403. /** @hidden */
  45404. _markAllSubMeshesAsTexturesDirty(): void;
  45405. /**
  45406. * Instantiate a new istance of clear coat configuration.
  45407. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  45408. */
  45409. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  45410. /**
  45411. * Gets wehter the submesh is ready to be used or not.
  45412. * @param defines the list of "defines" to update.
  45413. * @param scene defines the scene the material belongs to.
  45414. * @param engine defines the engine the material belongs to.
  45415. * @param disableBumpMap defines wether the material disables bump or not.
  45416. * @returns - boolean indicating that the submesh is ready or not.
  45417. */
  45418. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  45419. /**
  45420. * Checks to see if a texture is used in the material.
  45421. * @param defines the list of "defines" to update.
  45422. * @param scene defines the scene to the material belongs to.
  45423. */
  45424. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  45425. /**
  45426. * Binds the material data.
  45427. * @param uniformBuffer defines the Uniform buffer to fill in.
  45428. * @param scene defines the scene the material belongs to.
  45429. * @param engine defines the engine the material belongs to.
  45430. * @param disableBumpMap defines wether the material disables bump or not.
  45431. * @param isFrozen defines wether the material is frozen or not.
  45432. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  45433. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  45434. */
  45435. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  45436. /**
  45437. * Checks to see if a texture is used in the material.
  45438. * @param texture - Base texture to use.
  45439. * @returns - Boolean specifying if a texture is used in the material.
  45440. */
  45441. hasTexture(texture: BaseTexture): boolean;
  45442. /**
  45443. * Returns an array of the actively used textures.
  45444. * @param activeTextures Array of BaseTextures
  45445. */
  45446. getActiveTextures(activeTextures: BaseTexture[]): void;
  45447. /**
  45448. * Returns the animatable textures.
  45449. * @param animatables Array of animatable textures.
  45450. */
  45451. getAnimatables(animatables: IAnimatable[]): void;
  45452. /**
  45453. * Disposes the resources of the material.
  45454. * @param forceDisposeTextures - Forces the disposal of all textures.
  45455. */
  45456. dispose(forceDisposeTextures?: boolean): void;
  45457. /**
  45458. * Get the current class name of the texture useful for serialization or dynamic coding.
  45459. * @returns "PBRClearCoatConfiguration"
  45460. */
  45461. getClassName(): string;
  45462. /**
  45463. * Add fallbacks to the effect fallbacks list.
  45464. * @param defines defines the Base texture to use.
  45465. * @param fallbacks defines the current fallback list.
  45466. * @param currentRank defines the current fallback rank.
  45467. * @returns the new fallback rank.
  45468. */
  45469. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  45470. /**
  45471. * Add the required uniforms to the current list.
  45472. * @param uniforms defines the current uniform list.
  45473. */
  45474. static AddUniforms(uniforms: string[]): void;
  45475. /**
  45476. * Add the required samplers to the current list.
  45477. * @param samplers defines the current sampler list.
  45478. */
  45479. static AddSamplers(samplers: string[]): void;
  45480. /**
  45481. * Add the required uniforms to the current buffer.
  45482. * @param uniformBuffer defines the current uniform buffer.
  45483. */
  45484. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  45485. /**
  45486. * Makes a duplicate of the current configuration into another one.
  45487. * @param clearCoatConfiguration define the config where to copy the info
  45488. */
  45489. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  45490. /**
  45491. * Serializes this clear coat configuration.
  45492. * @returns - An object with the serialized config.
  45493. */
  45494. serialize(): any;
  45495. /**
  45496. * Parses a Clear Coat Configuration from a serialized object.
  45497. * @param source - Serialized object.
  45498. */
  45499. parse(source: any): void;
  45500. }
  45501. }
  45502. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  45503. import { EffectFallbacks } from "babylonjs/Materials/effect";
  45504. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  45505. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45506. import { Vector2 } from "babylonjs/Maths/math";
  45507. import { Scene } from "babylonjs/scene";
  45508. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45509. import { IAnimatable } from "babylonjs/Misc/tools";
  45510. import { Nullable } from "babylonjs/types";
  45511. /**
  45512. * @hidden
  45513. */
  45514. export interface IMaterialAnisotropicDefines {
  45515. ANISOTROPIC: boolean;
  45516. ANISOTROPIC_TEXTURE: boolean;
  45517. ANISOTROPIC_TEXTUREDIRECTUV: number;
  45518. MAINUV1: boolean;
  45519. _areTexturesDirty: boolean;
  45520. _needUVs: boolean;
  45521. }
  45522. /**
  45523. * Define the code related to the anisotropic parameters of the pbr material.
  45524. */
  45525. export class PBRAnisotropicConfiguration {
  45526. private _isEnabled;
  45527. /**
  45528. * Defines if the anisotropy is enabled in the material.
  45529. */
  45530. isEnabled: boolean;
  45531. /**
  45532. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  45533. */
  45534. intensity: number;
  45535. /**
  45536. * Defines if the effect is along the tangents, bitangents or in between.
  45537. * By default, the effect is "strectching" the highlights along the tangents.
  45538. */
  45539. direction: Vector2;
  45540. private _texture;
  45541. /**
  45542. * Stores the anisotropy values in a texture.
  45543. * rg is direction (like normal from -1 to 1)
  45544. * b is a intensity
  45545. */
  45546. texture: Nullable<BaseTexture>;
  45547. /** @hidden */
  45548. private _internalMarkAllSubMeshesAsTexturesDirty;
  45549. /** @hidden */
  45550. _markAllSubMeshesAsTexturesDirty(): void;
  45551. /**
  45552. * Instantiate a new istance of anisotropy configuration.
  45553. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  45554. */
  45555. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  45556. /**
  45557. * Specifies that the submesh is ready to be used.
  45558. * @param defines the list of "defines" to update.
  45559. * @param scene defines the scene the material belongs to.
  45560. * @returns - boolean indicating that the submesh is ready or not.
  45561. */
  45562. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  45563. /**
  45564. * Checks to see if a texture is used in the material.
  45565. * @param defines the list of "defines" to update.
  45566. * @param mesh the mesh we are preparing the defines for.
  45567. * @param scene defines the scene the material belongs to.
  45568. */
  45569. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  45570. /**
  45571. * Binds the material data.
  45572. * @param uniformBuffer defines the Uniform buffer to fill in.
  45573. * @param scene defines the scene the material belongs to.
  45574. * @param isFrozen defines wether the material is frozen or not.
  45575. */
  45576. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  45577. /**
  45578. * Checks to see if a texture is used in the material.
  45579. * @param texture - Base texture to use.
  45580. * @returns - Boolean specifying if a texture is used in the material.
  45581. */
  45582. hasTexture(texture: BaseTexture): boolean;
  45583. /**
  45584. * Returns an array of the actively used textures.
  45585. * @param activeTextures Array of BaseTextures
  45586. */
  45587. getActiveTextures(activeTextures: BaseTexture[]): void;
  45588. /**
  45589. * Returns the animatable textures.
  45590. * @param animatables Array of animatable textures.
  45591. */
  45592. getAnimatables(animatables: IAnimatable[]): void;
  45593. /**
  45594. * Disposes the resources of the material.
  45595. * @param forceDisposeTextures - Forces the disposal of all textures.
  45596. */
  45597. dispose(forceDisposeTextures?: boolean): void;
  45598. /**
  45599. * Get the current class name of the texture useful for serialization or dynamic coding.
  45600. * @returns "PBRAnisotropicConfiguration"
  45601. */
  45602. getClassName(): string;
  45603. /**
  45604. * Add fallbacks to the effect fallbacks list.
  45605. * @param defines defines the Base texture to use.
  45606. * @param fallbacks defines the current fallback list.
  45607. * @param currentRank defines the current fallback rank.
  45608. * @returns the new fallback rank.
  45609. */
  45610. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  45611. /**
  45612. * Add the required uniforms to the current list.
  45613. * @param uniforms defines the current uniform list.
  45614. */
  45615. static AddUniforms(uniforms: string[]): void;
  45616. /**
  45617. * Add the required uniforms to the current buffer.
  45618. * @param uniformBuffer defines the current uniform buffer.
  45619. */
  45620. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  45621. /**
  45622. * Add the required samplers to the current list.
  45623. * @param samplers defines the current sampler list.
  45624. */
  45625. static AddSamplers(samplers: string[]): void;
  45626. /**
  45627. * Makes a duplicate of the current configuration into another one.
  45628. * @param anisotropicConfiguration define the config where to copy the info
  45629. */
  45630. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  45631. /**
  45632. * Serializes this anisotropy configuration.
  45633. * @returns - An object with the serialized config.
  45634. */
  45635. serialize(): any;
  45636. /**
  45637. * Parses a anisotropy Configuration from a serialized object.
  45638. * @param source - Serialized object.
  45639. */
  45640. parse(source: any): void;
  45641. }
  45642. }
  45643. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  45644. /**
  45645. * @hidden
  45646. */
  45647. export interface IMaterialBRDFDefines {
  45648. BRDF_V_HEIGHT_CORRELATED: boolean;
  45649. MS_BRDF_ENERGY_CONSERVATION: boolean;
  45650. /** @hidden */
  45651. _areMiscDirty: boolean;
  45652. }
  45653. /**
  45654. * Define the code related to the BRDF parameters of the pbr material.
  45655. */
  45656. export class PBRBRDFConfiguration {
  45657. /**
  45658. * Default value used for the energy conservation.
  45659. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  45660. */
  45661. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  45662. /**
  45663. * Default value used for the Smith Visibility Height Correlated mode.
  45664. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  45665. */
  45666. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  45667. private _useEnergyConservation;
  45668. /**
  45669. * Defines if the material uses energy conservation.
  45670. */
  45671. useEnergyConservation: boolean;
  45672. private _useSmithVisibilityHeightCorrelated;
  45673. /**
  45674. * LEGACY Mode set to false
  45675. * Defines if the material uses height smith correlated visibility term.
  45676. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  45677. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  45678. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  45679. * Not relying on height correlated will also disable energy conservation.
  45680. */
  45681. useSmithVisibilityHeightCorrelated: boolean;
  45682. /** @hidden */
  45683. private _internalMarkAllSubMeshesAsMiscDirty;
  45684. /** @hidden */
  45685. _markAllSubMeshesAsMiscDirty(): void;
  45686. /**
  45687. * Instantiate a new istance of clear coat configuration.
  45688. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  45689. */
  45690. constructor(markAllSubMeshesAsMiscDirty: () => void);
  45691. /**
  45692. * Checks to see if a texture is used in the material.
  45693. * @param defines the list of "defines" to update.
  45694. */
  45695. prepareDefines(defines: IMaterialBRDFDefines): void;
  45696. /**
  45697. * Get the current class name of the texture useful for serialization or dynamic coding.
  45698. * @returns "PBRClearCoatConfiguration"
  45699. */
  45700. getClassName(): string;
  45701. /**
  45702. * Makes a duplicate of the current configuration into another one.
  45703. * @param brdfConfiguration define the config where to copy the info
  45704. */
  45705. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  45706. /**
  45707. * Serializes this BRDF configuration.
  45708. * @returns - An object with the serialized config.
  45709. */
  45710. serialize(): any;
  45711. /**
  45712. * Parses a BRDF Configuration from a serialized object.
  45713. * @param source - Serialized object.
  45714. */
  45715. parse(source: any): void;
  45716. }
  45717. }
  45718. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  45719. import { EffectFallbacks } from "babylonjs/Materials/effect";
  45720. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  45721. import { Color3 } from "babylonjs/Maths/math";
  45722. import { Scene } from "babylonjs/scene";
  45723. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45724. import { IAnimatable } from "babylonjs/Misc/tools";
  45725. import { Nullable } from "babylonjs/types";
  45726. /**
  45727. * @hidden
  45728. */
  45729. export interface IMaterialSheenDefines {
  45730. SHEEN: boolean;
  45731. SHEEN_TEXTURE: boolean;
  45732. SHEEN_TEXTUREDIRECTUV: number;
  45733. SHEEN_LINKWITHALBEDO: boolean;
  45734. /** @hidden */
  45735. _areTexturesDirty: boolean;
  45736. }
  45737. /**
  45738. * Define the code related to the Sheen parameters of the pbr material.
  45739. */
  45740. export class PBRSheenConfiguration {
  45741. private _isEnabled;
  45742. /**
  45743. * Defines if the material uses sheen.
  45744. */
  45745. isEnabled: boolean;
  45746. private _linkSheenWithAlbedo;
  45747. /**
  45748. * Defines if the sheen is linked to the sheen color.
  45749. */
  45750. linkSheenWithAlbedo: boolean;
  45751. /**
  45752. * Defines the sheen intensity.
  45753. */
  45754. intensity: number;
  45755. /**
  45756. * Defines the sheen color.
  45757. */
  45758. color: Color3;
  45759. private _texture;
  45760. /**
  45761. * Stores the sheen tint values in a texture.
  45762. * rgb is tint
  45763. * a is a intensity
  45764. */
  45765. texture: Nullable<BaseTexture>;
  45766. /** @hidden */
  45767. private _internalMarkAllSubMeshesAsTexturesDirty;
  45768. /** @hidden */
  45769. _markAllSubMeshesAsTexturesDirty(): void;
  45770. /**
  45771. * Instantiate a new istance of clear coat configuration.
  45772. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  45773. */
  45774. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  45775. /**
  45776. * Specifies that the submesh is ready to be used.
  45777. * @param defines the list of "defines" to update.
  45778. * @param scene defines the scene the material belongs to.
  45779. * @returns - boolean indicating that the submesh is ready or not.
  45780. */
  45781. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  45782. /**
  45783. * Checks to see if a texture is used in the material.
  45784. * @param defines the list of "defines" to update.
  45785. * @param scene defines the scene the material belongs to.
  45786. */
  45787. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  45788. /**
  45789. * Binds the material data.
  45790. * @param uniformBuffer defines the Uniform buffer to fill in.
  45791. * @param scene defines the scene the material belongs to.
  45792. * @param isFrozen defines wether the material is frozen or not.
  45793. */
  45794. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  45795. /**
  45796. * Checks to see if a texture is used in the material.
  45797. * @param texture - Base texture to use.
  45798. * @returns - Boolean specifying if a texture is used in the material.
  45799. */
  45800. hasTexture(texture: BaseTexture): boolean;
  45801. /**
  45802. * Returns an array of the actively used textures.
  45803. * @param activeTextures Array of BaseTextures
  45804. */
  45805. getActiveTextures(activeTextures: BaseTexture[]): void;
  45806. /**
  45807. * Returns the animatable textures.
  45808. * @param animatables Array of animatable textures.
  45809. */
  45810. getAnimatables(animatables: IAnimatable[]): void;
  45811. /**
  45812. * Disposes the resources of the material.
  45813. * @param forceDisposeTextures - Forces the disposal of all textures.
  45814. */
  45815. dispose(forceDisposeTextures?: boolean): void;
  45816. /**
  45817. * Get the current class name of the texture useful for serialization or dynamic coding.
  45818. * @returns "PBRSheenConfiguration"
  45819. */
  45820. getClassName(): string;
  45821. /**
  45822. * Add fallbacks to the effect fallbacks list.
  45823. * @param defines defines the Base texture to use.
  45824. * @param fallbacks defines the current fallback list.
  45825. * @param currentRank defines the current fallback rank.
  45826. * @returns the new fallback rank.
  45827. */
  45828. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  45829. /**
  45830. * Add the required uniforms to the current list.
  45831. * @param uniforms defines the current uniform list.
  45832. */
  45833. static AddUniforms(uniforms: string[]): void;
  45834. /**
  45835. * Add the required uniforms to the current buffer.
  45836. * @param uniformBuffer defines the current uniform buffer.
  45837. */
  45838. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  45839. /**
  45840. * Add the required samplers to the current list.
  45841. * @param samplers defines the current sampler list.
  45842. */
  45843. static AddSamplers(samplers: string[]): void;
  45844. /**
  45845. * Makes a duplicate of the current configuration into another one.
  45846. * @param sheenConfiguration define the config where to copy the info
  45847. */
  45848. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  45849. /**
  45850. * Serializes this BRDF configuration.
  45851. * @returns - An object with the serialized config.
  45852. */
  45853. serialize(): any;
  45854. /**
  45855. * Parses a Sheen Configuration from a serialized object.
  45856. * @param source - Serialized object.
  45857. */
  45858. parse(source: any): void;
  45859. }
  45860. }
  45861. declare module "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration" {
  45862. import { Nullable } from "babylonjs/types";
  45863. import { IAnimatable } from "babylonjs/Misc/tools";
  45864. import { Color3 } from "babylonjs/Maths/math";
  45865. import { SmartArray } from "babylonjs/Misc/smartArray";
  45866. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45867. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  45868. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  45869. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  45870. import { Engine } from "babylonjs/Engines/engine";
  45871. import { Scene } from "babylonjs/scene";
  45872. /**
  45873. * @hidden
  45874. */
  45875. export interface IMaterialSubSurfaceDefines {
  45876. SUBSURFACE: boolean;
  45877. SS_REFRACTION: boolean;
  45878. SS_TRANSLUCENCY: boolean;
  45879. SS_SCATERRING: boolean;
  45880. SS_THICKNESSANDMASK_TEXTURE: boolean;
  45881. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  45882. SS_REFRACTIONMAP_3D: boolean;
  45883. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  45884. SS_LODINREFRACTIONALPHA: boolean;
  45885. SS_GAMMAREFRACTION: boolean;
  45886. SS_RGBDREFRACTION: boolean;
  45887. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  45888. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  45889. /** @hidden */
  45890. _areTexturesDirty: boolean;
  45891. }
  45892. /**
  45893. * Define the code related to the sub surface parameters of the pbr material.
  45894. */
  45895. export class PBRSubSurfaceConfiguration {
  45896. private _isRefractionEnabled;
  45897. /**
  45898. * Defines if the refraction is enabled in the material.
  45899. */
  45900. isRefractionEnabled: boolean;
  45901. private _isTranslucencyEnabled;
  45902. /**
  45903. * Defines if the translucency is enabled in the material.
  45904. */
  45905. isTranslucencyEnabled: boolean;
  45906. private _isScatteringEnabled;
  45907. /**
  45908. * Defines the refraction intensity of the material.
  45909. * The refraction when enabled replaces the Diffuse part of the material.
  45910. * The intensity helps transitionning between diffuse and refraction.
  45911. */
  45912. refractionIntensity: number;
  45913. /**
  45914. * Defines the translucency intensity of the material.
  45915. * When translucency has been enabled, this defines how much of the "translucency"
  45916. * is addded to the diffuse part of the material.
  45917. */
  45918. translucencyIntensity: number;
  45919. /**
  45920. * Defines the scattering intensity of the material.
  45921. * When scattering has been enabled, this defines how much of the "scattered light"
  45922. * is addded to the diffuse part of the material.
  45923. */
  45924. scatteringIntensity: number;
  45925. private _thicknessTexture;
  45926. /**
  45927. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  45928. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  45929. * 0 would mean minimumThickness
  45930. * 1 would mean maximumThickness
  45931. * The other channels might be use as a mask to vary the different effects intensity.
  45932. */
  45933. thicknessTexture: Nullable<BaseTexture>;
  45934. private _refractionTexture;
  45935. /**
  45936. * Defines the texture to use for refraction.
  45937. */
  45938. refractionTexture: Nullable<BaseTexture>;
  45939. private _indexOfRefraction;
  45940. /**
  45941. * Defines the indice of refraction used in the material.
  45942. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  45943. */
  45944. indexOfRefraction: number;
  45945. private _invertRefractionY;
  45946. /**
  45947. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  45948. */
  45949. invertRefractionY: boolean;
  45950. private _linkRefractionWithTransparency;
  45951. /**
  45952. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  45953. * Materials half opaque for instance using refraction could benefit from this control.
  45954. */
  45955. linkRefractionWithTransparency: boolean;
  45956. /**
  45957. * Defines the minimum thickness stored in the thickness map.
  45958. * If no thickness map is defined, this value will be used to simulate thickness.
  45959. */
  45960. minimumThickness: number;
  45961. /**
  45962. * Defines the maximum thickness stored in the thickness map.
  45963. */
  45964. maximumThickness: number;
  45965. /**
  45966. * Defines the volume tint of the material.
  45967. * This is used for both translucency and scattering.
  45968. */
  45969. tintColor: Color3;
  45970. /**
  45971. * Defines the distance at which the tint color should be found in the media.
  45972. * This is used for refraction only.
  45973. */
  45974. tintColorAtDistance: number;
  45975. /**
  45976. * Defines how far each channel transmit through the media.
  45977. * It is defined as a color to simplify it selection.
  45978. */
  45979. diffusionDistance: Color3;
  45980. private _useMaskFromThicknessTexture;
  45981. /**
  45982. * Stores the intensity of the different subsurface effects in the thickness texture.
  45983. * * the green channel is the translucency intensity.
  45984. * * the blue channel is the scattering intensity.
  45985. * * the alpha channel is the refraction intensity.
  45986. */
  45987. useMaskFromThicknessTexture: boolean;
  45988. /** @hidden */
  45989. private _internalMarkAllSubMeshesAsTexturesDirty;
  45990. /** @hidden */
  45991. _markAllSubMeshesAsTexturesDirty(): void;
  45992. /**
  45993. * Instantiate a new istance of sub surface configuration.
  45994. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  45995. */
  45996. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  45997. /**
  45998. * Gets wehter the submesh is ready to be used or not.
  45999. * @param defines the list of "defines" to update.
  46000. * @param scene defines the scene the material belongs to.
  46001. * @returns - boolean indicating that the submesh is ready or not.
  46002. */
  46003. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  46004. /**
  46005. * Checks to see if a texture is used in the material.
  46006. * @param defines the list of "defines" to update.
  46007. * @param scene defines the scene to the material belongs to.
  46008. */
  46009. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  46010. /**
  46011. * Binds the material data.
  46012. * @param uniformBuffer defines the Uniform buffer to fill in.
  46013. * @param scene defines the scene the material belongs to.
  46014. * @param engine defines the engine the material belongs to.
  46015. * @param isFrozen defines wether the material is frozen or not.
  46016. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  46017. */
  46018. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  46019. /**
  46020. * Unbinds the material from the mesh.
  46021. * @param activeEffect defines the effect that should be unbound from.
  46022. * @returns true if unbound, otherwise false
  46023. */
  46024. unbind(activeEffect: Effect): boolean;
  46025. /**
  46026. * Returns the texture used for refraction or null if none is used.
  46027. * @param scene defines the scene the material belongs to.
  46028. * @returns - Refraction texture if present. If no refraction texture and refraction
  46029. * is linked with transparency, returns environment texture. Otherwise, returns null.
  46030. */
  46031. private _getRefractionTexture;
  46032. /**
  46033. * Returns true if alpha blending should be disabled.
  46034. */
  46035. readonly disableAlphaBlending: boolean;
  46036. /**
  46037. * Fills the list of render target textures.
  46038. * @param renderTargets the list of render targets to update
  46039. */
  46040. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  46041. /**
  46042. * Checks to see if a texture is used in the material.
  46043. * @param texture - Base texture to use.
  46044. * @returns - Boolean specifying if a texture is used in the material.
  46045. */
  46046. hasTexture(texture: BaseTexture): boolean;
  46047. /**
  46048. * Gets a boolean indicating that current material needs to register RTT
  46049. * @returns true if this uses a render target otherwise false.
  46050. */
  46051. hasRenderTargetTextures(): boolean;
  46052. /**
  46053. * Returns an array of the actively used textures.
  46054. * @param activeTextures Array of BaseTextures
  46055. */
  46056. getActiveTextures(activeTextures: BaseTexture[]): void;
  46057. /**
  46058. * Returns the animatable textures.
  46059. * @param animatables Array of animatable textures.
  46060. */
  46061. getAnimatables(animatables: IAnimatable[]): void;
  46062. /**
  46063. * Disposes the resources of the material.
  46064. * @param forceDisposeTextures - Forces the disposal of all textures.
  46065. */
  46066. dispose(forceDisposeTextures?: boolean): void;
  46067. /**
  46068. * Get the current class name of the texture useful for serialization or dynamic coding.
  46069. * @returns "PBRSubSurfaceConfiguration"
  46070. */
  46071. getClassName(): string;
  46072. /**
  46073. * Add fallbacks to the effect fallbacks list.
  46074. * @param defines defines the Base texture to use.
  46075. * @param fallbacks defines the current fallback list.
  46076. * @param currentRank defines the current fallback rank.
  46077. * @returns the new fallback rank.
  46078. */
  46079. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  46080. /**
  46081. * Add the required uniforms to the current list.
  46082. * @param uniforms defines the current uniform list.
  46083. */
  46084. static AddUniforms(uniforms: string[]): void;
  46085. /**
  46086. * Add the required samplers to the current list.
  46087. * @param samplers defines the current sampler list.
  46088. */
  46089. static AddSamplers(samplers: string[]): void;
  46090. /**
  46091. * Add the required uniforms to the current buffer.
  46092. * @param uniformBuffer defines the current uniform buffer.
  46093. */
  46094. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  46095. /**
  46096. * Makes a duplicate of the current configuration into another one.
  46097. * @param configuration define the config where to copy the info
  46098. */
  46099. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  46100. /**
  46101. * Serializes this Sub Surface configuration.
  46102. * @returns - An object with the serialized config.
  46103. */
  46104. serialize(): any;
  46105. /**
  46106. * Parses a Sub Surface Configuration from a serialized object.
  46107. * @param source - Serialized object.
  46108. */
  46109. parse(source: any): void;
  46110. }
  46111. }
  46112. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  46113. /** @hidden */
  46114. export var pbrFragmentDeclaration: {
  46115. name: string;
  46116. shader: string;
  46117. };
  46118. }
  46119. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  46120. /** @hidden */
  46121. export var pbrUboDeclaration: {
  46122. name: string;
  46123. shader: string;
  46124. };
  46125. }
  46126. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration" {
  46127. /** @hidden */
  46128. export var pbrFragmentExtraDeclaration: {
  46129. name: string;
  46130. shader: string;
  46131. };
  46132. }
  46133. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration" {
  46134. /** @hidden */
  46135. export var pbrFragmentSamplersDeclaration: {
  46136. name: string;
  46137. shader: string;
  46138. };
  46139. }
  46140. declare module "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions" {
  46141. /** @hidden */
  46142. export var pbrHelperFunctions: {
  46143. name: string;
  46144. shader: string;
  46145. };
  46146. }
  46147. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  46148. /** @hidden */
  46149. export var harmonicsFunctions: {
  46150. name: string;
  46151. shader: string;
  46152. };
  46153. }
  46154. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions" {
  46155. /** @hidden */
  46156. export var pbrDirectLightingSetupFunctions: {
  46157. name: string;
  46158. shader: string;
  46159. };
  46160. }
  46161. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions" {
  46162. /** @hidden */
  46163. export var pbrDirectLightingFalloffFunctions: {
  46164. name: string;
  46165. shader: string;
  46166. };
  46167. }
  46168. declare module "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions" {
  46169. /** @hidden */
  46170. export var pbrBRDFFunctions: {
  46171. name: string;
  46172. shader: string;
  46173. };
  46174. }
  46175. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions" {
  46176. /** @hidden */
  46177. export var pbrDirectLightingFunctions: {
  46178. name: string;
  46179. shader: string;
  46180. };
  46181. }
  46182. declare module "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions" {
  46183. /** @hidden */
  46184. export var pbrIBLFunctions: {
  46185. name: string;
  46186. shader: string;
  46187. };
  46188. }
  46189. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  46190. /** @hidden */
  46191. export var pbrDebug: {
  46192. name: string;
  46193. shader: string;
  46194. };
  46195. }
  46196. declare module "babylonjs/Shaders/pbr.fragment" {
  46197. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  46198. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  46199. import "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration";
  46200. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  46201. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  46202. import "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration";
  46203. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  46204. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  46205. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  46206. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  46207. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  46208. import "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions";
  46209. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  46210. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  46211. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  46212. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions";
  46213. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions";
  46214. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  46215. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions";
  46216. import "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions";
  46217. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  46218. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  46219. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  46220. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  46221. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  46222. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  46223. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  46224. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  46225. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  46226. /** @hidden */
  46227. export var pbrPixelShader: {
  46228. name: string;
  46229. shader: string;
  46230. };
  46231. }
  46232. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  46233. /** @hidden */
  46234. export var pbrVertexDeclaration: {
  46235. name: string;
  46236. shader: string;
  46237. };
  46238. }
  46239. declare module "babylonjs/Shaders/pbr.vertex" {
  46240. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  46241. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  46242. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  46243. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  46244. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  46245. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  46246. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  46247. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  46248. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  46249. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  46250. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  46251. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  46252. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  46253. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  46254. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  46255. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  46256. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  46257. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  46258. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  46259. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  46260. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  46261. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  46262. /** @hidden */
  46263. export var pbrVertexShader: {
  46264. name: string;
  46265. shader: string;
  46266. };
  46267. }
  46268. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  46269. import { IAnimatable } from "babylonjs/Misc/tools";
  46270. import { Nullable } from "babylonjs/types";
  46271. import { Scene } from "babylonjs/scene";
  46272. import { Matrix, Color3 } from "babylonjs/Maths/math";
  46273. import { SubMesh } from "babylonjs/Meshes/subMesh";
  46274. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46275. import { Mesh } from "babylonjs/Meshes/mesh";
  46276. import { IMaterialClearCoatDefines, PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  46277. import { IMaterialAnisotropicDefines, PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  46278. import { IMaterialBRDFDefines, PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  46279. import { IMaterialSheenDefines, PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  46280. import { IMaterialSubSurfaceDefines, PBRSubSurfaceConfiguration } from "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration";
  46281. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  46282. import { Material } from "babylonjs/Materials/material";
  46283. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  46284. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  46285. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46286. import "babylonjs/Shaders/pbr.fragment";
  46287. import "babylonjs/Shaders/pbr.vertex";
  46288. /**
  46289. * Manages the defines for the PBR Material.
  46290. * @hidden
  46291. */
  46292. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  46293. PBR: boolean;
  46294. MAINUV1: boolean;
  46295. MAINUV2: boolean;
  46296. UV1: boolean;
  46297. UV2: boolean;
  46298. ALBEDO: boolean;
  46299. ALBEDODIRECTUV: number;
  46300. VERTEXCOLOR: boolean;
  46301. AMBIENT: boolean;
  46302. AMBIENTDIRECTUV: number;
  46303. AMBIENTINGRAYSCALE: boolean;
  46304. OPACITY: boolean;
  46305. VERTEXALPHA: boolean;
  46306. OPACITYDIRECTUV: number;
  46307. OPACITYRGB: boolean;
  46308. ALPHATEST: boolean;
  46309. DEPTHPREPASS: boolean;
  46310. ALPHABLEND: boolean;
  46311. ALPHAFROMALBEDO: boolean;
  46312. ALPHATESTVALUE: string;
  46313. SPECULAROVERALPHA: boolean;
  46314. RADIANCEOVERALPHA: boolean;
  46315. ALPHAFRESNEL: boolean;
  46316. LINEARALPHAFRESNEL: boolean;
  46317. PREMULTIPLYALPHA: boolean;
  46318. EMISSIVE: boolean;
  46319. EMISSIVEDIRECTUV: number;
  46320. REFLECTIVITY: boolean;
  46321. REFLECTIVITYDIRECTUV: number;
  46322. SPECULARTERM: boolean;
  46323. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  46324. MICROSURFACEAUTOMATIC: boolean;
  46325. LODBASEDMICROSFURACE: boolean;
  46326. MICROSURFACEMAP: boolean;
  46327. MICROSURFACEMAPDIRECTUV: number;
  46328. METALLICWORKFLOW: boolean;
  46329. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  46330. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  46331. METALLNESSSTOREINMETALMAPBLUE: boolean;
  46332. AOSTOREINMETALMAPRED: boolean;
  46333. ENVIRONMENTBRDF: boolean;
  46334. ENVIRONMENTBRDF_RGBD: boolean;
  46335. NORMAL: boolean;
  46336. TANGENT: boolean;
  46337. BUMP: boolean;
  46338. BUMPDIRECTUV: number;
  46339. OBJECTSPACE_NORMALMAP: boolean;
  46340. PARALLAX: boolean;
  46341. PARALLAXOCCLUSION: boolean;
  46342. NORMALXYSCALE: boolean;
  46343. LIGHTMAP: boolean;
  46344. LIGHTMAPDIRECTUV: number;
  46345. USELIGHTMAPASSHADOWMAP: boolean;
  46346. GAMMALIGHTMAP: boolean;
  46347. REFLECTION: boolean;
  46348. REFLECTIONMAP_3D: boolean;
  46349. REFLECTIONMAP_SPHERICAL: boolean;
  46350. REFLECTIONMAP_PLANAR: boolean;
  46351. REFLECTIONMAP_CUBIC: boolean;
  46352. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  46353. REFLECTIONMAP_PROJECTION: boolean;
  46354. REFLECTIONMAP_SKYBOX: boolean;
  46355. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  46356. REFLECTIONMAP_EXPLICIT: boolean;
  46357. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  46358. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  46359. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  46360. INVERTCUBICMAP: boolean;
  46361. USESPHERICALFROMREFLECTIONMAP: boolean;
  46362. USESPHERICALINVERTEX: boolean;
  46363. REFLECTIONMAP_OPPOSITEZ: boolean;
  46364. LODINREFLECTIONALPHA: boolean;
  46365. GAMMAREFLECTION: boolean;
  46366. RGBDREFLECTION: boolean;
  46367. RADIANCEOCCLUSION: boolean;
  46368. HORIZONOCCLUSION: boolean;
  46369. INSTANCES: boolean;
  46370. NUM_BONE_INFLUENCERS: number;
  46371. BonesPerMesh: number;
  46372. BONETEXTURE: boolean;
  46373. NONUNIFORMSCALING: boolean;
  46374. MORPHTARGETS: boolean;
  46375. MORPHTARGETS_NORMAL: boolean;
  46376. MORPHTARGETS_TANGENT: boolean;
  46377. NUM_MORPH_INFLUENCERS: number;
  46378. IMAGEPROCESSING: boolean;
  46379. VIGNETTE: boolean;
  46380. VIGNETTEBLENDMODEMULTIPLY: boolean;
  46381. VIGNETTEBLENDMODEOPAQUE: boolean;
  46382. TONEMAPPING: boolean;
  46383. TONEMAPPING_ACES: boolean;
  46384. CONTRAST: boolean;
  46385. COLORCURVES: boolean;
  46386. COLORGRADING: boolean;
  46387. COLORGRADING3D: boolean;
  46388. SAMPLER3DGREENDEPTH: boolean;
  46389. SAMPLER3DBGRMAP: boolean;
  46390. IMAGEPROCESSINGPOSTPROCESS: boolean;
  46391. EXPOSURE: boolean;
  46392. MULTIVIEW: boolean;
  46393. USEPHYSICALLIGHTFALLOFF: boolean;
  46394. USEGLTFLIGHTFALLOFF: boolean;
  46395. TWOSIDEDLIGHTING: boolean;
  46396. SHADOWFLOAT: boolean;
  46397. CLIPPLANE: boolean;
  46398. CLIPPLANE2: boolean;
  46399. CLIPPLANE3: boolean;
  46400. CLIPPLANE4: boolean;
  46401. POINTSIZE: boolean;
  46402. FOG: boolean;
  46403. LOGARITHMICDEPTH: boolean;
  46404. FORCENORMALFORWARD: boolean;
  46405. SPECULARAA: boolean;
  46406. CLEARCOAT: boolean;
  46407. CLEARCOAT_DEFAULTIOR: boolean;
  46408. CLEARCOAT_TEXTURE: boolean;
  46409. CLEARCOAT_TEXTUREDIRECTUV: number;
  46410. CLEARCOAT_BUMP: boolean;
  46411. CLEARCOAT_BUMPDIRECTUV: number;
  46412. CLEARCOAT_TINT: boolean;
  46413. CLEARCOAT_TINT_TEXTURE: boolean;
  46414. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  46415. ANISOTROPIC: boolean;
  46416. ANISOTROPIC_TEXTURE: boolean;
  46417. ANISOTROPIC_TEXTUREDIRECTUV: number;
  46418. BRDF_V_HEIGHT_CORRELATED: boolean;
  46419. MS_BRDF_ENERGY_CONSERVATION: boolean;
  46420. SHEEN: boolean;
  46421. SHEEN_TEXTURE: boolean;
  46422. SHEEN_TEXTUREDIRECTUV: number;
  46423. SHEEN_LINKWITHALBEDO: boolean;
  46424. SUBSURFACE: boolean;
  46425. SS_REFRACTION: boolean;
  46426. SS_TRANSLUCENCY: boolean;
  46427. SS_SCATERRING: boolean;
  46428. SS_THICKNESSANDMASK_TEXTURE: boolean;
  46429. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  46430. SS_REFRACTIONMAP_3D: boolean;
  46431. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  46432. SS_LODINREFRACTIONALPHA: boolean;
  46433. SS_GAMMAREFRACTION: boolean;
  46434. SS_RGBDREFRACTION: boolean;
  46435. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  46436. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  46437. UNLIT: boolean;
  46438. DEBUGMODE: number;
  46439. /**
  46440. * Initializes the PBR Material defines.
  46441. */
  46442. constructor();
  46443. /**
  46444. * Resets the PBR Material defines.
  46445. */
  46446. reset(): void;
  46447. }
  46448. /**
  46449. * The Physically based material base class of BJS.
  46450. *
  46451. * This offers the main features of a standard PBR material.
  46452. * For more information, please refer to the documentation :
  46453. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  46454. */
  46455. export abstract class PBRBaseMaterial extends PushMaterial {
  46456. /**
  46457. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  46458. */
  46459. static readonly PBRMATERIAL_OPAQUE: number;
  46460. /**
  46461. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  46462. */
  46463. static readonly PBRMATERIAL_ALPHATEST: number;
  46464. /**
  46465. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  46466. */
  46467. static readonly PBRMATERIAL_ALPHABLEND: number;
  46468. /**
  46469. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  46470. * They are also discarded below the alpha cutoff threshold to improve performances.
  46471. */
  46472. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  46473. /**
  46474. * Defines the default value of how much AO map is occluding the analytical lights
  46475. * (point spot...).
  46476. */
  46477. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  46478. /**
  46479. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  46480. */
  46481. static readonly LIGHTFALLOFF_PHYSICAL: number;
  46482. /**
  46483. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  46484. * to enhance interoperability with other engines.
  46485. */
  46486. static readonly LIGHTFALLOFF_GLTF: number;
  46487. /**
  46488. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  46489. * to enhance interoperability with other materials.
  46490. */
  46491. static readonly LIGHTFALLOFF_STANDARD: number;
  46492. /**
  46493. * Intensity of the direct lights e.g. the four lights available in your scene.
  46494. * This impacts both the direct diffuse and specular highlights.
  46495. */
  46496. protected _directIntensity: number;
  46497. /**
  46498. * Intensity of the emissive part of the material.
  46499. * This helps controlling the emissive effect without modifying the emissive color.
  46500. */
  46501. protected _emissiveIntensity: number;
  46502. /**
  46503. * Intensity of the environment e.g. how much the environment will light the object
  46504. * either through harmonics for rough material or through the refelction for shiny ones.
  46505. */
  46506. protected _environmentIntensity: number;
  46507. /**
  46508. * This is a special control allowing the reduction of the specular highlights coming from the
  46509. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  46510. */
  46511. protected _specularIntensity: number;
  46512. /**
  46513. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  46514. */
  46515. private _lightingInfos;
  46516. /**
  46517. * Debug Control allowing disabling the bump map on this material.
  46518. */
  46519. protected _disableBumpMap: boolean;
  46520. /**
  46521. * AKA Diffuse Texture in standard nomenclature.
  46522. */
  46523. protected _albedoTexture: BaseTexture;
  46524. /**
  46525. * AKA Occlusion Texture in other nomenclature.
  46526. */
  46527. protected _ambientTexture: BaseTexture;
  46528. /**
  46529. * AKA Occlusion Texture Intensity in other nomenclature.
  46530. */
  46531. protected _ambientTextureStrength: number;
  46532. /**
  46533. * Defines how much the AO map is occluding the analytical lights (point spot...).
  46534. * 1 means it completely occludes it
  46535. * 0 mean it has no impact
  46536. */
  46537. protected _ambientTextureImpactOnAnalyticalLights: number;
  46538. /**
  46539. * Stores the alpha values in a texture.
  46540. */
  46541. protected _opacityTexture: BaseTexture;
  46542. /**
  46543. * Stores the reflection values in a texture.
  46544. */
  46545. protected _reflectionTexture: BaseTexture;
  46546. /**
  46547. * Stores the emissive values in a texture.
  46548. */
  46549. protected _emissiveTexture: BaseTexture;
  46550. /**
  46551. * AKA Specular texture in other nomenclature.
  46552. */
  46553. protected _reflectivityTexture: BaseTexture;
  46554. /**
  46555. * Used to switch from specular/glossiness to metallic/roughness workflow.
  46556. */
  46557. protected _metallicTexture: BaseTexture;
  46558. /**
  46559. * Specifies the metallic scalar of the metallic/roughness workflow.
  46560. * Can also be used to scale the metalness values of the metallic texture.
  46561. */
  46562. protected _metallic: Nullable<number>;
  46563. /**
  46564. * Specifies the roughness scalar of the metallic/roughness workflow.
  46565. * Can also be used to scale the roughness values of the metallic texture.
  46566. */
  46567. protected _roughness: Nullable<number>;
  46568. /**
  46569. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  46570. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  46571. */
  46572. protected _microSurfaceTexture: BaseTexture;
  46573. /**
  46574. * Stores surface normal data used to displace a mesh in a texture.
  46575. */
  46576. protected _bumpTexture: BaseTexture;
  46577. /**
  46578. * Stores the pre-calculated light information of a mesh in a texture.
  46579. */
  46580. protected _lightmapTexture: BaseTexture;
  46581. /**
  46582. * The color of a material in ambient lighting.
  46583. */
  46584. protected _ambientColor: Color3;
  46585. /**
  46586. * AKA Diffuse Color in other nomenclature.
  46587. */
  46588. protected _albedoColor: Color3;
  46589. /**
  46590. * AKA Specular Color in other nomenclature.
  46591. */
  46592. protected _reflectivityColor: Color3;
  46593. /**
  46594. * The color applied when light is reflected from a material.
  46595. */
  46596. protected _reflectionColor: Color3;
  46597. /**
  46598. * The color applied when light is emitted from a material.
  46599. */
  46600. protected _emissiveColor: Color3;
  46601. /**
  46602. * AKA Glossiness in other nomenclature.
  46603. */
  46604. protected _microSurface: number;
  46605. /**
  46606. * Specifies that the material will use the light map as a show map.
  46607. */
  46608. protected _useLightmapAsShadowmap: boolean;
  46609. /**
  46610. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  46611. * makes the reflect vector face the model (under horizon).
  46612. */
  46613. protected _useHorizonOcclusion: boolean;
  46614. /**
  46615. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  46616. * too much the area relying on ambient texture to define their ambient occlusion.
  46617. */
  46618. protected _useRadianceOcclusion: boolean;
  46619. /**
  46620. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  46621. */
  46622. protected _useAlphaFromAlbedoTexture: boolean;
  46623. /**
  46624. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  46625. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  46626. */
  46627. protected _useSpecularOverAlpha: boolean;
  46628. /**
  46629. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  46630. */
  46631. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  46632. /**
  46633. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  46634. */
  46635. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  46636. /**
  46637. * Specifies if the metallic texture contains the roughness information in its green channel.
  46638. */
  46639. protected _useRoughnessFromMetallicTextureGreen: boolean;
  46640. /**
  46641. * Specifies if the metallic texture contains the metallness information in its blue channel.
  46642. */
  46643. protected _useMetallnessFromMetallicTextureBlue: boolean;
  46644. /**
  46645. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  46646. */
  46647. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  46648. /**
  46649. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  46650. */
  46651. protected _useAmbientInGrayScale: boolean;
  46652. /**
  46653. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  46654. * The material will try to infer what glossiness each pixel should be.
  46655. */
  46656. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  46657. /**
  46658. * Defines the falloff type used in this material.
  46659. * It by default is Physical.
  46660. */
  46661. protected _lightFalloff: number;
  46662. /**
  46663. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  46664. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  46665. */
  46666. protected _useRadianceOverAlpha: boolean;
  46667. /**
  46668. * Allows using an object space normal map (instead of tangent space).
  46669. */
  46670. protected _useObjectSpaceNormalMap: boolean;
  46671. /**
  46672. * Allows using the bump map in parallax mode.
  46673. */
  46674. protected _useParallax: boolean;
  46675. /**
  46676. * Allows using the bump map in parallax occlusion mode.
  46677. */
  46678. protected _useParallaxOcclusion: boolean;
  46679. /**
  46680. * Controls the scale bias of the parallax mode.
  46681. */
  46682. protected _parallaxScaleBias: number;
  46683. /**
  46684. * If sets to true, disables all the lights affecting the material.
  46685. */
  46686. protected _disableLighting: boolean;
  46687. /**
  46688. * Number of Simultaneous lights allowed on the material.
  46689. */
  46690. protected _maxSimultaneousLights: number;
  46691. /**
  46692. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  46693. */
  46694. protected _invertNormalMapX: boolean;
  46695. /**
  46696. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  46697. */
  46698. protected _invertNormalMapY: boolean;
  46699. /**
  46700. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  46701. */
  46702. protected _twoSidedLighting: boolean;
  46703. /**
  46704. * Defines the alpha limits in alpha test mode.
  46705. */
  46706. protected _alphaCutOff: number;
  46707. /**
  46708. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  46709. */
  46710. protected _forceAlphaTest: boolean;
  46711. /**
  46712. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  46713. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  46714. */
  46715. protected _useAlphaFresnel: boolean;
  46716. /**
  46717. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  46718. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  46719. */
  46720. protected _useLinearAlphaFresnel: boolean;
  46721. /**
  46722. * The transparency mode of the material.
  46723. */
  46724. protected _transparencyMode: Nullable<number>;
  46725. /**
  46726. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  46727. * from cos thetav and roughness:
  46728. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  46729. */
  46730. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  46731. /**
  46732. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  46733. */
  46734. protected _forceIrradianceInFragment: boolean;
  46735. /**
  46736. * Force normal to face away from face.
  46737. */
  46738. protected _forceNormalForward: boolean;
  46739. /**
  46740. * Enables specular anti aliasing in the PBR shader.
  46741. * It will both interacts on the Geometry for analytical and IBL lighting.
  46742. * It also prefilter the roughness map based on the bump values.
  46743. */
  46744. protected _enableSpecularAntiAliasing: boolean;
  46745. /**
  46746. * Default configuration related to image processing available in the PBR Material.
  46747. */
  46748. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  46749. /**
  46750. * Keep track of the image processing observer to allow dispose and replace.
  46751. */
  46752. private _imageProcessingObserver;
  46753. /**
  46754. * Attaches a new image processing configuration to the PBR Material.
  46755. * @param configuration
  46756. */
  46757. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  46758. /**
  46759. * Stores the available render targets.
  46760. */
  46761. private _renderTargets;
  46762. /**
  46763. * Sets the global ambient color for the material used in lighting calculations.
  46764. */
  46765. private _globalAmbientColor;
  46766. /**
  46767. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  46768. */
  46769. private _useLogarithmicDepth;
  46770. /**
  46771. * If set to true, no lighting calculations will be applied.
  46772. */
  46773. private _unlit;
  46774. private _debugMode;
  46775. /**
  46776. * @hidden
  46777. * This is reserved for the inspector.
  46778. * Defines the material debug mode.
  46779. * It helps seeing only some components of the material while troubleshooting.
  46780. */
  46781. debugMode: number;
  46782. /**
  46783. * @hidden
  46784. * This is reserved for the inspector.
  46785. * Specify from where on screen the debug mode should start.
  46786. * The value goes from -1 (full screen) to 1 (not visible)
  46787. * It helps with side by side comparison against the final render
  46788. * This defaults to -1
  46789. */
  46790. private debugLimit;
  46791. /**
  46792. * @hidden
  46793. * This is reserved for the inspector.
  46794. * As the default viewing range might not be enough (if the ambient is really small for instance)
  46795. * You can use the factor to better multiply the final value.
  46796. */
  46797. private debugFactor;
  46798. /**
  46799. * Defines the clear coat layer parameters for the material.
  46800. */
  46801. readonly clearCoat: PBRClearCoatConfiguration;
  46802. /**
  46803. * Defines the anisotropic parameters for the material.
  46804. */
  46805. readonly anisotropy: PBRAnisotropicConfiguration;
  46806. /**
  46807. * Defines the BRDF parameters for the material.
  46808. */
  46809. readonly brdf: PBRBRDFConfiguration;
  46810. /**
  46811. * Defines the Sheen parameters for the material.
  46812. */
  46813. readonly sheen: PBRSheenConfiguration;
  46814. /**
  46815. * Defines the SubSurface parameters for the material.
  46816. */
  46817. readonly subSurface: PBRSubSurfaceConfiguration;
  46818. /**
  46819. * Custom callback helping to override the default shader used in the material.
  46820. */
  46821. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  46822. /**
  46823. * Instantiates a new PBRMaterial instance.
  46824. *
  46825. * @param name The material name
  46826. * @param scene The scene the material will be use in.
  46827. */
  46828. constructor(name: string, scene: Scene);
  46829. /**
  46830. * Gets a boolean indicating that current material needs to register RTT
  46831. */
  46832. readonly hasRenderTargetTextures: boolean;
  46833. /**
  46834. * Gets the name of the material class.
  46835. */
  46836. getClassName(): string;
  46837. /**
  46838. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  46839. */
  46840. /**
  46841. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  46842. */
  46843. useLogarithmicDepth: boolean;
  46844. /**
  46845. * Gets the current transparency mode.
  46846. */
  46847. /**
  46848. * Sets the transparency mode of the material.
  46849. *
  46850. * | Value | Type | Description |
  46851. * | ----- | ----------------------------------- | ----------- |
  46852. * | 0 | OPAQUE | |
  46853. * | 1 | ALPHATEST | |
  46854. * | 2 | ALPHABLEND | |
  46855. * | 3 | ALPHATESTANDBLEND | |
  46856. *
  46857. */
  46858. transparencyMode: Nullable<number>;
  46859. /**
  46860. * Returns true if alpha blending should be disabled.
  46861. */
  46862. private readonly _disableAlphaBlending;
  46863. /**
  46864. * Specifies whether or not this material should be rendered in alpha blend mode.
  46865. */
  46866. needAlphaBlending(): boolean;
  46867. /**
  46868. * Specifies if the mesh will require alpha blending.
  46869. * @param mesh - BJS mesh.
  46870. */
  46871. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  46872. /**
  46873. * Specifies whether or not this material should be rendered in alpha test mode.
  46874. */
  46875. needAlphaTesting(): boolean;
  46876. /**
  46877. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  46878. */
  46879. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  46880. /**
  46881. * Gets the texture used for the alpha test.
  46882. */
  46883. getAlphaTestTexture(): BaseTexture;
  46884. /**
  46885. * Specifies that the submesh is ready to be used.
  46886. * @param mesh - BJS mesh.
  46887. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  46888. * @param useInstances - Specifies that instances should be used.
  46889. * @returns - boolean indicating that the submesh is ready or not.
  46890. */
  46891. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  46892. /**
  46893. * Specifies if the material uses metallic roughness workflow.
  46894. * @returns boolean specifiying if the material uses metallic roughness workflow.
  46895. */
  46896. isMetallicWorkflow(): boolean;
  46897. private _prepareEffect;
  46898. private _prepareDefines;
  46899. /**
  46900. * Force shader compilation
  46901. */
  46902. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  46903. clipPlane: boolean;
  46904. }>): void;
  46905. /**
  46906. * Initializes the uniform buffer layout for the shader.
  46907. */
  46908. buildUniformLayout(): void;
  46909. /**
  46910. * Unbinds the material from the mesh
  46911. */
  46912. unbind(): void;
  46913. /**
  46914. * Binds the submesh data.
  46915. * @param world - The world matrix.
  46916. * @param mesh - The BJS mesh.
  46917. * @param subMesh - A submesh of the BJS mesh.
  46918. */
  46919. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  46920. /**
  46921. * Returns the animatable textures.
  46922. * @returns - Array of animatable textures.
  46923. */
  46924. getAnimatables(): IAnimatable[];
  46925. /**
  46926. * Returns the texture used for reflections.
  46927. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  46928. */
  46929. private _getReflectionTexture;
  46930. /**
  46931. * Returns an array of the actively used textures.
  46932. * @returns - Array of BaseTextures
  46933. */
  46934. getActiveTextures(): BaseTexture[];
  46935. /**
  46936. * Checks to see if a texture is used in the material.
  46937. * @param texture - Base texture to use.
  46938. * @returns - Boolean specifying if a texture is used in the material.
  46939. */
  46940. hasTexture(texture: BaseTexture): boolean;
  46941. /**
  46942. * Disposes the resources of the material.
  46943. * @param forceDisposeEffect - Forces the disposal of effects.
  46944. * @param forceDisposeTextures - Forces the disposal of all textures.
  46945. */
  46946. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  46947. }
  46948. }
  46949. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  46950. import { Nullable } from "babylonjs/types";
  46951. import { Scene } from "babylonjs/scene";
  46952. import { Color3 } from "babylonjs/Maths/math";
  46953. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  46954. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  46955. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46956. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  46957. /**
  46958. * The Physically based material of BJS.
  46959. *
  46960. * This offers the main features of a standard PBR material.
  46961. * For more information, please refer to the documentation :
  46962. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  46963. */
  46964. export class PBRMaterial extends PBRBaseMaterial {
  46965. /**
  46966. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  46967. */
  46968. static readonly PBRMATERIAL_OPAQUE: number;
  46969. /**
  46970. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  46971. */
  46972. static readonly PBRMATERIAL_ALPHATEST: number;
  46973. /**
  46974. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  46975. */
  46976. static readonly PBRMATERIAL_ALPHABLEND: number;
  46977. /**
  46978. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  46979. * They are also discarded below the alpha cutoff threshold to improve performances.
  46980. */
  46981. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  46982. /**
  46983. * Defines the default value of how much AO map is occluding the analytical lights
  46984. * (point spot...).
  46985. */
  46986. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  46987. /**
  46988. * Intensity of the direct lights e.g. the four lights available in your scene.
  46989. * This impacts both the direct diffuse and specular highlights.
  46990. */
  46991. directIntensity: number;
  46992. /**
  46993. * Intensity of the emissive part of the material.
  46994. * This helps controlling the emissive effect without modifying the emissive color.
  46995. */
  46996. emissiveIntensity: number;
  46997. /**
  46998. * Intensity of the environment e.g. how much the environment will light the object
  46999. * either through harmonics for rough material or through the refelction for shiny ones.
  47000. */
  47001. environmentIntensity: number;
  47002. /**
  47003. * This is a special control allowing the reduction of the specular highlights coming from the
  47004. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  47005. */
  47006. specularIntensity: number;
  47007. /**
  47008. * Debug Control allowing disabling the bump map on this material.
  47009. */
  47010. disableBumpMap: boolean;
  47011. /**
  47012. * AKA Diffuse Texture in standard nomenclature.
  47013. */
  47014. albedoTexture: BaseTexture;
  47015. /**
  47016. * AKA Occlusion Texture in other nomenclature.
  47017. */
  47018. ambientTexture: BaseTexture;
  47019. /**
  47020. * AKA Occlusion Texture Intensity in other nomenclature.
  47021. */
  47022. ambientTextureStrength: number;
  47023. /**
  47024. * Defines how much the AO map is occluding the analytical lights (point spot...).
  47025. * 1 means it completely occludes it
  47026. * 0 mean it has no impact
  47027. */
  47028. ambientTextureImpactOnAnalyticalLights: number;
  47029. /**
  47030. * Stores the alpha values in a texture.
  47031. */
  47032. opacityTexture: BaseTexture;
  47033. /**
  47034. * Stores the reflection values in a texture.
  47035. */
  47036. reflectionTexture: Nullable<BaseTexture>;
  47037. /**
  47038. * Stores the emissive values in a texture.
  47039. */
  47040. emissiveTexture: BaseTexture;
  47041. /**
  47042. * AKA Specular texture in other nomenclature.
  47043. */
  47044. reflectivityTexture: BaseTexture;
  47045. /**
  47046. * Used to switch from specular/glossiness to metallic/roughness workflow.
  47047. */
  47048. metallicTexture: BaseTexture;
  47049. /**
  47050. * Specifies the metallic scalar of the metallic/roughness workflow.
  47051. * Can also be used to scale the metalness values of the metallic texture.
  47052. */
  47053. metallic: Nullable<number>;
  47054. /**
  47055. * Specifies the roughness scalar of the metallic/roughness workflow.
  47056. * Can also be used to scale the roughness values of the metallic texture.
  47057. */
  47058. roughness: Nullable<number>;
  47059. /**
  47060. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  47061. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  47062. */
  47063. microSurfaceTexture: BaseTexture;
  47064. /**
  47065. * Stores surface normal data used to displace a mesh in a texture.
  47066. */
  47067. bumpTexture: BaseTexture;
  47068. /**
  47069. * Stores the pre-calculated light information of a mesh in a texture.
  47070. */
  47071. lightmapTexture: BaseTexture;
  47072. /**
  47073. * Stores the refracted light information in a texture.
  47074. */
  47075. refractionTexture: Nullable<BaseTexture>;
  47076. /**
  47077. * The color of a material in ambient lighting.
  47078. */
  47079. ambientColor: Color3;
  47080. /**
  47081. * AKA Diffuse Color in other nomenclature.
  47082. */
  47083. albedoColor: Color3;
  47084. /**
  47085. * AKA Specular Color in other nomenclature.
  47086. */
  47087. reflectivityColor: Color3;
  47088. /**
  47089. * The color reflected from the material.
  47090. */
  47091. reflectionColor: Color3;
  47092. /**
  47093. * The color emitted from the material.
  47094. */
  47095. emissiveColor: Color3;
  47096. /**
  47097. * AKA Glossiness in other nomenclature.
  47098. */
  47099. microSurface: number;
  47100. /**
  47101. * source material index of refraction (IOR)' / 'destination material IOR.
  47102. */
  47103. indexOfRefraction: number;
  47104. /**
  47105. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  47106. */
  47107. invertRefractionY: boolean;
  47108. /**
  47109. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  47110. * Materials half opaque for instance using refraction could benefit from this control.
  47111. */
  47112. linkRefractionWithTransparency: boolean;
  47113. /**
  47114. * If true, the light map contains occlusion information instead of lighting info.
  47115. */
  47116. useLightmapAsShadowmap: boolean;
  47117. /**
  47118. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  47119. */
  47120. useAlphaFromAlbedoTexture: boolean;
  47121. /**
  47122. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  47123. */
  47124. forceAlphaTest: boolean;
  47125. /**
  47126. * Defines the alpha limits in alpha test mode.
  47127. */
  47128. alphaCutOff: number;
  47129. /**
  47130. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  47131. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  47132. */
  47133. useSpecularOverAlpha: boolean;
  47134. /**
  47135. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  47136. */
  47137. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  47138. /**
  47139. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  47140. */
  47141. useRoughnessFromMetallicTextureAlpha: boolean;
  47142. /**
  47143. * Specifies if the metallic texture contains the roughness information in its green channel.
  47144. */
  47145. useRoughnessFromMetallicTextureGreen: boolean;
  47146. /**
  47147. * Specifies if the metallic texture contains the metallness information in its blue channel.
  47148. */
  47149. useMetallnessFromMetallicTextureBlue: boolean;
  47150. /**
  47151. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  47152. */
  47153. useAmbientOcclusionFromMetallicTextureRed: boolean;
  47154. /**
  47155. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  47156. */
  47157. useAmbientInGrayScale: boolean;
  47158. /**
  47159. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  47160. * The material will try to infer what glossiness each pixel should be.
  47161. */
  47162. useAutoMicroSurfaceFromReflectivityMap: boolean;
  47163. /**
  47164. * BJS is using an harcoded light falloff based on a manually sets up range.
  47165. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  47166. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  47167. */
  47168. /**
  47169. * BJS is using an harcoded light falloff based on a manually sets up range.
  47170. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  47171. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  47172. */
  47173. usePhysicalLightFalloff: boolean;
  47174. /**
  47175. * In order to support the falloff compatibility with gltf, a special mode has been added
  47176. * to reproduce the gltf light falloff.
  47177. */
  47178. /**
  47179. * In order to support the falloff compatibility with gltf, a special mode has been added
  47180. * to reproduce the gltf light falloff.
  47181. */
  47182. useGLTFLightFalloff: boolean;
  47183. /**
  47184. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  47185. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  47186. */
  47187. useRadianceOverAlpha: boolean;
  47188. /**
  47189. * Allows using an object space normal map (instead of tangent space).
  47190. */
  47191. useObjectSpaceNormalMap: boolean;
  47192. /**
  47193. * Allows using the bump map in parallax mode.
  47194. */
  47195. useParallax: boolean;
  47196. /**
  47197. * Allows using the bump map in parallax occlusion mode.
  47198. */
  47199. useParallaxOcclusion: boolean;
  47200. /**
  47201. * Controls the scale bias of the parallax mode.
  47202. */
  47203. parallaxScaleBias: number;
  47204. /**
  47205. * If sets to true, disables all the lights affecting the material.
  47206. */
  47207. disableLighting: boolean;
  47208. /**
  47209. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  47210. */
  47211. forceIrradianceInFragment: boolean;
  47212. /**
  47213. * Number of Simultaneous lights allowed on the material.
  47214. */
  47215. maxSimultaneousLights: number;
  47216. /**
  47217. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  47218. */
  47219. invertNormalMapX: boolean;
  47220. /**
  47221. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  47222. */
  47223. invertNormalMapY: boolean;
  47224. /**
  47225. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  47226. */
  47227. twoSidedLighting: boolean;
  47228. /**
  47229. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  47230. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  47231. */
  47232. useAlphaFresnel: boolean;
  47233. /**
  47234. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  47235. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  47236. */
  47237. useLinearAlphaFresnel: boolean;
  47238. /**
  47239. * Let user defines the brdf lookup texture used for IBL.
  47240. * A default 8bit version is embedded but you could point at :
  47241. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.png
  47242. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  47243. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  47244. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  47245. */
  47246. environmentBRDFTexture: Nullable<BaseTexture>;
  47247. /**
  47248. * Force normal to face away from face.
  47249. */
  47250. forceNormalForward: boolean;
  47251. /**
  47252. * Enables specular anti aliasing in the PBR shader.
  47253. * It will both interacts on the Geometry for analytical and IBL lighting.
  47254. * It also prefilter the roughness map based on the bump values.
  47255. */
  47256. enableSpecularAntiAliasing: boolean;
  47257. /**
  47258. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  47259. * makes the reflect vector face the model (under horizon).
  47260. */
  47261. useHorizonOcclusion: boolean;
  47262. /**
  47263. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  47264. * too much the area relying on ambient texture to define their ambient occlusion.
  47265. */
  47266. useRadianceOcclusion: boolean;
  47267. /**
  47268. * If set to true, no lighting calculations will be applied.
  47269. */
  47270. unlit: boolean;
  47271. /**
  47272. * Gets the image processing configuration used either in this material.
  47273. */
  47274. /**
  47275. * Sets the Default image processing configuration used either in the this material.
  47276. *
  47277. * If sets to null, the scene one is in use.
  47278. */
  47279. imageProcessingConfiguration: ImageProcessingConfiguration;
  47280. /**
  47281. * Gets wether the color curves effect is enabled.
  47282. */
  47283. /**
  47284. * Sets wether the color curves effect is enabled.
  47285. */
  47286. cameraColorCurvesEnabled: boolean;
  47287. /**
  47288. * Gets wether the color grading effect is enabled.
  47289. */
  47290. /**
  47291. * Gets wether the color grading effect is enabled.
  47292. */
  47293. cameraColorGradingEnabled: boolean;
  47294. /**
  47295. * Gets wether tonemapping is enabled or not.
  47296. */
  47297. /**
  47298. * Sets wether tonemapping is enabled or not
  47299. */
  47300. cameraToneMappingEnabled: boolean;
  47301. /**
  47302. * The camera exposure used on this material.
  47303. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  47304. * This corresponds to a photographic exposure.
  47305. */
  47306. /**
  47307. * The camera exposure used on this material.
  47308. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  47309. * This corresponds to a photographic exposure.
  47310. */
  47311. cameraExposure: number;
  47312. /**
  47313. * Gets The camera contrast used on this material.
  47314. */
  47315. /**
  47316. * Sets The camera contrast used on this material.
  47317. */
  47318. cameraContrast: number;
  47319. /**
  47320. * Gets the Color Grading 2D Lookup Texture.
  47321. */
  47322. /**
  47323. * Sets the Color Grading 2D Lookup Texture.
  47324. */
  47325. cameraColorGradingTexture: Nullable<BaseTexture>;
  47326. /**
  47327. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  47328. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  47329. * 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;
  47330. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  47331. */
  47332. /**
  47333. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  47334. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  47335. * 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;
  47336. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  47337. */
  47338. cameraColorCurves: Nullable<ColorCurves>;
  47339. /**
  47340. * Instantiates a new PBRMaterial instance.
  47341. *
  47342. * @param name The material name
  47343. * @param scene The scene the material will be use in.
  47344. */
  47345. constructor(name: string, scene: Scene);
  47346. /**
  47347. * Returns the name of this material class.
  47348. */
  47349. getClassName(): string;
  47350. /**
  47351. * Makes a duplicate of the current material.
  47352. * @param name - name to use for the new material.
  47353. */
  47354. clone(name: string): PBRMaterial;
  47355. /**
  47356. * Serializes this PBR Material.
  47357. * @returns - An object with the serialized material.
  47358. */
  47359. serialize(): any;
  47360. /**
  47361. * Parses a PBR Material from a serialized object.
  47362. * @param source - Serialized object.
  47363. * @param scene - BJS scene instance.
  47364. * @param rootUrl - url for the scene object
  47365. * @returns - PBRMaterial
  47366. */
  47367. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  47368. }
  47369. }
  47370. declare module "babylonjs/Misc/dds" {
  47371. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  47372. import { Engine } from "babylonjs/Engines/engine";
  47373. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  47374. import { Nullable } from "babylonjs/types";
  47375. import { Scene } from "babylonjs/scene";
  47376. /**
  47377. * Direct draw surface info
  47378. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  47379. */
  47380. export interface DDSInfo {
  47381. /**
  47382. * Width of the texture
  47383. */
  47384. width: number;
  47385. /**
  47386. * Width of the texture
  47387. */
  47388. height: number;
  47389. /**
  47390. * Number of Mipmaps for the texture
  47391. * @see https://en.wikipedia.org/wiki/Mipmap
  47392. */
  47393. mipmapCount: number;
  47394. /**
  47395. * If the textures format is a known fourCC format
  47396. * @see https://www.fourcc.org/
  47397. */
  47398. isFourCC: boolean;
  47399. /**
  47400. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  47401. */
  47402. isRGB: boolean;
  47403. /**
  47404. * If the texture is a lumincance format
  47405. */
  47406. isLuminance: boolean;
  47407. /**
  47408. * If this is a cube texture
  47409. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  47410. */
  47411. isCube: boolean;
  47412. /**
  47413. * If the texture is a compressed format eg. FOURCC_DXT1
  47414. */
  47415. isCompressed: boolean;
  47416. /**
  47417. * The dxgiFormat of the texture
  47418. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  47419. */
  47420. dxgiFormat: number;
  47421. /**
  47422. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  47423. */
  47424. textureType: number;
  47425. /**
  47426. * Sphericle polynomial created for the dds texture
  47427. */
  47428. sphericalPolynomial?: SphericalPolynomial;
  47429. }
  47430. /**
  47431. * Class used to provide DDS decompression tools
  47432. */
  47433. export class DDSTools {
  47434. /**
  47435. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  47436. */
  47437. static StoreLODInAlphaChannel: boolean;
  47438. /**
  47439. * Gets DDS information from an array buffer
  47440. * @param arrayBuffer defines the array buffer to read data from
  47441. * @returns the DDS information
  47442. */
  47443. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  47444. private static _FloatView;
  47445. private static _Int32View;
  47446. private static _ToHalfFloat;
  47447. private static _FromHalfFloat;
  47448. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  47449. private static _GetHalfFloatRGBAArrayBuffer;
  47450. private static _GetFloatRGBAArrayBuffer;
  47451. private static _GetFloatAsUIntRGBAArrayBuffer;
  47452. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  47453. private static _GetRGBAArrayBuffer;
  47454. private static _ExtractLongWordOrder;
  47455. private static _GetRGBArrayBuffer;
  47456. private static _GetLuminanceArrayBuffer;
  47457. /**
  47458. * Uploads DDS Levels to a Babylon Texture
  47459. * @hidden
  47460. */
  47461. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  47462. }
  47463. module "babylonjs/Engines/engine" {
  47464. interface Engine {
  47465. /**
  47466. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  47467. * @param rootUrl defines the url where the file to load is located
  47468. * @param scene defines the current scene
  47469. * @param lodScale defines scale to apply to the mip map selection
  47470. * @param lodOffset defines offset to apply to the mip map selection
  47471. * @param onLoad defines an optional callback raised when the texture is loaded
  47472. * @param onError defines an optional callback raised if there is an issue to load the texture
  47473. * @param format defines the format of the data
  47474. * @param forcedExtension defines the extension to use to pick the right loader
  47475. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  47476. * @returns the cube texture as an InternalTexture
  47477. */
  47478. 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;
  47479. }
  47480. }
  47481. }
  47482. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  47483. import { Nullable } from "babylonjs/types";
  47484. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  47485. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  47486. /**
  47487. * Implementation of the DDS Texture Loader.
  47488. * @hidden
  47489. */
  47490. export class _DDSTextureLoader implements IInternalTextureLoader {
  47491. /**
  47492. * Defines wether the loader supports cascade loading the different faces.
  47493. */
  47494. readonly supportCascades: boolean;
  47495. /**
  47496. * This returns if the loader support the current file information.
  47497. * @param extension defines the file extension of the file being loaded
  47498. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47499. * @param fallback defines the fallback internal texture if any
  47500. * @param isBase64 defines whether the texture is encoded as a base64
  47501. * @param isBuffer defines whether the texture data are stored as a buffer
  47502. * @returns true if the loader can load the specified file
  47503. */
  47504. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  47505. /**
  47506. * Transform the url before loading if required.
  47507. * @param rootUrl the url of the texture
  47508. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47509. * @returns the transformed texture
  47510. */
  47511. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  47512. /**
  47513. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  47514. * @param rootUrl the url of the texture
  47515. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47516. * @returns the fallback texture
  47517. */
  47518. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  47519. /**
  47520. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  47521. * @param data contains the texture data
  47522. * @param texture defines the BabylonJS internal texture
  47523. * @param createPolynomials will be true if polynomials have been requested
  47524. * @param onLoad defines the callback to trigger once the texture is ready
  47525. * @param onError defines the callback to trigger in case of error
  47526. */
  47527. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  47528. /**
  47529. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  47530. * @param data contains the texture data
  47531. * @param texture defines the BabylonJS internal texture
  47532. * @param callback defines the method to call once ready to upload
  47533. */
  47534. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  47535. }
  47536. }
  47537. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  47538. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  47539. /** @hidden */
  47540. export var rgbdEncodePixelShader: {
  47541. name: string;
  47542. shader: string;
  47543. };
  47544. }
  47545. declare module "babylonjs/Misc/environmentTextureTools" {
  47546. import { Nullable } from "babylonjs/types";
  47547. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  47548. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  47549. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  47550. import "babylonjs/Shaders/rgbdEncode.fragment";
  47551. import "babylonjs/Shaders/rgbdDecode.fragment";
  47552. /**
  47553. * Raw texture data and descriptor sufficient for WebGL texture upload
  47554. */
  47555. export interface EnvironmentTextureInfo {
  47556. /**
  47557. * Version of the environment map
  47558. */
  47559. version: number;
  47560. /**
  47561. * Width of image
  47562. */
  47563. width: number;
  47564. /**
  47565. * Irradiance information stored in the file.
  47566. */
  47567. irradiance: any;
  47568. /**
  47569. * Specular information stored in the file.
  47570. */
  47571. specular: any;
  47572. }
  47573. /**
  47574. * Sets of helpers addressing the serialization and deserialization of environment texture
  47575. * stored in a BabylonJS env file.
  47576. * Those files are usually stored as .env files.
  47577. */
  47578. export class EnvironmentTextureTools {
  47579. /**
  47580. * Magic number identifying the env file.
  47581. */
  47582. private static _MagicBytes;
  47583. /**
  47584. * Gets the environment info from an env file.
  47585. * @param data The array buffer containing the .env bytes.
  47586. * @returns the environment file info (the json header) if successfully parsed.
  47587. */
  47588. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  47589. /**
  47590. * Creates an environment texture from a loaded cube texture.
  47591. * @param texture defines the cube texture to convert in env file
  47592. * @return a promise containing the environment data if succesfull.
  47593. */
  47594. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  47595. /**
  47596. * Creates a JSON representation of the spherical data.
  47597. * @param texture defines the texture containing the polynomials
  47598. * @return the JSON representation of the spherical info
  47599. */
  47600. private static _CreateEnvTextureIrradiance;
  47601. /**
  47602. * Uploads the texture info contained in the env file to the GPU.
  47603. * @param texture defines the internal texture to upload to
  47604. * @param arrayBuffer defines the buffer cotaining the data to load
  47605. * @param info defines the texture info retrieved through the GetEnvInfo method
  47606. * @returns a promise
  47607. */
  47608. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  47609. /**
  47610. * Uploads the levels of image data to the GPU.
  47611. * @param texture defines the internal texture to upload to
  47612. * @param imageData defines the array buffer views of image data [mipmap][face]
  47613. * @returns a promise
  47614. */
  47615. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  47616. /**
  47617. * Uploads spherical polynomials information to the texture.
  47618. * @param texture defines the texture we are trying to upload the information to
  47619. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  47620. */
  47621. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  47622. /** @hidden */
  47623. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  47624. }
  47625. }
  47626. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  47627. import { Nullable } from "babylonjs/types";
  47628. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  47629. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  47630. /**
  47631. * Implementation of the ENV Texture Loader.
  47632. * @hidden
  47633. */
  47634. export class _ENVTextureLoader implements IInternalTextureLoader {
  47635. /**
  47636. * Defines wether the loader supports cascade loading the different faces.
  47637. */
  47638. readonly supportCascades: boolean;
  47639. /**
  47640. * This returns if the loader support the current file information.
  47641. * @param extension defines the file extension of the file being loaded
  47642. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47643. * @param fallback defines the fallback internal texture if any
  47644. * @param isBase64 defines whether the texture is encoded as a base64
  47645. * @param isBuffer defines whether the texture data are stored as a buffer
  47646. * @returns true if the loader can load the specified file
  47647. */
  47648. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  47649. /**
  47650. * Transform the url before loading if required.
  47651. * @param rootUrl the url of the texture
  47652. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47653. * @returns the transformed texture
  47654. */
  47655. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  47656. /**
  47657. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  47658. * @param rootUrl the url of the texture
  47659. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47660. * @returns the fallback texture
  47661. */
  47662. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  47663. /**
  47664. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  47665. * @param data contains the texture data
  47666. * @param texture defines the BabylonJS internal texture
  47667. * @param createPolynomials will be true if polynomials have been requested
  47668. * @param onLoad defines the callback to trigger once the texture is ready
  47669. * @param onError defines the callback to trigger in case of error
  47670. */
  47671. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  47672. /**
  47673. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  47674. * @param data contains the texture data
  47675. * @param texture defines the BabylonJS internal texture
  47676. * @param callback defines the method to call once ready to upload
  47677. */
  47678. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  47679. }
  47680. }
  47681. declare module "babylonjs/Misc/khronosTextureContainer" {
  47682. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  47683. /**
  47684. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  47685. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  47686. */
  47687. export class KhronosTextureContainer {
  47688. /** contents of the KTX container file */
  47689. arrayBuffer: any;
  47690. private static HEADER_LEN;
  47691. private static COMPRESSED_2D;
  47692. private static COMPRESSED_3D;
  47693. private static TEX_2D;
  47694. private static TEX_3D;
  47695. /**
  47696. * Gets the openGL type
  47697. */
  47698. glType: number;
  47699. /**
  47700. * Gets the openGL type size
  47701. */
  47702. glTypeSize: number;
  47703. /**
  47704. * Gets the openGL format
  47705. */
  47706. glFormat: number;
  47707. /**
  47708. * Gets the openGL internal format
  47709. */
  47710. glInternalFormat: number;
  47711. /**
  47712. * Gets the base internal format
  47713. */
  47714. glBaseInternalFormat: number;
  47715. /**
  47716. * Gets image width in pixel
  47717. */
  47718. pixelWidth: number;
  47719. /**
  47720. * Gets image height in pixel
  47721. */
  47722. pixelHeight: number;
  47723. /**
  47724. * Gets image depth in pixels
  47725. */
  47726. pixelDepth: number;
  47727. /**
  47728. * Gets the number of array elements
  47729. */
  47730. numberOfArrayElements: number;
  47731. /**
  47732. * Gets the number of faces
  47733. */
  47734. numberOfFaces: number;
  47735. /**
  47736. * Gets the number of mipmap levels
  47737. */
  47738. numberOfMipmapLevels: number;
  47739. /**
  47740. * Gets the bytes of key value data
  47741. */
  47742. bytesOfKeyValueData: number;
  47743. /**
  47744. * Gets the load type
  47745. */
  47746. loadType: number;
  47747. /**
  47748. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  47749. */
  47750. isInvalid: boolean;
  47751. /**
  47752. * Creates a new KhronosTextureContainer
  47753. * @param arrayBuffer contents of the KTX container file
  47754. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  47755. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  47756. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  47757. */
  47758. constructor(
  47759. /** contents of the KTX container file */
  47760. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  47761. /**
  47762. * Uploads KTX content to a Babylon Texture.
  47763. * It is assumed that the texture has already been created & is currently bound
  47764. * @hidden
  47765. */
  47766. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  47767. private _upload2DCompressedLevels;
  47768. }
  47769. }
  47770. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  47771. import { Nullable } from "babylonjs/types";
  47772. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  47773. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  47774. /**
  47775. * Implementation of the KTX Texture Loader.
  47776. * @hidden
  47777. */
  47778. export class _KTXTextureLoader implements IInternalTextureLoader {
  47779. /**
  47780. * Defines wether the loader supports cascade loading the different faces.
  47781. */
  47782. readonly supportCascades: boolean;
  47783. /**
  47784. * This returns if the loader support the current file information.
  47785. * @param extension defines the file extension of the file being loaded
  47786. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47787. * @param fallback defines the fallback internal texture if any
  47788. * @param isBase64 defines whether the texture is encoded as a base64
  47789. * @param isBuffer defines whether the texture data are stored as a buffer
  47790. * @returns true if the loader can load the specified file
  47791. */
  47792. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  47793. /**
  47794. * Transform the url before loading if required.
  47795. * @param rootUrl the url of the texture
  47796. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47797. * @returns the transformed texture
  47798. */
  47799. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  47800. /**
  47801. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  47802. * @param rootUrl the url of the texture
  47803. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47804. * @returns the fallback texture
  47805. */
  47806. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  47807. /**
  47808. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  47809. * @param data contains the texture data
  47810. * @param texture defines the BabylonJS internal texture
  47811. * @param createPolynomials will be true if polynomials have been requested
  47812. * @param onLoad defines the callback to trigger once the texture is ready
  47813. * @param onError defines the callback to trigger in case of error
  47814. */
  47815. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  47816. /**
  47817. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  47818. * @param data contains the texture data
  47819. * @param texture defines the BabylonJS internal texture
  47820. * @param callback defines the method to call once ready to upload
  47821. */
  47822. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  47823. }
  47824. }
  47825. declare module "babylonjs/Helpers/sceneHelpers" {
  47826. import { Nullable } from "babylonjs/types";
  47827. import { Mesh } from "babylonjs/Meshes/mesh";
  47828. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47829. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  47830. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  47831. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  47832. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  47833. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  47834. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  47835. import "babylonjs/Meshes/Builders/boxBuilder";
  47836. /** @hidden */
  47837. export var _forceSceneHelpersToBundle: boolean;
  47838. module "babylonjs/scene" {
  47839. interface Scene {
  47840. /**
  47841. * Creates a default light for the scene.
  47842. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  47843. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  47844. */
  47845. createDefaultLight(replace?: boolean): void;
  47846. /**
  47847. * Creates a default camera for the scene.
  47848. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  47849. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  47850. * @param replace has default false, when true replaces the active camera in the scene
  47851. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  47852. */
  47853. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  47854. /**
  47855. * Creates a default camera and a default light.
  47856. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  47857. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  47858. * @param replace has the default false, when true replaces the active camera/light in the scene
  47859. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  47860. */
  47861. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  47862. /**
  47863. * Creates a new sky box
  47864. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  47865. * @param environmentTexture defines the texture to use as environment texture
  47866. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  47867. * @param scale defines the overall scale of the skybox
  47868. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  47869. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  47870. * @returns a new mesh holding the sky box
  47871. */
  47872. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  47873. /**
  47874. * Creates a new environment
  47875. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  47876. * @param options defines the options you can use to configure the environment
  47877. * @returns the new EnvironmentHelper
  47878. */
  47879. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  47880. /**
  47881. * Creates a new VREXperienceHelper
  47882. * @see http://doc.babylonjs.com/how_to/webvr_helper
  47883. * @param webVROptions defines the options used to create the new VREXperienceHelper
  47884. * @returns a new VREXperienceHelper
  47885. */
  47886. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  47887. /**
  47888. * Creates a new XREXperienceHelper
  47889. * @see http://doc.babylonjs.com/how_to/webxr
  47890. * @returns a promise for a new XREXperienceHelper
  47891. */
  47892. createDefaultXRExperienceAsync(): Promise<WebXRExperienceHelper>;
  47893. }
  47894. }
  47895. }
  47896. declare module "babylonjs/Helpers/videoDome" {
  47897. import { Scene } from "babylonjs/scene";
  47898. import { TransformNode } from "babylonjs/Meshes/transformNode";
  47899. import { Mesh } from "babylonjs/Meshes/mesh";
  47900. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  47901. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  47902. import "babylonjs/Meshes/Builders/sphereBuilder";
  47903. /**
  47904. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  47905. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  47906. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  47907. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  47908. */
  47909. export class VideoDome extends TransformNode {
  47910. /**
  47911. * Define the video source as a Monoscopic panoramic 360 video.
  47912. */
  47913. static readonly MODE_MONOSCOPIC: number;
  47914. /**
  47915. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  47916. */
  47917. static readonly MODE_TOPBOTTOM: number;
  47918. /**
  47919. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  47920. */
  47921. static readonly MODE_SIDEBYSIDE: number;
  47922. private _useDirectMapping;
  47923. /**
  47924. * The video texture being displayed on the sphere
  47925. */
  47926. protected _videoTexture: VideoTexture;
  47927. /**
  47928. * Gets the video texture being displayed on the sphere
  47929. */
  47930. readonly videoTexture: VideoTexture;
  47931. /**
  47932. * The skybox material
  47933. */
  47934. protected _material: BackgroundMaterial;
  47935. /**
  47936. * The surface used for the skybox
  47937. */
  47938. protected _mesh: Mesh;
  47939. /**
  47940. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  47941. * Also see the options.resolution property.
  47942. */
  47943. fovMultiplier: number;
  47944. private _videoMode;
  47945. /**
  47946. * Gets or set the current video mode for the video. It can be:
  47947. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  47948. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  47949. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  47950. */
  47951. videoMode: number;
  47952. /**
  47953. * Oberserver used in Stereoscopic VR Mode.
  47954. */
  47955. private _onBeforeCameraRenderObserver;
  47956. /**
  47957. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  47958. * @param name Element's name, child elements will append suffixes for their own names.
  47959. * @param urlsOrVideo defines the url(s) or the video element to use
  47960. * @param options An object containing optional or exposed sub element properties
  47961. */
  47962. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  47963. resolution?: number;
  47964. clickToPlay?: boolean;
  47965. autoPlay?: boolean;
  47966. loop?: boolean;
  47967. size?: number;
  47968. poster?: string;
  47969. faceForward?: boolean;
  47970. useDirectMapping?: boolean;
  47971. }, scene: Scene);
  47972. private _changeVideoMode;
  47973. /**
  47974. * Releases resources associated with this node.
  47975. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  47976. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  47977. */
  47978. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  47979. }
  47980. }
  47981. declare module "babylonjs/Helpers/index" {
  47982. export * from "babylonjs/Helpers/environmentHelper";
  47983. export * from "babylonjs/Helpers/photoDome";
  47984. export * from "babylonjs/Helpers/sceneHelpers";
  47985. export * from "babylonjs/Helpers/videoDome";
  47986. }
  47987. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  47988. import { PerfCounter } from "babylonjs/Misc/tools";
  47989. import { IDisposable } from "babylonjs/scene";
  47990. import { Engine } from "babylonjs/Engines/engine";
  47991. /**
  47992. * This class can be used to get instrumentation data from a Babylon engine
  47993. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  47994. */
  47995. export class EngineInstrumentation implements IDisposable {
  47996. /**
  47997. * Define the instrumented engine.
  47998. */
  47999. engine: Engine;
  48000. private _captureGPUFrameTime;
  48001. private _gpuFrameTimeToken;
  48002. private _gpuFrameTime;
  48003. private _captureShaderCompilationTime;
  48004. private _shaderCompilationTime;
  48005. private _onBeginFrameObserver;
  48006. private _onEndFrameObserver;
  48007. private _onBeforeShaderCompilationObserver;
  48008. private _onAfterShaderCompilationObserver;
  48009. /**
  48010. * Gets the perf counter used for GPU frame time
  48011. */
  48012. readonly gpuFrameTimeCounter: PerfCounter;
  48013. /**
  48014. * Gets the GPU frame time capture status
  48015. */
  48016. /**
  48017. * Enable or disable the GPU frame time capture
  48018. */
  48019. captureGPUFrameTime: boolean;
  48020. /**
  48021. * Gets the perf counter used for shader compilation time
  48022. */
  48023. readonly shaderCompilationTimeCounter: PerfCounter;
  48024. /**
  48025. * Gets the shader compilation time capture status
  48026. */
  48027. /**
  48028. * Enable or disable the shader compilation time capture
  48029. */
  48030. captureShaderCompilationTime: boolean;
  48031. /**
  48032. * Instantiates a new engine instrumentation.
  48033. * This class can be used to get instrumentation data from a Babylon engine
  48034. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  48035. * @param engine Defines the engine to instrument
  48036. */
  48037. constructor(
  48038. /**
  48039. * Define the instrumented engine.
  48040. */
  48041. engine: Engine);
  48042. /**
  48043. * Dispose and release associated resources.
  48044. */
  48045. dispose(): void;
  48046. }
  48047. }
  48048. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  48049. import { PerfCounter } from "babylonjs/Misc/tools";
  48050. import { Scene, IDisposable } from "babylonjs/scene";
  48051. /**
  48052. * This class can be used to get instrumentation data from a Babylon engine
  48053. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  48054. */
  48055. export class SceneInstrumentation implements IDisposable {
  48056. /**
  48057. * Defines the scene to instrument
  48058. */
  48059. scene: Scene;
  48060. private _captureActiveMeshesEvaluationTime;
  48061. private _activeMeshesEvaluationTime;
  48062. private _captureRenderTargetsRenderTime;
  48063. private _renderTargetsRenderTime;
  48064. private _captureFrameTime;
  48065. private _frameTime;
  48066. private _captureRenderTime;
  48067. private _renderTime;
  48068. private _captureInterFrameTime;
  48069. private _interFrameTime;
  48070. private _captureParticlesRenderTime;
  48071. private _particlesRenderTime;
  48072. private _captureSpritesRenderTime;
  48073. private _spritesRenderTime;
  48074. private _capturePhysicsTime;
  48075. private _physicsTime;
  48076. private _captureAnimationsTime;
  48077. private _animationsTime;
  48078. private _captureCameraRenderTime;
  48079. private _cameraRenderTime;
  48080. private _onBeforeActiveMeshesEvaluationObserver;
  48081. private _onAfterActiveMeshesEvaluationObserver;
  48082. private _onBeforeRenderTargetsRenderObserver;
  48083. private _onAfterRenderTargetsRenderObserver;
  48084. private _onAfterRenderObserver;
  48085. private _onBeforeDrawPhaseObserver;
  48086. private _onAfterDrawPhaseObserver;
  48087. private _onBeforeAnimationsObserver;
  48088. private _onBeforeParticlesRenderingObserver;
  48089. private _onAfterParticlesRenderingObserver;
  48090. private _onBeforeSpritesRenderingObserver;
  48091. private _onAfterSpritesRenderingObserver;
  48092. private _onBeforePhysicsObserver;
  48093. private _onAfterPhysicsObserver;
  48094. private _onAfterAnimationsObserver;
  48095. private _onBeforeCameraRenderObserver;
  48096. private _onAfterCameraRenderObserver;
  48097. /**
  48098. * Gets the perf counter used for active meshes evaluation time
  48099. */
  48100. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  48101. /**
  48102. * Gets the active meshes evaluation time capture status
  48103. */
  48104. /**
  48105. * Enable or disable the active meshes evaluation time capture
  48106. */
  48107. captureActiveMeshesEvaluationTime: boolean;
  48108. /**
  48109. * Gets the perf counter used for render targets render time
  48110. */
  48111. readonly renderTargetsRenderTimeCounter: PerfCounter;
  48112. /**
  48113. * Gets the render targets render time capture status
  48114. */
  48115. /**
  48116. * Enable or disable the render targets render time capture
  48117. */
  48118. captureRenderTargetsRenderTime: boolean;
  48119. /**
  48120. * Gets the perf counter used for particles render time
  48121. */
  48122. readonly particlesRenderTimeCounter: PerfCounter;
  48123. /**
  48124. * Gets the particles render time capture status
  48125. */
  48126. /**
  48127. * Enable or disable the particles render time capture
  48128. */
  48129. captureParticlesRenderTime: boolean;
  48130. /**
  48131. * Gets the perf counter used for sprites render time
  48132. */
  48133. readonly spritesRenderTimeCounter: PerfCounter;
  48134. /**
  48135. * Gets the sprites render time capture status
  48136. */
  48137. /**
  48138. * Enable or disable the sprites render time capture
  48139. */
  48140. captureSpritesRenderTime: boolean;
  48141. /**
  48142. * Gets the perf counter used for physics time
  48143. */
  48144. readonly physicsTimeCounter: PerfCounter;
  48145. /**
  48146. * Gets the physics time capture status
  48147. */
  48148. /**
  48149. * Enable or disable the physics time capture
  48150. */
  48151. capturePhysicsTime: boolean;
  48152. /**
  48153. * Gets the perf counter used for animations time
  48154. */
  48155. readonly animationsTimeCounter: PerfCounter;
  48156. /**
  48157. * Gets the animations time capture status
  48158. */
  48159. /**
  48160. * Enable or disable the animations time capture
  48161. */
  48162. captureAnimationsTime: boolean;
  48163. /**
  48164. * Gets the perf counter used for frame time capture
  48165. */
  48166. readonly frameTimeCounter: PerfCounter;
  48167. /**
  48168. * Gets the frame time capture status
  48169. */
  48170. /**
  48171. * Enable or disable the frame time capture
  48172. */
  48173. captureFrameTime: boolean;
  48174. /**
  48175. * Gets the perf counter used for inter-frames time capture
  48176. */
  48177. readonly interFrameTimeCounter: PerfCounter;
  48178. /**
  48179. * Gets the inter-frames time capture status
  48180. */
  48181. /**
  48182. * Enable or disable the inter-frames time capture
  48183. */
  48184. captureInterFrameTime: boolean;
  48185. /**
  48186. * Gets the perf counter used for render time capture
  48187. */
  48188. readonly renderTimeCounter: PerfCounter;
  48189. /**
  48190. * Gets the render time capture status
  48191. */
  48192. /**
  48193. * Enable or disable the render time capture
  48194. */
  48195. captureRenderTime: boolean;
  48196. /**
  48197. * Gets the perf counter used for camera render time capture
  48198. */
  48199. readonly cameraRenderTimeCounter: PerfCounter;
  48200. /**
  48201. * Gets the camera render time capture status
  48202. */
  48203. /**
  48204. * Enable or disable the camera render time capture
  48205. */
  48206. captureCameraRenderTime: boolean;
  48207. /**
  48208. * Gets the perf counter used for draw calls
  48209. */
  48210. readonly drawCallsCounter: PerfCounter;
  48211. /**
  48212. * Instantiates a new scene instrumentation.
  48213. * This class can be used to get instrumentation data from a Babylon engine
  48214. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  48215. * @param scene Defines the scene to instrument
  48216. */
  48217. constructor(
  48218. /**
  48219. * Defines the scene to instrument
  48220. */
  48221. scene: Scene);
  48222. /**
  48223. * Dispose and release associated resources.
  48224. */
  48225. dispose(): void;
  48226. }
  48227. }
  48228. declare module "babylonjs/Instrumentation/index" {
  48229. export * from "babylonjs/Instrumentation/engineInstrumentation";
  48230. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  48231. export * from "babylonjs/Instrumentation/timeToken";
  48232. }
  48233. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  48234. /** @hidden */
  48235. export var glowMapGenerationPixelShader: {
  48236. name: string;
  48237. shader: string;
  48238. };
  48239. }
  48240. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  48241. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  48242. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  48243. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  48244. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  48245. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  48246. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  48247. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  48248. /** @hidden */
  48249. export var glowMapGenerationVertexShader: {
  48250. name: string;
  48251. shader: string;
  48252. };
  48253. }
  48254. declare module "babylonjs/Layers/effectLayer" {
  48255. import { Observable } from "babylonjs/Misc/observable";
  48256. import { Nullable } from "babylonjs/types";
  48257. import { Camera } from "babylonjs/Cameras/camera";
  48258. import { Scene } from "babylonjs/scene";
  48259. import { Color4, ISize } from "babylonjs/Maths/math";
  48260. import { Engine } from "babylonjs/Engines/engine";
  48261. import { SubMesh } from "babylonjs/Meshes/subMesh";
  48262. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48263. import { Mesh } from "babylonjs/Meshes/mesh";
  48264. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  48265. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48266. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  48267. import { Effect } from "babylonjs/Materials/effect";
  48268. import { Material } from "babylonjs/Materials/material";
  48269. import "babylonjs/Shaders/glowMapGeneration.fragment";
  48270. import "babylonjs/Shaders/glowMapGeneration.vertex";
  48271. /**
  48272. * Effect layer options. This helps customizing the behaviour
  48273. * of the effect layer.
  48274. */
  48275. export interface IEffectLayerOptions {
  48276. /**
  48277. * Multiplication factor apply to the canvas size to compute the render target size
  48278. * used to generated the objects (the smaller the faster).
  48279. */
  48280. mainTextureRatio: number;
  48281. /**
  48282. * Enforces a fixed size texture to ensure effect stability across devices.
  48283. */
  48284. mainTextureFixedSize?: number;
  48285. /**
  48286. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  48287. */
  48288. alphaBlendingMode: number;
  48289. /**
  48290. * The camera attached to the layer.
  48291. */
  48292. camera: Nullable<Camera>;
  48293. /**
  48294. * The rendering group to draw the layer in.
  48295. */
  48296. renderingGroupId: number;
  48297. }
  48298. /**
  48299. * The effect layer Helps adding post process effect blended with the main pass.
  48300. *
  48301. * This can be for instance use to generate glow or higlight effects on the scene.
  48302. *
  48303. * The effect layer class can not be used directly and is intented to inherited from to be
  48304. * customized per effects.
  48305. */
  48306. export abstract class EffectLayer {
  48307. private _vertexBuffers;
  48308. private _indexBuffer;
  48309. private _cachedDefines;
  48310. private _effectLayerMapGenerationEffect;
  48311. private _effectLayerOptions;
  48312. private _mergeEffect;
  48313. protected _scene: Scene;
  48314. protected _engine: Engine;
  48315. protected _maxSize: number;
  48316. protected _mainTextureDesiredSize: ISize;
  48317. protected _mainTexture: RenderTargetTexture;
  48318. protected _shouldRender: boolean;
  48319. protected _postProcesses: PostProcess[];
  48320. protected _textures: BaseTexture[];
  48321. protected _emissiveTextureAndColor: {
  48322. texture: Nullable<BaseTexture>;
  48323. color: Color4;
  48324. };
  48325. /**
  48326. * The name of the layer
  48327. */
  48328. name: string;
  48329. /**
  48330. * The clear color of the texture used to generate the glow map.
  48331. */
  48332. neutralColor: Color4;
  48333. /**
  48334. * Specifies wether the highlight layer is enabled or not.
  48335. */
  48336. isEnabled: boolean;
  48337. /**
  48338. * Gets the camera attached to the layer.
  48339. */
  48340. readonly camera: Nullable<Camera>;
  48341. /**
  48342. * Gets the rendering group id the layer should render in.
  48343. */
  48344. readonly renderingGroupId: number;
  48345. /**
  48346. * An event triggered when the effect layer has been disposed.
  48347. */
  48348. onDisposeObservable: Observable<EffectLayer>;
  48349. /**
  48350. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  48351. */
  48352. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  48353. /**
  48354. * An event triggered when the generated texture is being merged in the scene.
  48355. */
  48356. onBeforeComposeObservable: Observable<EffectLayer>;
  48357. /**
  48358. * An event triggered when the generated texture has been merged in the scene.
  48359. */
  48360. onAfterComposeObservable: Observable<EffectLayer>;
  48361. /**
  48362. * An event triggered when the efffect layer changes its size.
  48363. */
  48364. onSizeChangedObservable: Observable<EffectLayer>;
  48365. /** @hidden */
  48366. static _SceneComponentInitialization: (scene: Scene) => void;
  48367. /**
  48368. * Instantiates a new effect Layer and references it in the scene.
  48369. * @param name The name of the layer
  48370. * @param scene The scene to use the layer in
  48371. */
  48372. constructor(
  48373. /** The Friendly of the effect in the scene */
  48374. name: string, scene: Scene);
  48375. /**
  48376. * Get the effect name of the layer.
  48377. * @return The effect name
  48378. */
  48379. abstract getEffectName(): string;
  48380. /**
  48381. * Checks for the readiness of the element composing the layer.
  48382. * @param subMesh the mesh to check for
  48383. * @param useInstances specify wether or not to use instances to render the mesh
  48384. * @return true if ready otherwise, false
  48385. */
  48386. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  48387. /**
  48388. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  48389. * @returns true if the effect requires stencil during the main canvas render pass.
  48390. */
  48391. abstract needStencil(): boolean;
  48392. /**
  48393. * Create the merge effect. This is the shader use to blit the information back
  48394. * to the main canvas at the end of the scene rendering.
  48395. * @returns The effect containing the shader used to merge the effect on the main canvas
  48396. */
  48397. protected abstract _createMergeEffect(): Effect;
  48398. /**
  48399. * Creates the render target textures and post processes used in the effect layer.
  48400. */
  48401. protected abstract _createTextureAndPostProcesses(): void;
  48402. /**
  48403. * Implementation specific of rendering the generating effect on the main canvas.
  48404. * @param effect The effect used to render through
  48405. */
  48406. protected abstract _internalRender(effect: Effect): void;
  48407. /**
  48408. * Sets the required values for both the emissive texture and and the main color.
  48409. */
  48410. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  48411. /**
  48412. * Free any resources and references associated to a mesh.
  48413. * Internal use
  48414. * @param mesh The mesh to free.
  48415. */
  48416. abstract _disposeMesh(mesh: Mesh): void;
  48417. /**
  48418. * Serializes this layer (Glow or Highlight for example)
  48419. * @returns a serialized layer object
  48420. */
  48421. abstract serialize?(): any;
  48422. /**
  48423. * Initializes the effect layer with the required options.
  48424. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  48425. */
  48426. protected _init(options: Partial<IEffectLayerOptions>): void;
  48427. /**
  48428. * Generates the index buffer of the full screen quad blending to the main canvas.
  48429. */
  48430. private _generateIndexBuffer;
  48431. /**
  48432. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  48433. */
  48434. private _genrateVertexBuffer;
  48435. /**
  48436. * Sets the main texture desired size which is the closest power of two
  48437. * of the engine canvas size.
  48438. */
  48439. private _setMainTextureSize;
  48440. /**
  48441. * Creates the main texture for the effect layer.
  48442. */
  48443. protected _createMainTexture(): void;
  48444. /**
  48445. * Adds specific effects defines.
  48446. * @param defines The defines to add specifics to.
  48447. */
  48448. protected _addCustomEffectDefines(defines: string[]): void;
  48449. /**
  48450. * Checks for the readiness of the element composing the layer.
  48451. * @param subMesh the mesh to check for
  48452. * @param useInstances specify wether or not to use instances to render the mesh
  48453. * @param emissiveTexture the associated emissive texture used to generate the glow
  48454. * @return true if ready otherwise, false
  48455. */
  48456. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  48457. /**
  48458. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  48459. */
  48460. render(): void;
  48461. /**
  48462. * Determine if a given mesh will be used in the current effect.
  48463. * @param mesh mesh to test
  48464. * @returns true if the mesh will be used
  48465. */
  48466. hasMesh(mesh: AbstractMesh): boolean;
  48467. /**
  48468. * Returns true if the layer contains information to display, otherwise false.
  48469. * @returns true if the glow layer should be rendered
  48470. */
  48471. shouldRender(): boolean;
  48472. /**
  48473. * Returns true if the mesh should render, otherwise false.
  48474. * @param mesh The mesh to render
  48475. * @returns true if it should render otherwise false
  48476. */
  48477. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  48478. /**
  48479. * Returns true if the mesh can be rendered, otherwise false.
  48480. * @param mesh The mesh to render
  48481. * @param material The material used on the mesh
  48482. * @returns true if it can be rendered otherwise false
  48483. */
  48484. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  48485. /**
  48486. * Returns true if the mesh should render, otherwise false.
  48487. * @param mesh The mesh to render
  48488. * @returns true if it should render otherwise false
  48489. */
  48490. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  48491. /**
  48492. * Renders the submesh passed in parameter to the generation map.
  48493. */
  48494. protected _renderSubMesh(subMesh: SubMesh): void;
  48495. /**
  48496. * Rebuild the required buffers.
  48497. * @hidden Internal use only.
  48498. */
  48499. _rebuild(): void;
  48500. /**
  48501. * Dispose only the render target textures and post process.
  48502. */
  48503. private _disposeTextureAndPostProcesses;
  48504. /**
  48505. * Dispose the highlight layer and free resources.
  48506. */
  48507. dispose(): void;
  48508. /**
  48509. * Gets the class name of the effect layer
  48510. * @returns the string with the class name of the effect layer
  48511. */
  48512. getClassName(): string;
  48513. /**
  48514. * Creates an effect layer from parsed effect layer data
  48515. * @param parsedEffectLayer defines effect layer data
  48516. * @param scene defines the current scene
  48517. * @param rootUrl defines the root URL containing the effect layer information
  48518. * @returns a parsed effect Layer
  48519. */
  48520. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  48521. }
  48522. }
  48523. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  48524. import { Scene } from "babylonjs/scene";
  48525. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  48526. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  48527. import { AbstractScene } from "babylonjs/abstractScene";
  48528. module "babylonjs/abstractScene" {
  48529. interface AbstractScene {
  48530. /**
  48531. * The list of effect layers (highlights/glow) added to the scene
  48532. * @see http://doc.babylonjs.com/how_to/highlight_layer
  48533. * @see http://doc.babylonjs.com/how_to/glow_layer
  48534. */
  48535. effectLayers: Array<EffectLayer>;
  48536. /**
  48537. * Removes the given effect layer from this scene.
  48538. * @param toRemove defines the effect layer to remove
  48539. * @returns the index of the removed effect layer
  48540. */
  48541. removeEffectLayer(toRemove: EffectLayer): number;
  48542. /**
  48543. * Adds the given effect layer to this scene
  48544. * @param newEffectLayer defines the effect layer to add
  48545. */
  48546. addEffectLayer(newEffectLayer: EffectLayer): void;
  48547. }
  48548. }
  48549. /**
  48550. * Defines the layer scene component responsible to manage any effect layers
  48551. * in a given scene.
  48552. */
  48553. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  48554. /**
  48555. * The component name helpfull to identify the component in the list of scene components.
  48556. */
  48557. readonly name: string;
  48558. /**
  48559. * The scene the component belongs to.
  48560. */
  48561. scene: Scene;
  48562. private _engine;
  48563. private _renderEffects;
  48564. private _needStencil;
  48565. private _previousStencilState;
  48566. /**
  48567. * Creates a new instance of the component for the given scene
  48568. * @param scene Defines the scene to register the component in
  48569. */
  48570. constructor(scene: Scene);
  48571. /**
  48572. * Registers the component in a given scene
  48573. */
  48574. register(): void;
  48575. /**
  48576. * Rebuilds the elements related to this component in case of
  48577. * context lost for instance.
  48578. */
  48579. rebuild(): void;
  48580. /**
  48581. * Serializes the component data to the specified json object
  48582. * @param serializationObject The object to serialize to
  48583. */
  48584. serialize(serializationObject: any): void;
  48585. /**
  48586. * Adds all the element from the container to the scene
  48587. * @param container the container holding the elements
  48588. */
  48589. addFromContainer(container: AbstractScene): void;
  48590. /**
  48591. * Removes all the elements in the container from the scene
  48592. * @param container contains the elements to remove
  48593. * @param dispose if the removed element should be disposed (default: false)
  48594. */
  48595. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  48596. /**
  48597. * Disposes the component and the associated ressources.
  48598. */
  48599. dispose(): void;
  48600. private _isReadyForMesh;
  48601. private _renderMainTexture;
  48602. private _setStencil;
  48603. private _setStencilBack;
  48604. private _draw;
  48605. private _drawCamera;
  48606. private _drawRenderingGroup;
  48607. }
  48608. }
  48609. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  48610. /** @hidden */
  48611. export var glowMapMergePixelShader: {
  48612. name: string;
  48613. shader: string;
  48614. };
  48615. }
  48616. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  48617. /** @hidden */
  48618. export var glowMapMergeVertexShader: {
  48619. name: string;
  48620. shader: string;
  48621. };
  48622. }
  48623. declare module "babylonjs/Layers/glowLayer" {
  48624. import { Nullable } from "babylonjs/types";
  48625. import { Camera } from "babylonjs/Cameras/camera";
  48626. import { Scene } from "babylonjs/scene";
  48627. import { Color4 } from "babylonjs/Maths/math";
  48628. import { SubMesh } from "babylonjs/Meshes/subMesh";
  48629. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48630. import { Mesh } from "babylonjs/Meshes/mesh";
  48631. import { Texture } from "babylonjs/Materials/Textures/texture";
  48632. import { Effect } from "babylonjs/Materials/effect";
  48633. import { Material } from "babylonjs/Materials/material";
  48634. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  48635. import "babylonjs/Shaders/glowMapMerge.fragment";
  48636. import "babylonjs/Shaders/glowMapMerge.vertex";
  48637. import "babylonjs/Layers/effectLayerSceneComponent";
  48638. module "babylonjs/abstractScene" {
  48639. interface AbstractScene {
  48640. /**
  48641. * Return a the first highlight layer of the scene with a given name.
  48642. * @param name The name of the highlight layer to look for.
  48643. * @return The highlight layer if found otherwise null.
  48644. */
  48645. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  48646. }
  48647. }
  48648. /**
  48649. * Glow layer options. This helps customizing the behaviour
  48650. * of the glow layer.
  48651. */
  48652. export interface IGlowLayerOptions {
  48653. /**
  48654. * Multiplication factor apply to the canvas size to compute the render target size
  48655. * used to generated the glowing objects (the smaller the faster).
  48656. */
  48657. mainTextureRatio: number;
  48658. /**
  48659. * Enforces a fixed size texture to ensure resize independant blur.
  48660. */
  48661. mainTextureFixedSize?: number;
  48662. /**
  48663. * How big is the kernel of the blur texture.
  48664. */
  48665. blurKernelSize: number;
  48666. /**
  48667. * The camera attached to the layer.
  48668. */
  48669. camera: Nullable<Camera>;
  48670. /**
  48671. * Enable MSAA by chosing the number of samples.
  48672. */
  48673. mainTextureSamples?: number;
  48674. /**
  48675. * The rendering group to draw the layer in.
  48676. */
  48677. renderingGroupId: number;
  48678. }
  48679. /**
  48680. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  48681. *
  48682. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  48683. * glowy meshes to your scene.
  48684. *
  48685. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  48686. */
  48687. export class GlowLayer extends EffectLayer {
  48688. /**
  48689. * Effect Name of the layer.
  48690. */
  48691. static readonly EffectName: string;
  48692. /**
  48693. * The default blur kernel size used for the glow.
  48694. */
  48695. static DefaultBlurKernelSize: number;
  48696. /**
  48697. * The default texture size ratio used for the glow.
  48698. */
  48699. static DefaultTextureRatio: number;
  48700. /**
  48701. * Sets the kernel size of the blur.
  48702. */
  48703. /**
  48704. * Gets the kernel size of the blur.
  48705. */
  48706. blurKernelSize: number;
  48707. /**
  48708. * Sets the glow intensity.
  48709. */
  48710. /**
  48711. * Gets the glow intensity.
  48712. */
  48713. intensity: number;
  48714. private _options;
  48715. private _intensity;
  48716. private _horizontalBlurPostprocess1;
  48717. private _verticalBlurPostprocess1;
  48718. private _horizontalBlurPostprocess2;
  48719. private _verticalBlurPostprocess2;
  48720. private _blurTexture1;
  48721. private _blurTexture2;
  48722. private _postProcesses1;
  48723. private _postProcesses2;
  48724. private _includedOnlyMeshes;
  48725. private _excludedMeshes;
  48726. /**
  48727. * Callback used to let the user override the color selection on a per mesh basis
  48728. */
  48729. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  48730. /**
  48731. * Callback used to let the user override the texture selection on a per mesh basis
  48732. */
  48733. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  48734. /**
  48735. * Instantiates a new glow Layer and references it to the scene.
  48736. * @param name The name of the layer
  48737. * @param scene The scene to use the layer in
  48738. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  48739. */
  48740. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  48741. /**
  48742. * Get the effect name of the layer.
  48743. * @return The effect name
  48744. */
  48745. getEffectName(): string;
  48746. /**
  48747. * Create the merge effect. This is the shader use to blit the information back
  48748. * to the main canvas at the end of the scene rendering.
  48749. */
  48750. protected _createMergeEffect(): Effect;
  48751. /**
  48752. * Creates the render target textures and post processes used in the glow layer.
  48753. */
  48754. protected _createTextureAndPostProcesses(): void;
  48755. /**
  48756. * Checks for the readiness of the element composing the layer.
  48757. * @param subMesh the mesh to check for
  48758. * @param useInstances specify wether or not to use instances to render the mesh
  48759. * @param emissiveTexture the associated emissive texture used to generate the glow
  48760. * @return true if ready otherwise, false
  48761. */
  48762. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  48763. /**
  48764. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  48765. */
  48766. needStencil(): boolean;
  48767. /**
  48768. * Returns true if the mesh can be rendered, otherwise false.
  48769. * @param mesh The mesh to render
  48770. * @param material The material used on the mesh
  48771. * @returns true if it can be rendered otherwise false
  48772. */
  48773. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  48774. /**
  48775. * Implementation specific of rendering the generating effect on the main canvas.
  48776. * @param effect The effect used to render through
  48777. */
  48778. protected _internalRender(effect: Effect): void;
  48779. /**
  48780. * Sets the required values for both the emissive texture and and the main color.
  48781. */
  48782. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  48783. /**
  48784. * Returns true if the mesh should render, otherwise false.
  48785. * @param mesh The mesh to render
  48786. * @returns true if it should render otherwise false
  48787. */
  48788. protected _shouldRenderMesh(mesh: Mesh): boolean;
  48789. /**
  48790. * Adds specific effects defines.
  48791. * @param defines The defines to add specifics to.
  48792. */
  48793. protected _addCustomEffectDefines(defines: string[]): void;
  48794. /**
  48795. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  48796. * @param mesh The mesh to exclude from the glow layer
  48797. */
  48798. addExcludedMesh(mesh: Mesh): void;
  48799. /**
  48800. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  48801. * @param mesh The mesh to remove
  48802. */
  48803. removeExcludedMesh(mesh: Mesh): void;
  48804. /**
  48805. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  48806. * @param mesh The mesh to include in the glow layer
  48807. */
  48808. addIncludedOnlyMesh(mesh: Mesh): void;
  48809. /**
  48810. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  48811. * @param mesh The mesh to remove
  48812. */
  48813. removeIncludedOnlyMesh(mesh: Mesh): void;
  48814. /**
  48815. * Determine if a given mesh will be used in the glow layer
  48816. * @param mesh The mesh to test
  48817. * @returns true if the mesh will be highlighted by the current glow layer
  48818. */
  48819. hasMesh(mesh: AbstractMesh): boolean;
  48820. /**
  48821. * Free any resources and references associated to a mesh.
  48822. * Internal use
  48823. * @param mesh The mesh to free.
  48824. * @hidden
  48825. */
  48826. _disposeMesh(mesh: Mesh): void;
  48827. /**
  48828. * Gets the class name of the effect layer
  48829. * @returns the string with the class name of the effect layer
  48830. */
  48831. getClassName(): string;
  48832. /**
  48833. * Serializes this glow layer
  48834. * @returns a serialized glow layer object
  48835. */
  48836. serialize(): any;
  48837. /**
  48838. * Creates a Glow Layer from parsed glow layer data
  48839. * @param parsedGlowLayer defines glow layer data
  48840. * @param scene defines the current scene
  48841. * @param rootUrl defines the root URL containing the glow layer information
  48842. * @returns a parsed Glow Layer
  48843. */
  48844. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  48845. }
  48846. }
  48847. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  48848. /** @hidden */
  48849. export var glowBlurPostProcessPixelShader: {
  48850. name: string;
  48851. shader: string;
  48852. };
  48853. }
  48854. declare module "babylonjs/Layers/highlightLayer" {
  48855. import { Observable } from "babylonjs/Misc/observable";
  48856. import { Nullable } from "babylonjs/types";
  48857. import { Camera } from "babylonjs/Cameras/camera";
  48858. import { Scene } from "babylonjs/scene";
  48859. import { Color3, Color4 } from "babylonjs/Maths/math";
  48860. import { SubMesh } from "babylonjs/Meshes/subMesh";
  48861. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48862. import { Mesh } from "babylonjs/Meshes/mesh";
  48863. import { Effect } from "babylonjs/Materials/effect";
  48864. import { Material } from "babylonjs/Materials/material";
  48865. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  48866. import "babylonjs/Shaders/glowMapMerge.fragment";
  48867. import "babylonjs/Shaders/glowMapMerge.vertex";
  48868. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  48869. module "babylonjs/abstractScene" {
  48870. interface AbstractScene {
  48871. /**
  48872. * Return a the first highlight layer of the scene with a given name.
  48873. * @param name The name of the highlight layer to look for.
  48874. * @return The highlight layer if found otherwise null.
  48875. */
  48876. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  48877. }
  48878. }
  48879. /**
  48880. * Highlight layer options. This helps customizing the behaviour
  48881. * of the highlight layer.
  48882. */
  48883. export interface IHighlightLayerOptions {
  48884. /**
  48885. * Multiplication factor apply to the canvas size to compute the render target size
  48886. * used to generated the glowing objects (the smaller the faster).
  48887. */
  48888. mainTextureRatio: number;
  48889. /**
  48890. * Enforces a fixed size texture to ensure resize independant blur.
  48891. */
  48892. mainTextureFixedSize?: number;
  48893. /**
  48894. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  48895. * of the picture to blur (the smaller the faster).
  48896. */
  48897. blurTextureSizeRatio: number;
  48898. /**
  48899. * How big in texel of the blur texture is the vertical blur.
  48900. */
  48901. blurVerticalSize: number;
  48902. /**
  48903. * How big in texel of the blur texture is the horizontal blur.
  48904. */
  48905. blurHorizontalSize: number;
  48906. /**
  48907. * Alpha blending mode used to apply the blur. Default is combine.
  48908. */
  48909. alphaBlendingMode: number;
  48910. /**
  48911. * The camera attached to the layer.
  48912. */
  48913. camera: Nullable<Camera>;
  48914. /**
  48915. * Should we display highlight as a solid stroke?
  48916. */
  48917. isStroke?: boolean;
  48918. /**
  48919. * The rendering group to draw the layer in.
  48920. */
  48921. renderingGroupId: number;
  48922. }
  48923. /**
  48924. * The highlight layer Helps adding a glow effect around a mesh.
  48925. *
  48926. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  48927. * glowy meshes to your scene.
  48928. *
  48929. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  48930. */
  48931. export class HighlightLayer extends EffectLayer {
  48932. name: string;
  48933. /**
  48934. * Effect Name of the highlight layer.
  48935. */
  48936. static readonly EffectName: string;
  48937. /**
  48938. * The neutral color used during the preparation of the glow effect.
  48939. * This is black by default as the blend operation is a blend operation.
  48940. */
  48941. static NeutralColor: Color4;
  48942. /**
  48943. * Stencil value used for glowing meshes.
  48944. */
  48945. static GlowingMeshStencilReference: number;
  48946. /**
  48947. * Stencil value used for the other meshes in the scene.
  48948. */
  48949. static NormalMeshStencilReference: number;
  48950. /**
  48951. * Specifies whether or not the inner glow is ACTIVE in the layer.
  48952. */
  48953. innerGlow: boolean;
  48954. /**
  48955. * Specifies whether or not the outer glow is ACTIVE in the layer.
  48956. */
  48957. outerGlow: boolean;
  48958. /**
  48959. * Specifies the horizontal size of the blur.
  48960. */
  48961. /**
  48962. * Gets the horizontal size of the blur.
  48963. */
  48964. blurHorizontalSize: number;
  48965. /**
  48966. * Specifies the vertical size of the blur.
  48967. */
  48968. /**
  48969. * Gets the vertical size of the blur.
  48970. */
  48971. blurVerticalSize: number;
  48972. /**
  48973. * An event triggered when the highlight layer is being blurred.
  48974. */
  48975. onBeforeBlurObservable: Observable<HighlightLayer>;
  48976. /**
  48977. * An event triggered when the highlight layer has been blurred.
  48978. */
  48979. onAfterBlurObservable: Observable<HighlightLayer>;
  48980. private _instanceGlowingMeshStencilReference;
  48981. private _options;
  48982. private _downSamplePostprocess;
  48983. private _horizontalBlurPostprocess;
  48984. private _verticalBlurPostprocess;
  48985. private _blurTexture;
  48986. private _meshes;
  48987. private _excludedMeshes;
  48988. /**
  48989. * Instantiates a new highlight Layer and references it to the scene..
  48990. * @param name The name of the layer
  48991. * @param scene The scene to use the layer in
  48992. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  48993. */
  48994. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  48995. /**
  48996. * Get the effect name of the layer.
  48997. * @return The effect name
  48998. */
  48999. getEffectName(): string;
  49000. /**
  49001. * Create the merge effect. This is the shader use to blit the information back
  49002. * to the main canvas at the end of the scene rendering.
  49003. */
  49004. protected _createMergeEffect(): Effect;
  49005. /**
  49006. * Creates the render target textures and post processes used in the highlight layer.
  49007. */
  49008. protected _createTextureAndPostProcesses(): void;
  49009. /**
  49010. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  49011. */
  49012. needStencil(): boolean;
  49013. /**
  49014. * Checks for the readiness of the element composing the layer.
  49015. * @param subMesh the mesh to check for
  49016. * @param useInstances specify wether or not to use instances to render the mesh
  49017. * @param emissiveTexture the associated emissive texture used to generate the glow
  49018. * @return true if ready otherwise, false
  49019. */
  49020. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  49021. /**
  49022. * Implementation specific of rendering the generating effect on the main canvas.
  49023. * @param effect The effect used to render through
  49024. */
  49025. protected _internalRender(effect: Effect): void;
  49026. /**
  49027. * Returns true if the layer contains information to display, otherwise false.
  49028. */
  49029. shouldRender(): boolean;
  49030. /**
  49031. * Returns true if the mesh should render, otherwise false.
  49032. * @param mesh The mesh to render
  49033. * @returns true if it should render otherwise false
  49034. */
  49035. protected _shouldRenderMesh(mesh: Mesh): boolean;
  49036. /**
  49037. * Sets the required values for both the emissive texture and and the main color.
  49038. */
  49039. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  49040. /**
  49041. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  49042. * @param mesh The mesh to exclude from the highlight layer
  49043. */
  49044. addExcludedMesh(mesh: Mesh): void;
  49045. /**
  49046. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  49047. * @param mesh The mesh to highlight
  49048. */
  49049. removeExcludedMesh(mesh: Mesh): void;
  49050. /**
  49051. * Determine if a given mesh will be highlighted by the current HighlightLayer
  49052. * @param mesh mesh to test
  49053. * @returns true if the mesh will be highlighted by the current HighlightLayer
  49054. */
  49055. hasMesh(mesh: AbstractMesh): boolean;
  49056. /**
  49057. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  49058. * @param mesh The mesh to highlight
  49059. * @param color The color of the highlight
  49060. * @param glowEmissiveOnly Extract the glow from the emissive texture
  49061. */
  49062. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  49063. /**
  49064. * Remove a mesh from the highlight layer in order to make it stop glowing.
  49065. * @param mesh The mesh to highlight
  49066. */
  49067. removeMesh(mesh: Mesh): void;
  49068. /**
  49069. * Force the stencil to the normal expected value for none glowing parts
  49070. */
  49071. private _defaultStencilReference;
  49072. /**
  49073. * Free any resources and references associated to a mesh.
  49074. * Internal use
  49075. * @param mesh The mesh to free.
  49076. * @hidden
  49077. */
  49078. _disposeMesh(mesh: Mesh): void;
  49079. /**
  49080. * Dispose the highlight layer and free resources.
  49081. */
  49082. dispose(): void;
  49083. /**
  49084. * Gets the class name of the effect layer
  49085. * @returns the string with the class name of the effect layer
  49086. */
  49087. getClassName(): string;
  49088. /**
  49089. * Serializes this Highlight layer
  49090. * @returns a serialized Highlight layer object
  49091. */
  49092. serialize(): any;
  49093. /**
  49094. * Creates a Highlight layer from parsed Highlight layer data
  49095. * @param parsedHightlightLayer defines the Highlight layer data
  49096. * @param scene defines the current scene
  49097. * @param rootUrl defines the root URL containing the Highlight layer information
  49098. * @returns a parsed Highlight layer
  49099. */
  49100. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  49101. }
  49102. }
  49103. declare module "babylonjs/Layers/index" {
  49104. export * from "babylonjs/Layers/effectLayer";
  49105. export * from "babylonjs/Layers/effectLayerSceneComponent";
  49106. export * from "babylonjs/Layers/glowLayer";
  49107. export * from "babylonjs/Layers/highlightLayer";
  49108. export * from "babylonjs/Layers/layer";
  49109. export * from "babylonjs/Layers/layerSceneComponent";
  49110. }
  49111. declare module "babylonjs/Shaders/lensFlare.fragment" {
  49112. /** @hidden */
  49113. export var lensFlarePixelShader: {
  49114. name: string;
  49115. shader: string;
  49116. };
  49117. }
  49118. declare module "babylonjs/Shaders/lensFlare.vertex" {
  49119. /** @hidden */
  49120. export var lensFlareVertexShader: {
  49121. name: string;
  49122. shader: string;
  49123. };
  49124. }
  49125. declare module "babylonjs/LensFlares/lensFlareSystem" {
  49126. import { Scene } from "babylonjs/scene";
  49127. import { Vector3, Viewport } from "babylonjs/Maths/math";
  49128. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49129. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  49130. import "babylonjs/Shaders/lensFlare.fragment";
  49131. import "babylonjs/Shaders/lensFlare.vertex";
  49132. /**
  49133. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  49134. * It is usually composed of several `lensFlare`.
  49135. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49136. */
  49137. export class LensFlareSystem {
  49138. /**
  49139. * Define the name of the lens flare system
  49140. */
  49141. name: string;
  49142. /**
  49143. * List of lens flares used in this system.
  49144. */
  49145. lensFlares: LensFlare[];
  49146. /**
  49147. * Define a limit from the border the lens flare can be visible.
  49148. */
  49149. borderLimit: number;
  49150. /**
  49151. * Define a viewport border we do not want to see the lens flare in.
  49152. */
  49153. viewportBorder: number;
  49154. /**
  49155. * Define a predicate which could limit the list of meshes able to occlude the effect.
  49156. */
  49157. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  49158. /**
  49159. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  49160. */
  49161. layerMask: number;
  49162. /**
  49163. * Define the id of the lens flare system in the scene.
  49164. * (equal to name by default)
  49165. */
  49166. id: string;
  49167. private _scene;
  49168. private _emitter;
  49169. private _vertexBuffers;
  49170. private _indexBuffer;
  49171. private _effect;
  49172. private _positionX;
  49173. private _positionY;
  49174. private _isEnabled;
  49175. /** @hidden */
  49176. static _SceneComponentInitialization: (scene: Scene) => void;
  49177. /**
  49178. * Instantiates a lens flare system.
  49179. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  49180. * It is usually composed of several `lensFlare`.
  49181. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49182. * @param name Define the name of the lens flare system in the scene
  49183. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  49184. * @param scene Define the scene the lens flare system belongs to
  49185. */
  49186. constructor(
  49187. /**
  49188. * Define the name of the lens flare system
  49189. */
  49190. name: string, emitter: any, scene: Scene);
  49191. /**
  49192. * Define if the lens flare system is enabled.
  49193. */
  49194. isEnabled: boolean;
  49195. /**
  49196. * Get the scene the effects belongs to.
  49197. * @returns the scene holding the lens flare system
  49198. */
  49199. getScene(): Scene;
  49200. /**
  49201. * Get the emitter of the lens flare system.
  49202. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  49203. * @returns the emitter of the lens flare system
  49204. */
  49205. getEmitter(): any;
  49206. /**
  49207. * Set the emitter of the lens flare system.
  49208. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  49209. * @param newEmitter Define the new emitter of the system
  49210. */
  49211. setEmitter(newEmitter: any): void;
  49212. /**
  49213. * Get the lens flare system emitter position.
  49214. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  49215. * @returns the position
  49216. */
  49217. getEmitterPosition(): Vector3;
  49218. /**
  49219. * @hidden
  49220. */
  49221. computeEffectivePosition(globalViewport: Viewport): boolean;
  49222. /** @hidden */
  49223. _isVisible(): boolean;
  49224. /**
  49225. * @hidden
  49226. */
  49227. render(): boolean;
  49228. /**
  49229. * Dispose and release the lens flare with its associated resources.
  49230. */
  49231. dispose(): void;
  49232. /**
  49233. * Parse a lens flare system from a JSON repressentation
  49234. * @param parsedLensFlareSystem Define the JSON to parse
  49235. * @param scene Define the scene the parsed system should be instantiated in
  49236. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  49237. * @returns the parsed system
  49238. */
  49239. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  49240. /**
  49241. * Serialize the current Lens Flare System into a JSON representation.
  49242. * @returns the serialized JSON
  49243. */
  49244. serialize(): any;
  49245. }
  49246. }
  49247. declare module "babylonjs/LensFlares/lensFlare" {
  49248. import { Nullable } from "babylonjs/types";
  49249. import { Color3 } from "babylonjs/Maths/math";
  49250. import { Texture } from "babylonjs/Materials/Textures/texture";
  49251. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  49252. /**
  49253. * This represents one of the lens effect in a `lensFlareSystem`.
  49254. * It controls one of the indiviual texture used in the effect.
  49255. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49256. */
  49257. export class LensFlare {
  49258. /**
  49259. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  49260. */
  49261. size: number;
  49262. /**
  49263. * 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.
  49264. */
  49265. position: number;
  49266. /**
  49267. * Define the lens color.
  49268. */
  49269. color: Color3;
  49270. /**
  49271. * Define the lens texture.
  49272. */
  49273. texture: Nullable<Texture>;
  49274. /**
  49275. * Define the alpha mode to render this particular lens.
  49276. */
  49277. alphaMode: number;
  49278. private _system;
  49279. /**
  49280. * Creates a new Lens Flare.
  49281. * This represents one of the lens effect in a `lensFlareSystem`.
  49282. * It controls one of the indiviual texture used in the effect.
  49283. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49284. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  49285. * @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.
  49286. * @param color Define the lens color
  49287. * @param imgUrl Define the lens texture url
  49288. * @param system Define the `lensFlareSystem` this flare is part of
  49289. * @returns The newly created Lens Flare
  49290. */
  49291. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  49292. /**
  49293. * Instantiates a new Lens Flare.
  49294. * This represents one of the lens effect in a `lensFlareSystem`.
  49295. * It controls one of the indiviual texture used in the effect.
  49296. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49297. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  49298. * @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.
  49299. * @param color Define the lens color
  49300. * @param imgUrl Define the lens texture url
  49301. * @param system Define the `lensFlareSystem` this flare is part of
  49302. */
  49303. constructor(
  49304. /**
  49305. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  49306. */
  49307. size: number,
  49308. /**
  49309. * 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.
  49310. */
  49311. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  49312. /**
  49313. * Dispose and release the lens flare with its associated resources.
  49314. */
  49315. dispose(): void;
  49316. }
  49317. }
  49318. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  49319. import { Nullable } from "babylonjs/types";
  49320. import { Scene } from "babylonjs/scene";
  49321. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  49322. import { AbstractScene } from "babylonjs/abstractScene";
  49323. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  49324. module "babylonjs/abstractScene" {
  49325. interface AbstractScene {
  49326. /**
  49327. * The list of lens flare system added to the scene
  49328. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49329. */
  49330. lensFlareSystems: Array<LensFlareSystem>;
  49331. /**
  49332. * Removes the given lens flare system from this scene.
  49333. * @param toRemove The lens flare system to remove
  49334. * @returns The index of the removed lens flare system
  49335. */
  49336. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  49337. /**
  49338. * Adds the given lens flare system to this scene
  49339. * @param newLensFlareSystem The lens flare system to add
  49340. */
  49341. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  49342. /**
  49343. * Gets a lens flare system using its name
  49344. * @param name defines the name to look for
  49345. * @returns the lens flare system or null if not found
  49346. */
  49347. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  49348. /**
  49349. * Gets a lens flare system using its id
  49350. * @param id defines the id to look for
  49351. * @returns the lens flare system or null if not found
  49352. */
  49353. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  49354. }
  49355. }
  49356. /**
  49357. * Defines the lens flare scene component responsible to manage any lens flares
  49358. * in a given scene.
  49359. */
  49360. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  49361. /**
  49362. * The component name helpfull to identify the component in the list of scene components.
  49363. */
  49364. readonly name: string;
  49365. /**
  49366. * The scene the component belongs to.
  49367. */
  49368. scene: Scene;
  49369. /**
  49370. * Creates a new instance of the component for the given scene
  49371. * @param scene Defines the scene to register the component in
  49372. */
  49373. constructor(scene: Scene);
  49374. /**
  49375. * Registers the component in a given scene
  49376. */
  49377. register(): void;
  49378. /**
  49379. * Rebuilds the elements related to this component in case of
  49380. * context lost for instance.
  49381. */
  49382. rebuild(): void;
  49383. /**
  49384. * Adds all the element from the container to the scene
  49385. * @param container the container holding the elements
  49386. */
  49387. addFromContainer(container: AbstractScene): void;
  49388. /**
  49389. * Removes all the elements in the container from the scene
  49390. * @param container contains the elements to remove
  49391. * @param dispose if the removed element should be disposed (default: false)
  49392. */
  49393. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  49394. /**
  49395. * Serializes the component data to the specified json object
  49396. * @param serializationObject The object to serialize to
  49397. */
  49398. serialize(serializationObject: any): void;
  49399. /**
  49400. * Disposes the component and the associated ressources.
  49401. */
  49402. dispose(): void;
  49403. private _draw;
  49404. }
  49405. }
  49406. declare module "babylonjs/LensFlares/index" {
  49407. export * from "babylonjs/LensFlares/lensFlare";
  49408. export * from "babylonjs/LensFlares/lensFlareSystem";
  49409. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  49410. }
  49411. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  49412. import { Scene } from "babylonjs/scene";
  49413. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  49414. import { AbstractScene } from "babylonjs/abstractScene";
  49415. /**
  49416. * Defines the shadow generator component responsible to manage any shadow generators
  49417. * in a given scene.
  49418. */
  49419. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  49420. /**
  49421. * The component name helpfull to identify the component in the list of scene components.
  49422. */
  49423. readonly name: string;
  49424. /**
  49425. * The scene the component belongs to.
  49426. */
  49427. scene: Scene;
  49428. /**
  49429. * Creates a new instance of the component for the given scene
  49430. * @param scene Defines the scene to register the component in
  49431. */
  49432. constructor(scene: Scene);
  49433. /**
  49434. * Registers the component in a given scene
  49435. */
  49436. register(): void;
  49437. /**
  49438. * Rebuilds the elements related to this component in case of
  49439. * context lost for instance.
  49440. */
  49441. rebuild(): void;
  49442. /**
  49443. * Serializes the component data to the specified json object
  49444. * @param serializationObject The object to serialize to
  49445. */
  49446. serialize(serializationObject: any): void;
  49447. /**
  49448. * Adds all the element from the container to the scene
  49449. * @param container the container holding the elements
  49450. */
  49451. addFromContainer(container: AbstractScene): void;
  49452. /**
  49453. * Removes all the elements in the container from the scene
  49454. * @param container contains the elements to remove
  49455. * @param dispose if the removed element should be disposed (default: false)
  49456. */
  49457. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  49458. /**
  49459. * Rebuilds the elements related to this component in case of
  49460. * context lost for instance.
  49461. */
  49462. dispose(): void;
  49463. private _gatherRenderTargets;
  49464. }
  49465. }
  49466. declare module "babylonjs/Lights/Shadows/index" {
  49467. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  49468. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  49469. }
  49470. declare module "babylonjs/Lights/pointLight" {
  49471. import { Scene } from "babylonjs/scene";
  49472. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  49473. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49474. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  49475. import { Effect } from "babylonjs/Materials/effect";
  49476. /**
  49477. * A point light is a light defined by an unique point in world space.
  49478. * The light is emitted in every direction from this point.
  49479. * A good example of a point light is a standard light bulb.
  49480. * Documentation: https://doc.babylonjs.com/babylon101/lights
  49481. */
  49482. export class PointLight extends ShadowLight {
  49483. private _shadowAngle;
  49484. /**
  49485. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  49486. * This specifies what angle the shadow will use to be created.
  49487. *
  49488. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  49489. */
  49490. /**
  49491. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  49492. * This specifies what angle the shadow will use to be created.
  49493. *
  49494. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  49495. */
  49496. shadowAngle: number;
  49497. /**
  49498. * Gets the direction if it has been set.
  49499. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  49500. */
  49501. /**
  49502. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  49503. */
  49504. direction: Vector3;
  49505. /**
  49506. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  49507. * A PointLight emits the light in every direction.
  49508. * It can cast shadows.
  49509. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  49510. * ```javascript
  49511. * var pointLight = new PointLight("pl", camera.position, scene);
  49512. * ```
  49513. * Documentation : https://doc.babylonjs.com/babylon101/lights
  49514. * @param name The light friendly name
  49515. * @param position The position of the point light in the scene
  49516. * @param scene The scene the lights belongs to
  49517. */
  49518. constructor(name: string, position: Vector3, scene: Scene);
  49519. /**
  49520. * Returns the string "PointLight"
  49521. * @returns the class name
  49522. */
  49523. getClassName(): string;
  49524. /**
  49525. * Returns the integer 0.
  49526. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  49527. */
  49528. getTypeID(): number;
  49529. /**
  49530. * Specifies wether or not the shadowmap should be a cube texture.
  49531. * @returns true if the shadowmap needs to be a cube texture.
  49532. */
  49533. needCube(): boolean;
  49534. /**
  49535. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  49536. * @param faceIndex The index of the face we are computed the direction to generate shadow
  49537. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  49538. */
  49539. getShadowDirection(faceIndex?: number): Vector3;
  49540. /**
  49541. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  49542. * - fov = PI / 2
  49543. * - aspect ratio : 1.0
  49544. * - z-near and far equal to the active camera minZ and maxZ.
  49545. * Returns the PointLight.
  49546. */
  49547. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  49548. protected _buildUniformLayout(): void;
  49549. /**
  49550. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  49551. * @param effect The effect to update
  49552. * @param lightIndex The index of the light in the effect to update
  49553. * @returns The point light
  49554. */
  49555. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  49556. /**
  49557. * Prepares the list of defines specific to the light type.
  49558. * @param defines the list of defines
  49559. * @param lightIndex defines the index of the light for the effect
  49560. */
  49561. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  49562. }
  49563. }
  49564. declare module "babylonjs/Lights/index" {
  49565. export * from "babylonjs/Lights/light";
  49566. export * from "babylonjs/Lights/shadowLight";
  49567. export * from "babylonjs/Lights/Shadows/index";
  49568. export * from "babylonjs/Lights/directionalLight";
  49569. export * from "babylonjs/Lights/hemisphericLight";
  49570. export * from "babylonjs/Lights/pointLight";
  49571. export * from "babylonjs/Lights/spotLight";
  49572. }
  49573. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  49574. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  49575. /**
  49576. * Header information of HDR texture files.
  49577. */
  49578. export interface HDRInfo {
  49579. /**
  49580. * The height of the texture in pixels.
  49581. */
  49582. height: number;
  49583. /**
  49584. * The width of the texture in pixels.
  49585. */
  49586. width: number;
  49587. /**
  49588. * The index of the beginning of the data in the binary file.
  49589. */
  49590. dataPosition: number;
  49591. }
  49592. /**
  49593. * This groups tools to convert HDR texture to native colors array.
  49594. */
  49595. export class HDRTools {
  49596. private static Ldexp;
  49597. private static Rgbe2float;
  49598. private static readStringLine;
  49599. /**
  49600. * Reads header information from an RGBE texture stored in a native array.
  49601. * More information on this format are available here:
  49602. * https://en.wikipedia.org/wiki/RGBE_image_format
  49603. *
  49604. * @param uint8array The binary file stored in native array.
  49605. * @return The header information.
  49606. */
  49607. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  49608. /**
  49609. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  49610. * This RGBE texture needs to store the information as a panorama.
  49611. *
  49612. * More information on this format are available here:
  49613. * https://en.wikipedia.org/wiki/RGBE_image_format
  49614. *
  49615. * @param buffer The binary file stored in an array buffer.
  49616. * @param size The expected size of the extracted cubemap.
  49617. * @return The Cube Map information.
  49618. */
  49619. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  49620. /**
  49621. * Returns the pixels data extracted from an RGBE texture.
  49622. * This pixels will be stored left to right up to down in the R G B order in one array.
  49623. *
  49624. * More information on this format are available here:
  49625. * https://en.wikipedia.org/wiki/RGBE_image_format
  49626. *
  49627. * @param uint8array The binary file stored in an array buffer.
  49628. * @param hdrInfo The header information of the file.
  49629. * @return The pixels data in RGB right to left up to down order.
  49630. */
  49631. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  49632. private static RGBE_ReadPixels_RLE;
  49633. }
  49634. }
  49635. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  49636. import { Nullable } from "babylonjs/types";
  49637. import { Scene } from "babylonjs/scene";
  49638. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  49639. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49640. /**
  49641. * This represents a texture coming from an HDR input.
  49642. *
  49643. * The only supported format is currently panorama picture stored in RGBE format.
  49644. * Example of such files can be found on HDRLib: http://hdrlib.com/
  49645. */
  49646. export class HDRCubeTexture extends BaseTexture {
  49647. private static _facesMapping;
  49648. private _generateHarmonics;
  49649. private _noMipmap;
  49650. private _textureMatrix;
  49651. private _size;
  49652. private _onLoad;
  49653. private _onError;
  49654. /**
  49655. * The texture URL.
  49656. */
  49657. url: string;
  49658. /**
  49659. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  49660. */
  49661. coordinatesMode: number;
  49662. protected _isBlocking: boolean;
  49663. /**
  49664. * Sets wether or not the texture is blocking during loading.
  49665. */
  49666. /**
  49667. * Gets wether or not the texture is blocking during loading.
  49668. */
  49669. isBlocking: boolean;
  49670. protected _rotationY: number;
  49671. /**
  49672. * Sets texture matrix rotation angle around Y axis in radians.
  49673. */
  49674. /**
  49675. * Gets texture matrix rotation angle around Y axis radians.
  49676. */
  49677. rotationY: number;
  49678. /**
  49679. * Gets or sets the center of the bounding box associated with the cube texture
  49680. * It must define where the camera used to render the texture was set
  49681. */
  49682. boundingBoxPosition: Vector3;
  49683. private _boundingBoxSize;
  49684. /**
  49685. * Gets or sets the size of the bounding box associated with the cube texture
  49686. * When defined, the cubemap will switch to local mode
  49687. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  49688. * @example https://www.babylonjs-playground.com/#RNASML
  49689. */
  49690. boundingBoxSize: Vector3;
  49691. /**
  49692. * Instantiates an HDRTexture from the following parameters.
  49693. *
  49694. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  49695. * @param scene The scene the texture will be used in
  49696. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  49697. * @param noMipmap Forces to not generate the mipmap if true
  49698. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  49699. * @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)
  49700. * @param reserved Reserved flag for internal use.
  49701. */
  49702. 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>);
  49703. /**
  49704. * Get the current class name of the texture useful for serialization or dynamic coding.
  49705. * @returns "HDRCubeTexture"
  49706. */
  49707. getClassName(): string;
  49708. /**
  49709. * Occurs when the file is raw .hdr file.
  49710. */
  49711. private loadTexture;
  49712. clone(): HDRCubeTexture;
  49713. delayLoad(): void;
  49714. /**
  49715. * Get the texture reflection matrix used to rotate/transform the reflection.
  49716. * @returns the reflection matrix
  49717. */
  49718. getReflectionTextureMatrix(): Matrix;
  49719. /**
  49720. * Set the texture reflection matrix used to rotate/transform the reflection.
  49721. * @param value Define the reflection matrix to set
  49722. */
  49723. setReflectionTextureMatrix(value: Matrix): void;
  49724. /**
  49725. * Parses a JSON representation of an HDR Texture in order to create the texture
  49726. * @param parsedTexture Define the JSON representation
  49727. * @param scene Define the scene the texture should be created in
  49728. * @param rootUrl Define the root url in case we need to load relative dependencies
  49729. * @returns the newly created texture after parsing
  49730. */
  49731. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  49732. serialize(): any;
  49733. }
  49734. }
  49735. declare module "babylonjs/Physics/physicsEngine" {
  49736. import { Nullable } from "babylonjs/types";
  49737. import { Vector3 } from "babylonjs/Maths/math";
  49738. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  49739. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  49740. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  49741. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  49742. /**
  49743. * Class used to control physics engine
  49744. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  49745. */
  49746. export class PhysicsEngine implements IPhysicsEngine {
  49747. private _physicsPlugin;
  49748. /**
  49749. * Global value used to control the smallest number supported by the simulation
  49750. */
  49751. static Epsilon: number;
  49752. private _impostors;
  49753. private _joints;
  49754. /**
  49755. * Gets the gravity vector used by the simulation
  49756. */
  49757. gravity: Vector3;
  49758. /**
  49759. * Factory used to create the default physics plugin.
  49760. * @returns The default physics plugin
  49761. */
  49762. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  49763. /**
  49764. * Creates a new Physics Engine
  49765. * @param gravity defines the gravity vector used by the simulation
  49766. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  49767. */
  49768. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  49769. /**
  49770. * Sets the gravity vector used by the simulation
  49771. * @param gravity defines the gravity vector to use
  49772. */
  49773. setGravity(gravity: Vector3): void;
  49774. /**
  49775. * Set the time step of the physics engine.
  49776. * Default is 1/60.
  49777. * To slow it down, enter 1/600 for example.
  49778. * To speed it up, 1/30
  49779. * @param newTimeStep defines the new timestep to apply to this world.
  49780. */
  49781. setTimeStep(newTimeStep?: number): void;
  49782. /**
  49783. * Get the time step of the physics engine.
  49784. * @returns the current time step
  49785. */
  49786. getTimeStep(): number;
  49787. /**
  49788. * Release all resources
  49789. */
  49790. dispose(): void;
  49791. /**
  49792. * Gets the name of the current physics plugin
  49793. * @returns the name of the plugin
  49794. */
  49795. getPhysicsPluginName(): string;
  49796. /**
  49797. * Adding a new impostor for the impostor tracking.
  49798. * This will be done by the impostor itself.
  49799. * @param impostor the impostor to add
  49800. */
  49801. addImpostor(impostor: PhysicsImpostor): void;
  49802. /**
  49803. * Remove an impostor from the engine.
  49804. * This impostor and its mesh will not longer be updated by the physics engine.
  49805. * @param impostor the impostor to remove
  49806. */
  49807. removeImpostor(impostor: PhysicsImpostor): void;
  49808. /**
  49809. * Add a joint to the physics engine
  49810. * @param mainImpostor defines the main impostor to which the joint is added.
  49811. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  49812. * @param joint defines the joint that will connect both impostors.
  49813. */
  49814. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  49815. /**
  49816. * Removes a joint from the simulation
  49817. * @param mainImpostor defines the impostor used with the joint
  49818. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  49819. * @param joint defines the joint to remove
  49820. */
  49821. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  49822. /**
  49823. * Called by the scene. No need to call it.
  49824. * @param delta defines the timespam between frames
  49825. */
  49826. _step(delta: number): void;
  49827. /**
  49828. * Gets the current plugin used to run the simulation
  49829. * @returns current plugin
  49830. */
  49831. getPhysicsPlugin(): IPhysicsEnginePlugin;
  49832. /**
  49833. * Gets the list of physic impostors
  49834. * @returns an array of PhysicsImpostor
  49835. */
  49836. getImpostors(): Array<PhysicsImpostor>;
  49837. /**
  49838. * Gets the impostor for a physics enabled object
  49839. * @param object defines the object impersonated by the impostor
  49840. * @returns the PhysicsImpostor or null if not found
  49841. */
  49842. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  49843. /**
  49844. * Gets the impostor for a physics body object
  49845. * @param body defines physics body used by the impostor
  49846. * @returns the PhysicsImpostor or null if not found
  49847. */
  49848. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  49849. /**
  49850. * Does a raycast in the physics world
  49851. * @param from when should the ray start?
  49852. * @param to when should the ray end?
  49853. * @returns PhysicsRaycastResult
  49854. */
  49855. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  49856. }
  49857. }
  49858. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  49859. import { Nullable } from "babylonjs/types";
  49860. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  49861. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49862. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  49863. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  49864. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  49865. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  49866. /** @hidden */
  49867. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  49868. private _useDeltaForWorldStep;
  49869. world: any;
  49870. name: string;
  49871. private _physicsMaterials;
  49872. private _fixedTimeStep;
  49873. private _cannonRaycastResult;
  49874. private _raycastResult;
  49875. private _removeAfterStep;
  49876. BJSCANNON: any;
  49877. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  49878. setGravity(gravity: Vector3): void;
  49879. setTimeStep(timeStep: number): void;
  49880. getTimeStep(): number;
  49881. executeStep(delta: number): void;
  49882. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  49883. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  49884. generatePhysicsBody(impostor: PhysicsImpostor): void;
  49885. private _processChildMeshes;
  49886. removePhysicsBody(impostor: PhysicsImpostor): void;
  49887. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  49888. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  49889. private _addMaterial;
  49890. private _checkWithEpsilon;
  49891. private _createShape;
  49892. private _createHeightmap;
  49893. private _minus90X;
  49894. private _plus90X;
  49895. private _tmpPosition;
  49896. private _tmpDeltaPosition;
  49897. private _tmpUnityRotation;
  49898. private _updatePhysicsBodyTransformation;
  49899. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  49900. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  49901. isSupported(): boolean;
  49902. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  49903. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  49904. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  49905. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  49906. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  49907. getBodyMass(impostor: PhysicsImpostor): number;
  49908. getBodyFriction(impostor: PhysicsImpostor): number;
  49909. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  49910. getBodyRestitution(impostor: PhysicsImpostor): number;
  49911. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  49912. sleepBody(impostor: PhysicsImpostor): void;
  49913. wakeUpBody(impostor: PhysicsImpostor): void;
  49914. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  49915. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  49916. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  49917. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  49918. getRadius(impostor: PhysicsImpostor): number;
  49919. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  49920. dispose(): void;
  49921. private _extendNamespace;
  49922. /**
  49923. * Does a raycast in the physics world
  49924. * @param from when should the ray start?
  49925. * @param to when should the ray end?
  49926. * @returns PhysicsRaycastResult
  49927. */
  49928. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  49929. }
  49930. }
  49931. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  49932. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  49933. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  49934. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  49935. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49936. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  49937. import { Nullable } from "babylonjs/types";
  49938. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  49939. /** @hidden */
  49940. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  49941. world: any;
  49942. name: string;
  49943. BJSOIMO: any;
  49944. private _raycastResult;
  49945. constructor(iterations?: number, oimoInjection?: any);
  49946. setGravity(gravity: Vector3): void;
  49947. setTimeStep(timeStep: number): void;
  49948. getTimeStep(): number;
  49949. private _tmpImpostorsArray;
  49950. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  49951. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  49952. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  49953. generatePhysicsBody(impostor: PhysicsImpostor): void;
  49954. private _tmpPositionVector;
  49955. removePhysicsBody(impostor: PhysicsImpostor): void;
  49956. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  49957. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  49958. isSupported(): boolean;
  49959. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  49960. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  49961. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  49962. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  49963. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  49964. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  49965. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  49966. getBodyMass(impostor: PhysicsImpostor): number;
  49967. getBodyFriction(impostor: PhysicsImpostor): number;
  49968. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  49969. getBodyRestitution(impostor: PhysicsImpostor): number;
  49970. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  49971. sleepBody(impostor: PhysicsImpostor): void;
  49972. wakeUpBody(impostor: PhysicsImpostor): void;
  49973. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  49974. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  49975. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  49976. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  49977. getRadius(impostor: PhysicsImpostor): number;
  49978. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  49979. dispose(): void;
  49980. /**
  49981. * Does a raycast in the physics world
  49982. * @param from when should the ray start?
  49983. * @param to when should the ray end?
  49984. * @returns PhysicsRaycastResult
  49985. */
  49986. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  49987. }
  49988. }
  49989. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  49990. import { Nullable } from "babylonjs/types";
  49991. import { Scene } from "babylonjs/scene";
  49992. import { Vector3, Vector2, Color4, Vector4 } from "babylonjs/Maths/math";
  49993. import { Mesh } from "babylonjs/Meshes/mesh";
  49994. /**
  49995. * Class containing static functions to help procedurally build meshes
  49996. */
  49997. export class RibbonBuilder {
  49998. /**
  49999. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  50000. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  50001. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  50002. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  50003. * * 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
  50004. * * 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
  50005. * * 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
  50006. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50007. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50008. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50009. * * 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
  50010. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  50011. * * 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
  50012. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  50013. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50014. * @param name defines the name of the mesh
  50015. * @param options defines the options used to create the mesh
  50016. * @param scene defines the hosting scene
  50017. * @returns the ribbon mesh
  50018. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  50019. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50020. */
  50021. static CreateRibbon(name: string, options: {
  50022. pathArray: Vector3[][];
  50023. closeArray?: boolean;
  50024. closePath?: boolean;
  50025. offset?: number;
  50026. updatable?: boolean;
  50027. sideOrientation?: number;
  50028. frontUVs?: Vector4;
  50029. backUVs?: Vector4;
  50030. instance?: Mesh;
  50031. invertUV?: boolean;
  50032. uvs?: Vector2[];
  50033. colors?: Color4[];
  50034. }, scene?: Nullable<Scene>): Mesh;
  50035. }
  50036. }
  50037. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  50038. import { Nullable } from "babylonjs/types";
  50039. import { Scene } from "babylonjs/scene";
  50040. import { Vector3, Vector4 } from "babylonjs/Maths/math";
  50041. import { Mesh } from "babylonjs/Meshes/mesh";
  50042. /**
  50043. * Class containing static functions to help procedurally build meshes
  50044. */
  50045. export class ShapeBuilder {
  50046. /**
  50047. * 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.
  50048. * * 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.
  50049. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  50050. * * 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.
  50051. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  50052. * * 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
  50053. * * 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
  50054. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  50055. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50056. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50057. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  50058. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50059. * @param name defines the name of the mesh
  50060. * @param options defines the options used to create the mesh
  50061. * @param scene defines the hosting scene
  50062. * @returns the extruded shape mesh
  50063. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50064. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  50065. */
  50066. static ExtrudeShape(name: string, options: {
  50067. shape: Vector3[];
  50068. path: Vector3[];
  50069. scale?: number;
  50070. rotation?: number;
  50071. cap?: number;
  50072. updatable?: boolean;
  50073. sideOrientation?: number;
  50074. frontUVs?: Vector4;
  50075. backUVs?: Vector4;
  50076. instance?: Mesh;
  50077. invertUV?: boolean;
  50078. }, scene?: Nullable<Scene>): Mesh;
  50079. /**
  50080. * Creates an custom extruded shape mesh.
  50081. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  50082. * * 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.
  50083. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  50084. * * 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
  50085. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  50086. * * 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
  50087. * * It must returns a float value that will be the scale value applied to the shape on each path point
  50088. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  50089. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  50090. * * 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
  50091. * * 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
  50092. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  50093. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50094. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50095. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50096. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50097. * @param name defines the name of the mesh
  50098. * @param options defines the options used to create the mesh
  50099. * @param scene defines the hosting scene
  50100. * @returns the custom extruded shape mesh
  50101. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  50102. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50103. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  50104. */
  50105. static ExtrudeShapeCustom(name: string, options: {
  50106. shape: Vector3[];
  50107. path: Vector3[];
  50108. scaleFunction?: any;
  50109. rotationFunction?: any;
  50110. ribbonCloseArray?: boolean;
  50111. ribbonClosePath?: boolean;
  50112. cap?: number;
  50113. updatable?: boolean;
  50114. sideOrientation?: number;
  50115. frontUVs?: Vector4;
  50116. backUVs?: Vector4;
  50117. instance?: Mesh;
  50118. invertUV?: boolean;
  50119. }, scene?: Nullable<Scene>): Mesh;
  50120. private static _ExtrudeShapeGeneric;
  50121. }
  50122. }
  50123. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  50124. import { Quaternion, Vector3 } from "babylonjs/Maths/math";
  50125. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  50126. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  50127. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  50128. import { Nullable } from "babylonjs/types";
  50129. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50130. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  50131. /**
  50132. * AmmoJS Physics plugin
  50133. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  50134. * @see https://github.com/kripken/ammo.js/
  50135. */
  50136. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  50137. private _useDeltaForWorldStep;
  50138. /**
  50139. * Reference to the Ammo library
  50140. */
  50141. bjsAMMO: any;
  50142. /**
  50143. * Created ammoJS world which physics bodies are added to
  50144. */
  50145. world: any;
  50146. /**
  50147. * Name of the plugin
  50148. */
  50149. name: string;
  50150. private _timeStep;
  50151. private _fixedTimeStep;
  50152. private _maxSteps;
  50153. private _tmpQuaternion;
  50154. private _tmpAmmoTransform;
  50155. private _tmpAmmoQuaternion;
  50156. private _tmpAmmoConcreteContactResultCallback;
  50157. private _collisionConfiguration;
  50158. private _dispatcher;
  50159. private _overlappingPairCache;
  50160. private _solver;
  50161. private _softBodySolver;
  50162. private _tmpAmmoVectorA;
  50163. private _tmpAmmoVectorB;
  50164. private _tmpAmmoVectorC;
  50165. private _tmpAmmoVectorD;
  50166. private _tmpContactCallbackResult;
  50167. private _tmpAmmoVectorRCA;
  50168. private _tmpAmmoVectorRCB;
  50169. private _raycastResult;
  50170. private static readonly DISABLE_COLLISION_FLAG;
  50171. private static readonly KINEMATIC_FLAG;
  50172. private static readonly DISABLE_DEACTIVATION_FLAG;
  50173. /**
  50174. * Initializes the ammoJS plugin
  50175. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  50176. * @param ammoInjection can be used to inject your own ammo reference
  50177. */
  50178. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any);
  50179. /**
  50180. * Sets the gravity of the physics world (m/(s^2))
  50181. * @param gravity Gravity to set
  50182. */
  50183. setGravity(gravity: Vector3): void;
  50184. /**
  50185. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  50186. * @param timeStep timestep to use in seconds
  50187. */
  50188. setTimeStep(timeStep: number): void;
  50189. /**
  50190. * 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)
  50191. * @param fixedTimeStep fixedTimeStep to use in seconds
  50192. */
  50193. setFixedTimeStep(fixedTimeStep: number): void;
  50194. /**
  50195. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  50196. * @param maxSteps the maximum number of steps by the physics engine per frame
  50197. */
  50198. setMaxSteps(maxSteps: number): void;
  50199. /**
  50200. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  50201. * @returns the current timestep in seconds
  50202. */
  50203. getTimeStep(): number;
  50204. private _isImpostorInContact;
  50205. private _isImpostorPairInContact;
  50206. private _stepSimulation;
  50207. /**
  50208. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  50209. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  50210. * After the step the babylon meshes are set to the position of the physics imposters
  50211. * @param delta amount of time to step forward
  50212. * @param impostors array of imposters to update before/after the step
  50213. */
  50214. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  50215. /**
  50216. * Update babylon mesh to match physics world object
  50217. * @param impostor imposter to match
  50218. */
  50219. private _afterSoftStep;
  50220. /**
  50221. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  50222. * @param impostor imposter to match
  50223. */
  50224. private _ropeStep;
  50225. /**
  50226. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  50227. * @param impostor imposter to match
  50228. */
  50229. private _softbodyOrClothStep;
  50230. private _tmpVector;
  50231. private _tmpMatrix;
  50232. /**
  50233. * Applies an impulse on the imposter
  50234. * @param impostor imposter to apply impulse to
  50235. * @param force amount of force to be applied to the imposter
  50236. * @param contactPoint the location to apply the impulse on the imposter
  50237. */
  50238. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50239. /**
  50240. * Applies a force on the imposter
  50241. * @param impostor imposter to apply force
  50242. * @param force amount of force to be applied to the imposter
  50243. * @param contactPoint the location to apply the force on the imposter
  50244. */
  50245. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50246. /**
  50247. * Creates a physics body using the plugin
  50248. * @param impostor the imposter to create the physics body on
  50249. */
  50250. generatePhysicsBody(impostor: PhysicsImpostor): void;
  50251. /**
  50252. * Removes the physics body from the imposter and disposes of the body's memory
  50253. * @param impostor imposter to remove the physics body from
  50254. */
  50255. removePhysicsBody(impostor: PhysicsImpostor): void;
  50256. /**
  50257. * Generates a joint
  50258. * @param impostorJoint the imposter joint to create the joint with
  50259. */
  50260. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  50261. /**
  50262. * Removes a joint
  50263. * @param impostorJoint the imposter joint to remove the joint from
  50264. */
  50265. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  50266. private _addMeshVerts;
  50267. /**
  50268. * Initialise the soft body vertices to match its object's (mesh) vertices
  50269. * Softbody vertices (nodes) are in world space and to match this
  50270. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  50271. * @param impostor to create the softbody for
  50272. */
  50273. private _softVertexData;
  50274. /**
  50275. * Create an impostor's soft body
  50276. * @param impostor to create the softbody for
  50277. */
  50278. private _createSoftbody;
  50279. /**
  50280. * Create cloth for an impostor
  50281. * @param impostor to create the softbody for
  50282. */
  50283. private _createCloth;
  50284. /**
  50285. * Create rope for an impostor
  50286. * @param impostor to create the softbody for
  50287. */
  50288. private _createRope;
  50289. private _addHullVerts;
  50290. private _createShape;
  50291. /**
  50292. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  50293. * @param impostor imposter containing the physics body and babylon object
  50294. */
  50295. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  50296. /**
  50297. * Sets the babylon object's position/rotation from the physics body's position/rotation
  50298. * @param impostor imposter containing the physics body and babylon object
  50299. * @param newPosition new position
  50300. * @param newRotation new rotation
  50301. */
  50302. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  50303. /**
  50304. * If this plugin is supported
  50305. * @returns true if its supported
  50306. */
  50307. isSupported(): boolean;
  50308. /**
  50309. * Sets the linear velocity of the physics body
  50310. * @param impostor imposter to set the velocity on
  50311. * @param velocity velocity to set
  50312. */
  50313. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50314. /**
  50315. * Sets the angular velocity of the physics body
  50316. * @param impostor imposter to set the velocity on
  50317. * @param velocity velocity to set
  50318. */
  50319. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50320. /**
  50321. * gets the linear velocity
  50322. * @param impostor imposter to get linear velocity from
  50323. * @returns linear velocity
  50324. */
  50325. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50326. /**
  50327. * gets the angular velocity
  50328. * @param impostor imposter to get angular velocity from
  50329. * @returns angular velocity
  50330. */
  50331. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50332. /**
  50333. * Sets the mass of physics body
  50334. * @param impostor imposter to set the mass on
  50335. * @param mass mass to set
  50336. */
  50337. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  50338. /**
  50339. * Gets the mass of the physics body
  50340. * @param impostor imposter to get the mass from
  50341. * @returns mass
  50342. */
  50343. getBodyMass(impostor: PhysicsImpostor): number;
  50344. /**
  50345. * Gets friction of the impostor
  50346. * @param impostor impostor to get friction from
  50347. * @returns friction value
  50348. */
  50349. getBodyFriction(impostor: PhysicsImpostor): number;
  50350. /**
  50351. * Sets friction of the impostor
  50352. * @param impostor impostor to set friction on
  50353. * @param friction friction value
  50354. */
  50355. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  50356. /**
  50357. * Gets restitution of the impostor
  50358. * @param impostor impostor to get restitution from
  50359. * @returns restitution value
  50360. */
  50361. getBodyRestitution(impostor: PhysicsImpostor): number;
  50362. /**
  50363. * Sets resitution of the impostor
  50364. * @param impostor impostor to set resitution on
  50365. * @param restitution resitution value
  50366. */
  50367. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  50368. /**
  50369. * Gets pressure inside the impostor
  50370. * @param impostor impostor to get pressure from
  50371. * @returns pressure value
  50372. */
  50373. getBodyPressure(impostor: PhysicsImpostor): number;
  50374. /**
  50375. * Sets pressure inside a soft body impostor
  50376. * Cloth and rope must remain 0 pressure
  50377. * @param impostor impostor to set pressure on
  50378. * @param pressure pressure value
  50379. */
  50380. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  50381. /**
  50382. * Gets stiffness of the impostor
  50383. * @param impostor impostor to get stiffness from
  50384. * @returns pressure value
  50385. */
  50386. getBodyStiffness(impostor: PhysicsImpostor): number;
  50387. /**
  50388. * Sets stiffness of the impostor
  50389. * @param impostor impostor to set stiffness on
  50390. * @param stiffness stiffness value from 0 to 1
  50391. */
  50392. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  50393. /**
  50394. * Gets velocityIterations of the impostor
  50395. * @param impostor impostor to get velocity iterations from
  50396. * @returns velocityIterations value
  50397. */
  50398. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  50399. /**
  50400. * Sets velocityIterations of the impostor
  50401. * @param impostor impostor to set velocity iterations on
  50402. * @param velocityIterations velocityIterations value
  50403. */
  50404. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  50405. /**
  50406. * Gets positionIterations of the impostor
  50407. * @param impostor impostor to get position iterations from
  50408. * @returns positionIterations value
  50409. */
  50410. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  50411. /**
  50412. * Sets positionIterations of the impostor
  50413. * @param impostor impostor to set position on
  50414. * @param positionIterations positionIterations value
  50415. */
  50416. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  50417. /**
  50418. * Append an anchor to a cloth object
  50419. * @param impostor is the cloth impostor to add anchor to
  50420. * @param otherImpostor is the rigid impostor to anchor to
  50421. * @param width ratio across width from 0 to 1
  50422. * @param height ratio up height from 0 to 1
  50423. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  50424. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  50425. */
  50426. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  50427. /**
  50428. * Append an hook to a rope object
  50429. * @param impostor is the rope impostor to add hook to
  50430. * @param otherImpostor is the rigid impostor to hook to
  50431. * @param length ratio along the rope from 0 to 1
  50432. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  50433. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  50434. */
  50435. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  50436. /**
  50437. * Sleeps the physics body and stops it from being active
  50438. * @param impostor impostor to sleep
  50439. */
  50440. sleepBody(impostor: PhysicsImpostor): void;
  50441. /**
  50442. * Activates the physics body
  50443. * @param impostor impostor to activate
  50444. */
  50445. wakeUpBody(impostor: PhysicsImpostor): void;
  50446. /**
  50447. * Updates the distance parameters of the joint
  50448. * @param joint joint to update
  50449. * @param maxDistance maximum distance of the joint
  50450. * @param minDistance minimum distance of the joint
  50451. */
  50452. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  50453. /**
  50454. * Sets a motor on the joint
  50455. * @param joint joint to set motor on
  50456. * @param speed speed of the motor
  50457. * @param maxForce maximum force of the motor
  50458. * @param motorIndex index of the motor
  50459. */
  50460. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  50461. /**
  50462. * Sets the motors limit
  50463. * @param joint joint to set limit on
  50464. * @param upperLimit upper limit
  50465. * @param lowerLimit lower limit
  50466. */
  50467. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  50468. /**
  50469. * Syncs the position and rotation of a mesh with the impostor
  50470. * @param mesh mesh to sync
  50471. * @param impostor impostor to update the mesh with
  50472. */
  50473. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  50474. /**
  50475. * Gets the radius of the impostor
  50476. * @param impostor impostor to get radius from
  50477. * @returns the radius
  50478. */
  50479. getRadius(impostor: PhysicsImpostor): number;
  50480. /**
  50481. * Gets the box size of the impostor
  50482. * @param impostor impostor to get box size from
  50483. * @param result the resulting box size
  50484. */
  50485. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  50486. /**
  50487. * Disposes of the impostor
  50488. */
  50489. dispose(): void;
  50490. /**
  50491. * Does a raycast in the physics world
  50492. * @param from when should the ray start?
  50493. * @param to when should the ray end?
  50494. * @returns PhysicsRaycastResult
  50495. */
  50496. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  50497. }
  50498. }
  50499. declare module "babylonjs/Probes/reflectionProbe" {
  50500. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  50501. import { Vector3 } from "babylonjs/Maths/math";
  50502. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50503. import { Nullable } from "babylonjs/types";
  50504. import { Scene } from "babylonjs/scene";
  50505. module "babylonjs/abstractScene" {
  50506. interface AbstractScene {
  50507. /**
  50508. * The list of reflection probes added to the scene
  50509. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  50510. */
  50511. reflectionProbes: Array<ReflectionProbe>;
  50512. /**
  50513. * Removes the given reflection probe from this scene.
  50514. * @param toRemove The reflection probe to remove
  50515. * @returns The index of the removed reflection probe
  50516. */
  50517. removeReflectionProbe(toRemove: ReflectionProbe): number;
  50518. /**
  50519. * Adds the given reflection probe to this scene.
  50520. * @param newReflectionProbe The reflection probe to add
  50521. */
  50522. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  50523. }
  50524. }
  50525. /**
  50526. * Class used to generate realtime reflection / refraction cube textures
  50527. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  50528. */
  50529. export class ReflectionProbe {
  50530. /** defines the name of the probe */
  50531. name: string;
  50532. private _scene;
  50533. private _renderTargetTexture;
  50534. private _projectionMatrix;
  50535. private _viewMatrix;
  50536. private _target;
  50537. private _add;
  50538. private _attachedMesh;
  50539. private _invertYAxis;
  50540. /** Gets or sets probe position (center of the cube map) */
  50541. position: Vector3;
  50542. /**
  50543. * Creates a new reflection probe
  50544. * @param name defines the name of the probe
  50545. * @param size defines the texture resolution (for each face)
  50546. * @param scene defines the hosting scene
  50547. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  50548. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  50549. */
  50550. constructor(
  50551. /** defines the name of the probe */
  50552. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  50553. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  50554. samples: number;
  50555. /** Gets or sets the refresh rate to use (on every frame by default) */
  50556. refreshRate: number;
  50557. /**
  50558. * Gets the hosting scene
  50559. * @returns a Scene
  50560. */
  50561. getScene(): Scene;
  50562. /** Gets the internal CubeTexture used to render to */
  50563. readonly cubeTexture: RenderTargetTexture;
  50564. /** Gets the list of meshes to render */
  50565. readonly renderList: Nullable<AbstractMesh[]>;
  50566. /**
  50567. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  50568. * @param mesh defines the mesh to attach to
  50569. */
  50570. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  50571. /**
  50572. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  50573. * @param renderingGroupId The rendering group id corresponding to its index
  50574. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  50575. */
  50576. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  50577. /**
  50578. * Clean all associated resources
  50579. */
  50580. dispose(): void;
  50581. /**
  50582. * Converts the reflection probe information to a readable string for debug purpose.
  50583. * @param fullDetails Supports for multiple levels of logging within scene loading
  50584. * @returns the human readable reflection probe info
  50585. */
  50586. toString(fullDetails?: boolean): string;
  50587. /**
  50588. * Get the class name of the relfection probe.
  50589. * @returns "ReflectionProbe"
  50590. */
  50591. getClassName(): string;
  50592. /**
  50593. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  50594. * @returns The JSON representation of the texture
  50595. */
  50596. serialize(): any;
  50597. /**
  50598. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  50599. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  50600. * @param scene Define the scene the parsed reflection probe should be instantiated in
  50601. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  50602. * @returns The parsed reflection probe if successful
  50603. */
  50604. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  50605. }
  50606. }
  50607. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  50608. /** @hidden */
  50609. export var _BabylonLoaderRegistered: boolean;
  50610. }
  50611. declare module "babylonjs/Loading/Plugins/index" {
  50612. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  50613. }
  50614. declare module "babylonjs/Loading/index" {
  50615. export * from "babylonjs/Loading/loadingScreen";
  50616. export * from "babylonjs/Loading/Plugins/index";
  50617. export * from "babylonjs/Loading/sceneLoader";
  50618. export * from "babylonjs/Loading/sceneLoaderFlags";
  50619. }
  50620. declare module "babylonjs/Materials/Background/index" {
  50621. export * from "babylonjs/Materials/Background/backgroundMaterial";
  50622. }
  50623. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  50624. import { Scene } from "babylonjs/scene";
  50625. import { Color3 } from "babylonjs/Maths/math";
  50626. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  50627. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50628. /**
  50629. * The Physically based simple base material of BJS.
  50630. *
  50631. * This enables better naming and convention enforcements on top of the pbrMaterial.
  50632. * It is used as the base class for both the specGloss and metalRough conventions.
  50633. */
  50634. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  50635. /**
  50636. * Number of Simultaneous lights allowed on the material.
  50637. */
  50638. maxSimultaneousLights: number;
  50639. /**
  50640. * If sets to true, disables all the lights affecting the material.
  50641. */
  50642. disableLighting: boolean;
  50643. /**
  50644. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  50645. */
  50646. environmentTexture: BaseTexture;
  50647. /**
  50648. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  50649. */
  50650. invertNormalMapX: boolean;
  50651. /**
  50652. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  50653. */
  50654. invertNormalMapY: boolean;
  50655. /**
  50656. * Normal map used in the model.
  50657. */
  50658. normalTexture: BaseTexture;
  50659. /**
  50660. * Emissivie color used to self-illuminate the model.
  50661. */
  50662. emissiveColor: Color3;
  50663. /**
  50664. * Emissivie texture used to self-illuminate the model.
  50665. */
  50666. emissiveTexture: BaseTexture;
  50667. /**
  50668. * Occlusion Channel Strenght.
  50669. */
  50670. occlusionStrength: number;
  50671. /**
  50672. * Occlusion Texture of the material (adding extra occlusion effects).
  50673. */
  50674. occlusionTexture: BaseTexture;
  50675. /**
  50676. * Defines the alpha limits in alpha test mode.
  50677. */
  50678. alphaCutOff: number;
  50679. /**
  50680. * Gets the current double sided mode.
  50681. */
  50682. /**
  50683. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  50684. */
  50685. doubleSided: boolean;
  50686. /**
  50687. * Stores the pre-calculated light information of a mesh in a texture.
  50688. */
  50689. lightmapTexture: BaseTexture;
  50690. /**
  50691. * If true, the light map contains occlusion information instead of lighting info.
  50692. */
  50693. useLightmapAsShadowmap: boolean;
  50694. /**
  50695. * Instantiates a new PBRMaterial instance.
  50696. *
  50697. * @param name The material name
  50698. * @param scene The scene the material will be use in.
  50699. */
  50700. constructor(name: string, scene: Scene);
  50701. getClassName(): string;
  50702. }
  50703. }
  50704. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  50705. import { Scene } from "babylonjs/scene";
  50706. import { Color3 } from "babylonjs/Maths/math";
  50707. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50708. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  50709. /**
  50710. * The PBR material of BJS following the metal roughness convention.
  50711. *
  50712. * This fits to the PBR convention in the GLTF definition:
  50713. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  50714. */
  50715. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  50716. /**
  50717. * The base color has two different interpretations depending on the value of metalness.
  50718. * When the material is a metal, the base color is the specific measured reflectance value
  50719. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  50720. * of the material.
  50721. */
  50722. baseColor: Color3;
  50723. /**
  50724. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  50725. * well as opacity information in the alpha channel.
  50726. */
  50727. baseTexture: BaseTexture;
  50728. /**
  50729. * Specifies the metallic scalar value of the material.
  50730. * Can also be used to scale the metalness values of the metallic texture.
  50731. */
  50732. metallic: number;
  50733. /**
  50734. * Specifies the roughness scalar value of the material.
  50735. * Can also be used to scale the roughness values of the metallic texture.
  50736. */
  50737. roughness: number;
  50738. /**
  50739. * Texture containing both the metallic value in the B channel and the
  50740. * roughness value in the G channel to keep better precision.
  50741. */
  50742. metallicRoughnessTexture: BaseTexture;
  50743. /**
  50744. * Instantiates a new PBRMetalRoughnessMaterial instance.
  50745. *
  50746. * @param name The material name
  50747. * @param scene The scene the material will be use in.
  50748. */
  50749. constructor(name: string, scene: Scene);
  50750. /**
  50751. * Return the currrent class name of the material.
  50752. */
  50753. getClassName(): string;
  50754. /**
  50755. * Makes a duplicate of the current material.
  50756. * @param name - name to use for the new material.
  50757. */
  50758. clone(name: string): PBRMetallicRoughnessMaterial;
  50759. /**
  50760. * Serialize the material to a parsable JSON object.
  50761. */
  50762. serialize(): any;
  50763. /**
  50764. * Parses a JSON object correponding to the serialize function.
  50765. */
  50766. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  50767. }
  50768. }
  50769. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  50770. import { Scene } from "babylonjs/scene";
  50771. import { Color3 } from "babylonjs/Maths/math";
  50772. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50773. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  50774. /**
  50775. * The PBR material of BJS following the specular glossiness convention.
  50776. *
  50777. * This fits to the PBR convention in the GLTF definition:
  50778. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  50779. */
  50780. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  50781. /**
  50782. * Specifies the diffuse color of the material.
  50783. */
  50784. diffuseColor: Color3;
  50785. /**
  50786. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  50787. * channel.
  50788. */
  50789. diffuseTexture: BaseTexture;
  50790. /**
  50791. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  50792. */
  50793. specularColor: Color3;
  50794. /**
  50795. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  50796. */
  50797. glossiness: number;
  50798. /**
  50799. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  50800. */
  50801. specularGlossinessTexture: BaseTexture;
  50802. /**
  50803. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  50804. *
  50805. * @param name The material name
  50806. * @param scene The scene the material will be use in.
  50807. */
  50808. constructor(name: string, scene: Scene);
  50809. /**
  50810. * Return the currrent class name of the material.
  50811. */
  50812. getClassName(): string;
  50813. /**
  50814. * Makes a duplicate of the current material.
  50815. * @param name - name to use for the new material.
  50816. */
  50817. clone(name: string): PBRSpecularGlossinessMaterial;
  50818. /**
  50819. * Serialize the material to a parsable JSON object.
  50820. */
  50821. serialize(): any;
  50822. /**
  50823. * Parses a JSON object correponding to the serialize function.
  50824. */
  50825. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  50826. }
  50827. }
  50828. declare module "babylonjs/Materials/PBR/index" {
  50829. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  50830. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  50831. export * from "babylonjs/Materials/PBR/pbrMaterial";
  50832. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  50833. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  50834. }
  50835. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  50836. import { Nullable } from "babylonjs/types";
  50837. import { Scene } from "babylonjs/scene";
  50838. import { Matrix } from "babylonjs/Maths/math";
  50839. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50840. /**
  50841. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  50842. * It can help converting any input color in a desired output one. This can then be used to create effects
  50843. * from sepia, black and white to sixties or futuristic rendering...
  50844. *
  50845. * The only supported format is currently 3dl.
  50846. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  50847. */
  50848. export class ColorGradingTexture extends BaseTexture {
  50849. /**
  50850. * The current texture matrix. (will always be identity in color grading texture)
  50851. */
  50852. private _textureMatrix;
  50853. /**
  50854. * The texture URL.
  50855. */
  50856. url: string;
  50857. /**
  50858. * Empty line regex stored for GC.
  50859. */
  50860. private static _noneEmptyLineRegex;
  50861. private _engine;
  50862. /**
  50863. * Instantiates a ColorGradingTexture from the following parameters.
  50864. *
  50865. * @param url The location of the color gradind data (currently only supporting 3dl)
  50866. * @param scene The scene the texture will be used in
  50867. */
  50868. constructor(url: string, scene: Scene);
  50869. /**
  50870. * Returns the texture matrix used in most of the material.
  50871. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  50872. */
  50873. getTextureMatrix(): Matrix;
  50874. /**
  50875. * Occurs when the file being loaded is a .3dl LUT file.
  50876. */
  50877. private load3dlTexture;
  50878. /**
  50879. * Starts the loading process of the texture.
  50880. */
  50881. private loadTexture;
  50882. /**
  50883. * Clones the color gradind texture.
  50884. */
  50885. clone(): ColorGradingTexture;
  50886. /**
  50887. * Called during delayed load for textures.
  50888. */
  50889. delayLoad(): void;
  50890. /**
  50891. * Parses a color grading texture serialized by Babylon.
  50892. * @param parsedTexture The texture information being parsedTexture
  50893. * @param scene The scene to load the texture in
  50894. * @param rootUrl The root url of the data assets to load
  50895. * @return A color gradind texture
  50896. */
  50897. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  50898. /**
  50899. * Serializes the LUT texture to json format.
  50900. */
  50901. serialize(): any;
  50902. }
  50903. }
  50904. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  50905. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50906. import { Scene } from "babylonjs/scene";
  50907. import { Nullable } from "babylonjs/types";
  50908. /**
  50909. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  50910. */
  50911. export class EquiRectangularCubeTexture extends BaseTexture {
  50912. /** The six faces of the cube. */
  50913. private static _FacesMapping;
  50914. private _noMipmap;
  50915. private _onLoad;
  50916. private _onError;
  50917. /** The size of the cubemap. */
  50918. private _size;
  50919. /** The buffer of the image. */
  50920. private _buffer;
  50921. /** The width of the input image. */
  50922. private _width;
  50923. /** The height of the input image. */
  50924. private _height;
  50925. /** The URL to the image. */
  50926. url: string;
  50927. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  50928. coordinatesMode: number;
  50929. /**
  50930. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  50931. * @param url The location of the image
  50932. * @param scene The scene the texture will be used in
  50933. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  50934. * @param noMipmap Forces to not generate the mipmap if true
  50935. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  50936. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  50937. * @param onLoad — defines a callback called when texture is loaded
  50938. * @param onError — defines a callback called if there is an error
  50939. */
  50940. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  50941. /**
  50942. * Load the image data, by putting the image on a canvas and extracting its buffer.
  50943. */
  50944. private loadImage;
  50945. /**
  50946. * Convert the image buffer into a cubemap and create a CubeTexture.
  50947. */
  50948. private loadTexture;
  50949. /**
  50950. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  50951. * @param buffer The ArrayBuffer that should be converted.
  50952. * @returns The buffer as Float32Array.
  50953. */
  50954. private getFloat32ArrayFromArrayBuffer;
  50955. /**
  50956. * Get the current class name of the texture useful for serialization or dynamic coding.
  50957. * @returns "EquiRectangularCubeTexture"
  50958. */
  50959. getClassName(): string;
  50960. /**
  50961. * Create a clone of the current EquiRectangularCubeTexture and return it.
  50962. * @returns A clone of the current EquiRectangularCubeTexture.
  50963. */
  50964. clone(): EquiRectangularCubeTexture;
  50965. }
  50966. }
  50967. declare module "babylonjs/Misc/tga" {
  50968. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  50969. /**
  50970. * Based on jsTGALoader - Javascript loader for TGA file
  50971. * By Vincent Thibault
  50972. * @see http://blog.robrowser.com/javascript-tga-loader.html
  50973. */
  50974. export class TGATools {
  50975. private static _TYPE_INDEXED;
  50976. private static _TYPE_RGB;
  50977. private static _TYPE_GREY;
  50978. private static _TYPE_RLE_INDEXED;
  50979. private static _TYPE_RLE_RGB;
  50980. private static _TYPE_RLE_GREY;
  50981. private static _ORIGIN_MASK;
  50982. private static _ORIGIN_SHIFT;
  50983. private static _ORIGIN_BL;
  50984. private static _ORIGIN_BR;
  50985. private static _ORIGIN_UL;
  50986. private static _ORIGIN_UR;
  50987. /**
  50988. * Gets the header of a TGA file
  50989. * @param data defines the TGA data
  50990. * @returns the header
  50991. */
  50992. static GetTGAHeader(data: Uint8Array): any;
  50993. /**
  50994. * Uploads TGA content to a Babylon Texture
  50995. * @hidden
  50996. */
  50997. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  50998. /** @hidden */
  50999. 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;
  51000. /** @hidden */
  51001. 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;
  51002. /** @hidden */
  51003. 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;
  51004. /** @hidden */
  51005. 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;
  51006. /** @hidden */
  51007. 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;
  51008. /** @hidden */
  51009. 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;
  51010. }
  51011. }
  51012. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  51013. import { Nullable } from "babylonjs/types";
  51014. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  51015. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  51016. /**
  51017. * Implementation of the TGA Texture Loader.
  51018. * @hidden
  51019. */
  51020. export class _TGATextureLoader implements IInternalTextureLoader {
  51021. /**
  51022. * Defines wether the loader supports cascade loading the different faces.
  51023. */
  51024. readonly supportCascades: boolean;
  51025. /**
  51026. * This returns if the loader support the current file information.
  51027. * @param extension defines the file extension of the file being loaded
  51028. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51029. * @param fallback defines the fallback internal texture if any
  51030. * @param isBase64 defines whether the texture is encoded as a base64
  51031. * @param isBuffer defines whether the texture data are stored as a buffer
  51032. * @returns true if the loader can load the specified file
  51033. */
  51034. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  51035. /**
  51036. * Transform the url before loading if required.
  51037. * @param rootUrl the url of the texture
  51038. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51039. * @returns the transformed texture
  51040. */
  51041. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  51042. /**
  51043. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  51044. * @param rootUrl the url of the texture
  51045. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51046. * @returns the fallback texture
  51047. */
  51048. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  51049. /**
  51050. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  51051. * @param data contains the texture data
  51052. * @param texture defines the BabylonJS internal texture
  51053. * @param createPolynomials will be true if polynomials have been requested
  51054. * @param onLoad defines the callback to trigger once the texture is ready
  51055. * @param onError defines the callback to trigger in case of error
  51056. */
  51057. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  51058. /**
  51059. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  51060. * @param data contains the texture data
  51061. * @param texture defines the BabylonJS internal texture
  51062. * @param callback defines the method to call once ready to upload
  51063. */
  51064. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  51065. }
  51066. }
  51067. declare module "babylonjs/Materials/Textures/Loaders/index" {
  51068. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  51069. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  51070. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  51071. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  51072. }
  51073. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  51074. import { Scene } from "babylonjs/scene";
  51075. import { Texture } from "babylonjs/Materials/Textures/texture";
  51076. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  51077. /**
  51078. * 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.
  51079. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  51080. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  51081. */
  51082. export class CustomProceduralTexture extends ProceduralTexture {
  51083. private _animate;
  51084. private _time;
  51085. private _config;
  51086. private _texturePath;
  51087. /**
  51088. * Instantiates a new Custom Procedural Texture.
  51089. * 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.
  51090. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  51091. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  51092. * @param name Define the name of the texture
  51093. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  51094. * @param size Define the size of the texture to create
  51095. * @param scene Define the scene the texture belongs to
  51096. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  51097. * @param generateMipMaps Define if the texture should creates mip maps or not
  51098. */
  51099. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  51100. private _loadJson;
  51101. /**
  51102. * Is the texture ready to be used ? (rendered at least once)
  51103. * @returns true if ready, otherwise, false.
  51104. */
  51105. isReady(): boolean;
  51106. /**
  51107. * Render the texture to its associated render target.
  51108. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  51109. */
  51110. render(useCameraPostProcess?: boolean): void;
  51111. /**
  51112. * Update the list of dependant textures samplers in the shader.
  51113. */
  51114. updateTextures(): void;
  51115. /**
  51116. * Update the uniform values of the procedural texture in the shader.
  51117. */
  51118. updateShaderUniforms(): void;
  51119. /**
  51120. * Define if the texture animates or not.
  51121. */
  51122. animate: boolean;
  51123. }
  51124. }
  51125. declare module "babylonjs/Shaders/noise.fragment" {
  51126. /** @hidden */
  51127. export var noisePixelShader: {
  51128. name: string;
  51129. shader: string;
  51130. };
  51131. }
  51132. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  51133. import { Nullable } from "babylonjs/types";
  51134. import { Scene } from "babylonjs/scene";
  51135. import { Texture } from "babylonjs/Materials/Textures/texture";
  51136. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  51137. import "babylonjs/Shaders/noise.fragment";
  51138. /**
  51139. * Class used to generate noise procedural textures
  51140. */
  51141. export class NoiseProceduralTexture extends ProceduralTexture {
  51142. private _time;
  51143. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  51144. brightness: number;
  51145. /** Defines the number of octaves to process */
  51146. octaves: number;
  51147. /** Defines the level of persistence (0.8 by default) */
  51148. persistence: number;
  51149. /** Gets or sets animation speed factor (default is 1) */
  51150. animationSpeedFactor: number;
  51151. /**
  51152. * Creates a new NoiseProceduralTexture
  51153. * @param name defines the name fo the texture
  51154. * @param size defines the size of the texture (default is 256)
  51155. * @param scene defines the hosting scene
  51156. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  51157. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  51158. */
  51159. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  51160. private _updateShaderUniforms;
  51161. protected _getDefines(): string;
  51162. /** Generate the current state of the procedural texture */
  51163. render(useCameraPostProcess?: boolean): void;
  51164. /**
  51165. * Serializes this noise procedural texture
  51166. * @returns a serialized noise procedural texture object
  51167. */
  51168. serialize(): any;
  51169. /**
  51170. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  51171. * @param parsedTexture defines parsed texture data
  51172. * @param scene defines the current scene
  51173. * @param rootUrl defines the root URL containing noise procedural texture information
  51174. * @returns a parsed NoiseProceduralTexture
  51175. */
  51176. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  51177. }
  51178. }
  51179. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  51180. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  51181. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  51182. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  51183. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  51184. }
  51185. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  51186. import { Nullable } from "babylonjs/types";
  51187. import { Scene } from "babylonjs/scene";
  51188. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  51189. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  51190. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  51191. /**
  51192. * Raw cube texture where the raw buffers are passed in
  51193. */
  51194. export class RawCubeTexture extends CubeTexture {
  51195. /**
  51196. * Creates a cube texture where the raw buffers are passed in.
  51197. * @param scene defines the scene the texture is attached to
  51198. * @param data defines the array of data to use to create each face
  51199. * @param size defines the size of the textures
  51200. * @param format defines the format of the data
  51201. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  51202. * @param generateMipMaps defines if the engine should generate the mip levels
  51203. * @param invertY defines if data must be stored with Y axis inverted
  51204. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  51205. * @param compression defines the compression used (null by default)
  51206. */
  51207. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  51208. /**
  51209. * Updates the raw cube texture.
  51210. * @param data defines the data to store
  51211. * @param format defines the data format
  51212. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  51213. * @param invertY defines if data must be stored with Y axis inverted
  51214. * @param compression defines the compression used (null by default)
  51215. * @param level defines which level of the texture to update
  51216. */
  51217. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  51218. /**
  51219. * Updates a raw cube texture with RGBD encoded data.
  51220. * @param data defines the array of data [mipmap][face] to use to create each face
  51221. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  51222. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  51223. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  51224. * @returns a promsie that resolves when the operation is complete
  51225. */
  51226. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  51227. /**
  51228. * Clones the raw cube texture.
  51229. * @return a new cube texture
  51230. */
  51231. clone(): CubeTexture;
  51232. /** @hidden */
  51233. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  51234. }
  51235. }
  51236. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  51237. import { Scene } from "babylonjs/scene";
  51238. import { Texture } from "babylonjs/Materials/Textures/texture";
  51239. /**
  51240. * Class used to store 3D textures containing user data
  51241. */
  51242. export class RawTexture3D extends Texture {
  51243. /** Gets or sets the texture format to use */
  51244. format: number;
  51245. private _engine;
  51246. /**
  51247. * Create a new RawTexture3D
  51248. * @param data defines the data of the texture
  51249. * @param width defines the width of the texture
  51250. * @param height defines the height of the texture
  51251. * @param depth defines the depth of the texture
  51252. * @param format defines the texture format to use
  51253. * @param scene defines the hosting scene
  51254. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  51255. * @param invertY defines if texture must be stored with Y axis inverted
  51256. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  51257. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  51258. */
  51259. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  51260. /** Gets or sets the texture format to use */
  51261. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  51262. /**
  51263. * Update the texture with new data
  51264. * @param data defines the data to store in the texture
  51265. */
  51266. update(data: ArrayBufferView): void;
  51267. }
  51268. }
  51269. declare module "babylonjs/Materials/Textures/refractionTexture" {
  51270. import { Scene } from "babylonjs/scene";
  51271. import { Plane } from "babylonjs/Maths/math";
  51272. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  51273. /**
  51274. * Creates a refraction texture used by refraction channel of the standard material.
  51275. * It is like a mirror but to see through a material.
  51276. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  51277. */
  51278. export class RefractionTexture extends RenderTargetTexture {
  51279. /**
  51280. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  51281. * 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.
  51282. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  51283. */
  51284. refractionPlane: Plane;
  51285. /**
  51286. * Define how deep under the surface we should see.
  51287. */
  51288. depth: number;
  51289. /**
  51290. * Creates a refraction texture used by refraction channel of the standard material.
  51291. * It is like a mirror but to see through a material.
  51292. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  51293. * @param name Define the texture name
  51294. * @param size Define the size of the underlying texture
  51295. * @param scene Define the scene the refraction belongs to
  51296. * @param generateMipMaps Define if we need to generate mips level for the refraction
  51297. */
  51298. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  51299. /**
  51300. * Clone the refraction texture.
  51301. * @returns the cloned texture
  51302. */
  51303. clone(): RefractionTexture;
  51304. /**
  51305. * Serialize the texture to a JSON representation you could use in Parse later on
  51306. * @returns the serialized JSON representation
  51307. */
  51308. serialize(): any;
  51309. }
  51310. }
  51311. declare module "babylonjs/Materials/Textures/index" {
  51312. export * from "babylonjs/Materials/Textures/baseTexture";
  51313. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  51314. export * from "babylonjs/Materials/Textures/cubeTexture";
  51315. export * from "babylonjs/Materials/Textures/dynamicTexture";
  51316. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  51317. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  51318. export * from "babylonjs/Materials/Textures/internalTexture";
  51319. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  51320. export * from "babylonjs/Materials/Textures/Loaders/index";
  51321. export * from "babylonjs/Materials/Textures/mirrorTexture";
  51322. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  51323. export * from "babylonjs/Materials/Textures/Procedurals/index";
  51324. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  51325. export * from "babylonjs/Materials/Textures/rawTexture";
  51326. export * from "babylonjs/Materials/Textures/rawTexture3D";
  51327. export * from "babylonjs/Materials/Textures/refractionTexture";
  51328. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  51329. export * from "babylonjs/Materials/Textures/texture";
  51330. export * from "babylonjs/Materials/Textures/videoTexture";
  51331. }
  51332. declare module "babylonjs/Materials/index" {
  51333. export * from "babylonjs/Materials/Background/index";
  51334. export * from "babylonjs/Materials/colorCurves";
  51335. export * from "babylonjs/Materials/effect";
  51336. export * from "babylonjs/Materials/fresnelParameters";
  51337. export * from "babylonjs/Materials/imageProcessingConfiguration";
  51338. export * from "babylonjs/Materials/material";
  51339. export * from "babylonjs/Materials/materialDefines";
  51340. export * from "babylonjs/Materials/materialHelper";
  51341. export * from "babylonjs/Materials/multiMaterial";
  51342. export * from "babylonjs/Materials/PBR/index";
  51343. export * from "babylonjs/Materials/pushMaterial";
  51344. export * from "babylonjs/Materials/shaderMaterial";
  51345. export * from "babylonjs/Materials/standardMaterial";
  51346. export * from "babylonjs/Materials/Textures/index";
  51347. export * from "babylonjs/Materials/uniformBuffer";
  51348. export * from "babylonjs/Materials/materialFlags";
  51349. }
  51350. declare module "babylonjs/Maths/index" {
  51351. export * from "babylonjs/Maths/math.scalar";
  51352. export * from "babylonjs/Maths/math";
  51353. export * from "babylonjs/Maths/sphericalPolynomial";
  51354. }
  51355. declare module "babylonjs/Misc/workerPool" {
  51356. import { IDisposable } from "babylonjs/scene";
  51357. /**
  51358. * Helper class to push actions to a pool of workers.
  51359. */
  51360. export class WorkerPool implements IDisposable {
  51361. private _workerInfos;
  51362. private _pendingActions;
  51363. /**
  51364. * Constructor
  51365. * @param workers Array of workers to use for actions
  51366. */
  51367. constructor(workers: Array<Worker>);
  51368. /**
  51369. * Terminates all workers and clears any pending actions.
  51370. */
  51371. dispose(): void;
  51372. /**
  51373. * Pushes an action to the worker pool. If all the workers are active, the action will be
  51374. * pended until a worker has completed its action.
  51375. * @param action The action to perform. Call onComplete when the action is complete.
  51376. */
  51377. push(action: (worker: Worker, onComplete: () => void) => void): void;
  51378. private _execute;
  51379. }
  51380. }
  51381. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  51382. import { IDisposable } from "babylonjs/scene";
  51383. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  51384. /**
  51385. * Configuration for Draco compression
  51386. */
  51387. export interface IDracoCompressionConfiguration {
  51388. /**
  51389. * Configuration for the decoder.
  51390. */
  51391. decoder?: {
  51392. /**
  51393. * The url to the WebAssembly module.
  51394. */
  51395. wasmUrl?: string;
  51396. /**
  51397. * The url to the WebAssembly binary.
  51398. */
  51399. wasmBinaryUrl?: string;
  51400. /**
  51401. * The url to the fallback JavaScript module.
  51402. */
  51403. fallbackUrl?: string;
  51404. };
  51405. }
  51406. /**
  51407. * Draco compression (https://google.github.io/draco/)
  51408. *
  51409. * This class wraps the Draco module.
  51410. *
  51411. * **Encoder**
  51412. *
  51413. * The encoder is not currently implemented.
  51414. *
  51415. * **Decoder**
  51416. *
  51417. * 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.
  51418. *
  51419. * To update the configuration, use the following code:
  51420. * ```javascript
  51421. * DracoCompression.Configuration = {
  51422. * decoder: {
  51423. * wasmUrl: "<url to the WebAssembly library>",
  51424. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  51425. * fallbackUrl: "<url to the fallback JavaScript library>",
  51426. * }
  51427. * };
  51428. * ```
  51429. *
  51430. * 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.
  51431. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  51432. * Use `DracoCompression.DecoderAvailable` to determine if the decoder is available for the current session.
  51433. *
  51434. * To decode Draco compressed data, create a DracoCompression object and call decodeMeshAsync:
  51435. * ```javascript
  51436. * var dracoCompression = new DracoCompression();
  51437. * var vertexData = await dracoCompression.decodeMeshAsync(data, {
  51438. * [VertexBuffer.PositionKind]: 0
  51439. * });
  51440. * ```
  51441. *
  51442. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  51443. */
  51444. export class DracoCompression implements IDisposable {
  51445. private _workerPoolPromise;
  51446. /**
  51447. * The configuration. Defaults to the following urls:
  51448. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  51449. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  51450. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  51451. */
  51452. static Configuration: IDracoCompressionConfiguration;
  51453. /**
  51454. * Returns true if the decoder is available.
  51455. */
  51456. static readonly DecoderAvailable: boolean;
  51457. /**
  51458. * Default number of workers to create when creating the draco compression object.
  51459. */
  51460. static DefaultNumWorkers: number;
  51461. private static GetDefaultNumWorkers;
  51462. /**
  51463. * Constructor
  51464. * @param numWorkers The number of workers for async operations
  51465. */
  51466. constructor(numWorkers?: number);
  51467. /**
  51468. * Stop all async operations and release resources.
  51469. */
  51470. dispose(): void;
  51471. /**
  51472. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  51473. * @returns a promise that resolves when ready
  51474. */
  51475. whenReadyAsync(): Promise<void>;
  51476. /**
  51477. * Decode Draco compressed mesh data to vertex data.
  51478. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  51479. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  51480. * @returns A promise that resolves with the decoded vertex data
  51481. */
  51482. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes: {
  51483. [kind: string]: number;
  51484. }): Promise<VertexData>;
  51485. /**
  51486. * The worker function that gets converted to a blob url to pass into a worker.
  51487. */
  51488. private static _Worker;
  51489. private _loadDecoderWasmBinaryAsync;
  51490. }
  51491. }
  51492. declare module "babylonjs/Meshes/Compression/index" {
  51493. export * from "babylonjs/Meshes/Compression/dracoCompression";
  51494. }
  51495. declare module "babylonjs/Meshes/csg" {
  51496. import { Nullable } from "babylonjs/types";
  51497. import { Scene } from "babylonjs/scene";
  51498. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math";
  51499. import { Mesh } from "babylonjs/Meshes/mesh";
  51500. import { Material } from "babylonjs/Materials/material";
  51501. /**
  51502. * Class for building Constructive Solid Geometry
  51503. */
  51504. export class CSG {
  51505. private polygons;
  51506. /**
  51507. * The world matrix
  51508. */
  51509. matrix: Matrix;
  51510. /**
  51511. * Stores the position
  51512. */
  51513. position: Vector3;
  51514. /**
  51515. * Stores the rotation
  51516. */
  51517. rotation: Vector3;
  51518. /**
  51519. * Stores the rotation quaternion
  51520. */
  51521. rotationQuaternion: Nullable<Quaternion>;
  51522. /**
  51523. * Stores the scaling vector
  51524. */
  51525. scaling: Vector3;
  51526. /**
  51527. * Convert the Mesh to CSG
  51528. * @param mesh The Mesh to convert to CSG
  51529. * @returns A new CSG from the Mesh
  51530. */
  51531. static FromMesh(mesh: Mesh): CSG;
  51532. /**
  51533. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  51534. * @param polygons Polygons used to construct a CSG solid
  51535. */
  51536. private static FromPolygons;
  51537. /**
  51538. * Clones, or makes a deep copy, of the CSG
  51539. * @returns A new CSG
  51540. */
  51541. clone(): CSG;
  51542. /**
  51543. * Unions this CSG with another CSG
  51544. * @param csg The CSG to union against this CSG
  51545. * @returns The unioned CSG
  51546. */
  51547. union(csg: CSG): CSG;
  51548. /**
  51549. * Unions this CSG with another CSG in place
  51550. * @param csg The CSG to union against this CSG
  51551. */
  51552. unionInPlace(csg: CSG): void;
  51553. /**
  51554. * Subtracts this CSG with another CSG
  51555. * @param csg The CSG to subtract against this CSG
  51556. * @returns A new CSG
  51557. */
  51558. subtract(csg: CSG): CSG;
  51559. /**
  51560. * Subtracts this CSG with another CSG in place
  51561. * @param csg The CSG to subtact against this CSG
  51562. */
  51563. subtractInPlace(csg: CSG): void;
  51564. /**
  51565. * Intersect this CSG with another CSG
  51566. * @param csg The CSG to intersect against this CSG
  51567. * @returns A new CSG
  51568. */
  51569. intersect(csg: CSG): CSG;
  51570. /**
  51571. * Intersects this CSG with another CSG in place
  51572. * @param csg The CSG to intersect against this CSG
  51573. */
  51574. intersectInPlace(csg: CSG): void;
  51575. /**
  51576. * Return a new CSG solid with solid and empty space switched. This solid is
  51577. * not modified.
  51578. * @returns A new CSG solid with solid and empty space switched
  51579. */
  51580. inverse(): CSG;
  51581. /**
  51582. * Inverses the CSG in place
  51583. */
  51584. inverseInPlace(): void;
  51585. /**
  51586. * This is used to keep meshes transformations so they can be restored
  51587. * when we build back a Babylon Mesh
  51588. * NB : All CSG operations are performed in world coordinates
  51589. * @param csg The CSG to copy the transform attributes from
  51590. * @returns This CSG
  51591. */
  51592. copyTransformAttributes(csg: CSG): CSG;
  51593. /**
  51594. * Build Raw mesh from CSG
  51595. * Coordinates here are in world space
  51596. * @param name The name of the mesh geometry
  51597. * @param scene The Scene
  51598. * @param keepSubMeshes Specifies if the submeshes should be kept
  51599. * @returns A new Mesh
  51600. */
  51601. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  51602. /**
  51603. * Build Mesh from CSG taking material and transforms into account
  51604. * @param name The name of the Mesh
  51605. * @param material The material of the Mesh
  51606. * @param scene The Scene
  51607. * @param keepSubMeshes Specifies if submeshes should be kept
  51608. * @returns The new Mesh
  51609. */
  51610. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  51611. }
  51612. }
  51613. declare module "babylonjs/Meshes/trailMesh" {
  51614. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51615. import { Mesh } from "babylonjs/Meshes/mesh";
  51616. import { Scene } from "babylonjs/scene";
  51617. /**
  51618. * Class used to create a trail following a mesh
  51619. */
  51620. export class TrailMesh extends Mesh {
  51621. private _generator;
  51622. private _autoStart;
  51623. private _running;
  51624. private _diameter;
  51625. private _length;
  51626. private _sectionPolygonPointsCount;
  51627. private _sectionVectors;
  51628. private _sectionNormalVectors;
  51629. private _beforeRenderObserver;
  51630. /**
  51631. * @constructor
  51632. * @param name The value used by scene.getMeshByName() to do a lookup.
  51633. * @param generator The mesh to generate a trail.
  51634. * @param scene The scene to add this mesh to.
  51635. * @param diameter Diameter of trailing mesh. Default is 1.
  51636. * @param length Length of trailing mesh. Default is 60.
  51637. * @param autoStart Automatically start trailing mesh. Default true.
  51638. */
  51639. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  51640. /**
  51641. * "TrailMesh"
  51642. * @returns "TrailMesh"
  51643. */
  51644. getClassName(): string;
  51645. private _createMesh;
  51646. /**
  51647. * Start trailing mesh.
  51648. */
  51649. start(): void;
  51650. /**
  51651. * Stop trailing mesh.
  51652. */
  51653. stop(): void;
  51654. /**
  51655. * Update trailing mesh geometry.
  51656. */
  51657. update(): void;
  51658. /**
  51659. * Returns a new TrailMesh object.
  51660. * @param name is a string, the name given to the new mesh
  51661. * @param newGenerator use new generator object for cloned trail mesh
  51662. * @returns a new mesh
  51663. */
  51664. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  51665. /**
  51666. * Serializes this trail mesh
  51667. * @param serializationObject object to write serialization to
  51668. */
  51669. serialize(serializationObject: any): void;
  51670. /**
  51671. * Parses a serialized trail mesh
  51672. * @param parsedMesh the serialized mesh
  51673. * @param scene the scene to create the trail mesh in
  51674. * @returns the created trail mesh
  51675. */
  51676. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  51677. }
  51678. }
  51679. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  51680. import { Vector4 } from "babylonjs/Maths/math";
  51681. import { Mesh } from "babylonjs/Meshes/mesh";
  51682. /**
  51683. * Class containing static functions to help procedurally build meshes
  51684. */
  51685. export class TorusKnotBuilder {
  51686. /**
  51687. * Creates a torus knot mesh
  51688. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  51689. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  51690. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  51691. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  51692. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51693. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51694. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  51695. * @param name defines the name of the mesh
  51696. * @param options defines the options used to create the mesh
  51697. * @param scene defines the hosting scene
  51698. * @returns the torus knot mesh
  51699. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  51700. */
  51701. static CreateTorusKnot(name: string, options: {
  51702. radius?: number;
  51703. tube?: number;
  51704. radialSegments?: number;
  51705. tubularSegments?: number;
  51706. p?: number;
  51707. q?: number;
  51708. updatable?: boolean;
  51709. sideOrientation?: number;
  51710. frontUVs?: Vector4;
  51711. backUVs?: Vector4;
  51712. }, scene: any): Mesh;
  51713. }
  51714. }
  51715. declare module "babylonjs/Meshes/polygonMesh" {
  51716. import { Scene } from "babylonjs/scene";
  51717. import { Vector2, Path2 } from "babylonjs/Maths/math";
  51718. import { Mesh } from "babylonjs/Meshes/mesh";
  51719. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  51720. /**
  51721. * Polygon
  51722. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  51723. */
  51724. export class Polygon {
  51725. /**
  51726. * Creates a rectangle
  51727. * @param xmin bottom X coord
  51728. * @param ymin bottom Y coord
  51729. * @param xmax top X coord
  51730. * @param ymax top Y coord
  51731. * @returns points that make the resulting rectation
  51732. */
  51733. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  51734. /**
  51735. * Creates a circle
  51736. * @param radius radius of circle
  51737. * @param cx scale in x
  51738. * @param cy scale in y
  51739. * @param numberOfSides number of sides that make up the circle
  51740. * @returns points that make the resulting circle
  51741. */
  51742. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  51743. /**
  51744. * Creates a polygon from input string
  51745. * @param input Input polygon data
  51746. * @returns the parsed points
  51747. */
  51748. static Parse(input: string): Vector2[];
  51749. /**
  51750. * Starts building a polygon from x and y coordinates
  51751. * @param x x coordinate
  51752. * @param y y coordinate
  51753. * @returns the started path2
  51754. */
  51755. static StartingAt(x: number, y: number): Path2;
  51756. }
  51757. /**
  51758. * Builds a polygon
  51759. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  51760. */
  51761. export class PolygonMeshBuilder {
  51762. private _points;
  51763. private _outlinepoints;
  51764. private _holes;
  51765. private _name;
  51766. private _scene;
  51767. private _epoints;
  51768. private _eholes;
  51769. private _addToepoint;
  51770. /**
  51771. * Babylon reference to the earcut plugin.
  51772. */
  51773. bjsEarcut: any;
  51774. /**
  51775. * Creates a PolygonMeshBuilder
  51776. * @param name name of the builder
  51777. * @param contours Path of the polygon
  51778. * @param scene scene to add to when creating the mesh
  51779. * @param earcutInjection can be used to inject your own earcut reference
  51780. */
  51781. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  51782. /**
  51783. * Adds a whole within the polygon
  51784. * @param hole Array of points defining the hole
  51785. * @returns this
  51786. */
  51787. addHole(hole: Vector2[]): PolygonMeshBuilder;
  51788. /**
  51789. * Creates the polygon
  51790. * @param updatable If the mesh should be updatable
  51791. * @param depth The depth of the mesh created
  51792. * @returns the created mesh
  51793. */
  51794. build(updatable?: boolean, depth?: number): Mesh;
  51795. /**
  51796. * Creates the polygon
  51797. * @param depth The depth of the mesh created
  51798. * @returns the created VertexData
  51799. */
  51800. buildVertexData(depth?: number): VertexData;
  51801. /**
  51802. * Adds a side to the polygon
  51803. * @param positions points that make the polygon
  51804. * @param normals normals of the polygon
  51805. * @param uvs uvs of the polygon
  51806. * @param indices indices of the polygon
  51807. * @param bounds bounds of the polygon
  51808. * @param points points of the polygon
  51809. * @param depth depth of the polygon
  51810. * @param flip flip of the polygon
  51811. */
  51812. private addSide;
  51813. }
  51814. }
  51815. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  51816. import { Scene } from "babylonjs/scene";
  51817. import { Vector3, Color4, Vector4 } from "babylonjs/Maths/math";
  51818. import { Mesh } from "babylonjs/Meshes/mesh";
  51819. import { Nullable } from "babylonjs/types";
  51820. /**
  51821. * Class containing static functions to help procedurally build meshes
  51822. */
  51823. export class PolygonBuilder {
  51824. /**
  51825. * Creates a polygon mesh
  51826. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  51827. * * 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
  51828. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  51829. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51830. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  51831. * * Remember you can only change the shape positions, not their number when updating a polygon
  51832. * @param name defines the name of the mesh
  51833. * @param options defines the options used to create the mesh
  51834. * @param scene defines the hosting scene
  51835. * @param earcutInjection can be used to inject your own earcut reference
  51836. * @returns the polygon mesh
  51837. */
  51838. static CreatePolygon(name: string, options: {
  51839. shape: Vector3[];
  51840. holes?: Vector3[][];
  51841. depth?: number;
  51842. faceUV?: Vector4[];
  51843. faceColors?: Color4[];
  51844. updatable?: boolean;
  51845. sideOrientation?: number;
  51846. frontUVs?: Vector4;
  51847. backUVs?: Vector4;
  51848. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  51849. /**
  51850. * Creates an extruded polygon mesh, with depth in the Y direction.
  51851. * * 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)
  51852. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  51853. * @param name defines the name of the mesh
  51854. * @param options defines the options used to create the mesh
  51855. * @param scene defines the hosting scene
  51856. * @param earcutInjection can be used to inject your own earcut reference
  51857. * @returns the polygon mesh
  51858. */
  51859. static ExtrudePolygon(name: string, options: {
  51860. shape: Vector3[];
  51861. holes?: Vector3[][];
  51862. depth?: number;
  51863. faceUV?: Vector4[];
  51864. faceColors?: Color4[];
  51865. updatable?: boolean;
  51866. sideOrientation?: number;
  51867. frontUVs?: Vector4;
  51868. backUVs?: Vector4;
  51869. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  51870. }
  51871. }
  51872. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  51873. import { Scene } from "babylonjs/scene";
  51874. import { Vector3, Vector4 } from "babylonjs/Maths/math";
  51875. import { Mesh } from "babylonjs/Meshes/mesh";
  51876. import { Nullable } from "babylonjs/types";
  51877. /**
  51878. * Class containing static functions to help procedurally build meshes
  51879. */
  51880. export class LatheBuilder {
  51881. /**
  51882. * Creates lathe mesh.
  51883. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  51884. * * 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
  51885. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  51886. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  51887. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  51888. * * 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
  51889. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  51890. * * 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
  51891. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51892. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51893. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  51894. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51895. * @param name defines the name of the mesh
  51896. * @param options defines the options used to create the mesh
  51897. * @param scene defines the hosting scene
  51898. * @returns the lathe mesh
  51899. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  51900. */
  51901. static CreateLathe(name: string, options: {
  51902. shape: Vector3[];
  51903. radius?: number;
  51904. tessellation?: number;
  51905. clip?: number;
  51906. arc?: number;
  51907. closed?: boolean;
  51908. updatable?: boolean;
  51909. sideOrientation?: number;
  51910. frontUVs?: Vector4;
  51911. backUVs?: Vector4;
  51912. cap?: number;
  51913. invertUV?: boolean;
  51914. }, scene?: Nullable<Scene>): Mesh;
  51915. }
  51916. }
  51917. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  51918. import { Nullable } from "babylonjs/types";
  51919. import { Scene } from "babylonjs/scene";
  51920. import { Vector3, Vector4 } from "babylonjs/Maths/math";
  51921. import { Mesh } from "babylonjs/Meshes/mesh";
  51922. /**
  51923. * Class containing static functions to help procedurally build meshes
  51924. */
  51925. export class TubeBuilder {
  51926. /**
  51927. * Creates a tube mesh.
  51928. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  51929. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  51930. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  51931. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  51932. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  51933. * * 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)
  51934. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  51935. * * 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
  51936. * * 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
  51937. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51938. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51939. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  51940. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51941. * @param name defines the name of the mesh
  51942. * @param options defines the options used to create the mesh
  51943. * @param scene defines the hosting scene
  51944. * @returns the tube mesh
  51945. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  51946. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  51947. */
  51948. static CreateTube(name: string, options: {
  51949. path: Vector3[];
  51950. radius?: number;
  51951. tessellation?: number;
  51952. radiusFunction?: {
  51953. (i: number, distance: number): number;
  51954. };
  51955. cap?: number;
  51956. arc?: number;
  51957. updatable?: boolean;
  51958. sideOrientation?: number;
  51959. frontUVs?: Vector4;
  51960. backUVs?: Vector4;
  51961. instance?: Mesh;
  51962. invertUV?: boolean;
  51963. }, scene?: Nullable<Scene>): Mesh;
  51964. }
  51965. }
  51966. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  51967. import { Scene } from "babylonjs/scene";
  51968. import { Vector4 } from "babylonjs/Maths/math";
  51969. import { Mesh } from "babylonjs/Meshes/mesh";
  51970. import { Nullable } from "babylonjs/types";
  51971. /**
  51972. * Class containing static functions to help procedurally build meshes
  51973. */
  51974. export class IcoSphereBuilder {
  51975. /**
  51976. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  51977. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  51978. * * 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`)
  51979. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  51980. * * 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
  51981. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51982. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51983. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51984. * @param name defines the name of the mesh
  51985. * @param options defines the options used to create the mesh
  51986. * @param scene defines the hosting scene
  51987. * @returns the icosahedron mesh
  51988. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  51989. */
  51990. static CreateIcoSphere(name: string, options: {
  51991. radius?: number;
  51992. radiusX?: number;
  51993. radiusY?: number;
  51994. radiusZ?: number;
  51995. flat?: boolean;
  51996. subdivisions?: number;
  51997. sideOrientation?: number;
  51998. frontUVs?: Vector4;
  51999. backUVs?: Vector4;
  52000. updatable?: boolean;
  52001. }, scene?: Nullable<Scene>): Mesh;
  52002. }
  52003. }
  52004. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  52005. import { Vector3 } from "babylonjs/Maths/math";
  52006. import { Mesh } from "babylonjs/Meshes/mesh";
  52007. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52008. /**
  52009. * Class containing static functions to help procedurally build meshes
  52010. */
  52011. export class DecalBuilder {
  52012. /**
  52013. * Creates a decal mesh.
  52014. * 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
  52015. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  52016. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  52017. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  52018. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  52019. * @param name defines the name of the mesh
  52020. * @param sourceMesh defines the mesh where the decal must be applied
  52021. * @param options defines the options used to create the mesh
  52022. * @param scene defines the hosting scene
  52023. * @returns the decal mesh
  52024. * @see https://doc.babylonjs.com/how_to/decals
  52025. */
  52026. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  52027. position?: Vector3;
  52028. normal?: Vector3;
  52029. size?: Vector3;
  52030. angle?: number;
  52031. }): Mesh;
  52032. }
  52033. }
  52034. declare module "babylonjs/Meshes/meshBuilder" {
  52035. import { Vector4, Color4, Vector3, Vector2, Plane, Color3 } from "babylonjs/Maths/math";
  52036. import { Nullable } from "babylonjs/types";
  52037. import { Scene } from "babylonjs/scene";
  52038. import { Mesh } from "babylonjs/Meshes/mesh";
  52039. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  52040. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  52041. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52042. /**
  52043. * Class containing static functions to help procedurally build meshes
  52044. */
  52045. export class MeshBuilder {
  52046. /**
  52047. * Creates a box mesh
  52048. * * The parameter `size` sets the size (float) of each box side (default 1)
  52049. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  52050. * * 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)
  52051. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  52052. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52053. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52054. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52055. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  52056. * @param name defines the name of the mesh
  52057. * @param options defines the options used to create the mesh
  52058. * @param scene defines the hosting scene
  52059. * @returns the box mesh
  52060. */
  52061. static CreateBox(name: string, options: {
  52062. size?: number;
  52063. width?: number;
  52064. height?: number;
  52065. depth?: number;
  52066. faceUV?: Vector4[];
  52067. faceColors?: Color4[];
  52068. sideOrientation?: number;
  52069. frontUVs?: Vector4;
  52070. backUVs?: Vector4;
  52071. updatable?: boolean;
  52072. }, scene?: Nullable<Scene>): Mesh;
  52073. /**
  52074. * Creates a sphere mesh
  52075. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  52076. * * 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`)
  52077. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  52078. * * 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
  52079. * * 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)
  52080. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52081. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52082. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52083. * @param name defines the name of the mesh
  52084. * @param options defines the options used to create the mesh
  52085. * @param scene defines the hosting scene
  52086. * @returns the sphere mesh
  52087. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  52088. */
  52089. static CreateSphere(name: string, options: {
  52090. segments?: number;
  52091. diameter?: number;
  52092. diameterX?: number;
  52093. diameterY?: number;
  52094. diameterZ?: number;
  52095. arc?: number;
  52096. slice?: number;
  52097. sideOrientation?: number;
  52098. frontUVs?: Vector4;
  52099. backUVs?: Vector4;
  52100. updatable?: boolean;
  52101. }, scene?: Nullable<Scene>): Mesh;
  52102. /**
  52103. * Creates a plane polygonal mesh. By default, this is a disc
  52104. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  52105. * * 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
  52106. * * 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
  52107. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52108. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52109. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52110. * @param name defines the name of the mesh
  52111. * @param options defines the options used to create the mesh
  52112. * @param scene defines the hosting scene
  52113. * @returns the plane polygonal mesh
  52114. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  52115. */
  52116. static CreateDisc(name: string, options: {
  52117. radius?: number;
  52118. tessellation?: number;
  52119. arc?: number;
  52120. updatable?: boolean;
  52121. sideOrientation?: number;
  52122. frontUVs?: Vector4;
  52123. backUVs?: Vector4;
  52124. }, scene?: Nullable<Scene>): Mesh;
  52125. /**
  52126. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  52127. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  52128. * * 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`)
  52129. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  52130. * * 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
  52131. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52132. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52133. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52134. * @param name defines the name of the mesh
  52135. * @param options defines the options used to create the mesh
  52136. * @param scene defines the hosting scene
  52137. * @returns the icosahedron mesh
  52138. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  52139. */
  52140. static CreateIcoSphere(name: string, options: {
  52141. radius?: number;
  52142. radiusX?: number;
  52143. radiusY?: number;
  52144. radiusZ?: number;
  52145. flat?: boolean;
  52146. subdivisions?: number;
  52147. sideOrientation?: number;
  52148. frontUVs?: Vector4;
  52149. backUVs?: Vector4;
  52150. updatable?: boolean;
  52151. }, scene?: Nullable<Scene>): Mesh;
  52152. /**
  52153. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  52154. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  52155. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  52156. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  52157. * * 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
  52158. * * 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
  52159. * * 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
  52160. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52161. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52162. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  52163. * * 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
  52164. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  52165. * * 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
  52166. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  52167. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52168. * @param name defines the name of the mesh
  52169. * @param options defines the options used to create the mesh
  52170. * @param scene defines the hosting scene
  52171. * @returns the ribbon mesh
  52172. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  52173. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52174. */
  52175. static CreateRibbon(name: string, options: {
  52176. pathArray: Vector3[][];
  52177. closeArray?: boolean;
  52178. closePath?: boolean;
  52179. offset?: number;
  52180. updatable?: boolean;
  52181. sideOrientation?: number;
  52182. frontUVs?: Vector4;
  52183. backUVs?: Vector4;
  52184. instance?: Mesh;
  52185. invertUV?: boolean;
  52186. uvs?: Vector2[];
  52187. colors?: Color4[];
  52188. }, scene?: Nullable<Scene>): Mesh;
  52189. /**
  52190. * Creates a cylinder or a cone mesh
  52191. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  52192. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  52193. * * 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.
  52194. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  52195. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  52196. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  52197. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  52198. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  52199. * * 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).
  52200. * * 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
  52201. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  52202. * * 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
  52203. * * 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.
  52204. * * If `enclose` is false, a ring surface is one element.
  52205. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  52206. * * 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
  52207. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52208. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52209. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52210. * @param name defines the name of the mesh
  52211. * @param options defines the options used to create the mesh
  52212. * @param scene defines the hosting scene
  52213. * @returns the cylinder mesh
  52214. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  52215. */
  52216. static CreateCylinder(name: string, options: {
  52217. height?: number;
  52218. diameterTop?: number;
  52219. diameterBottom?: number;
  52220. diameter?: number;
  52221. tessellation?: number;
  52222. subdivisions?: number;
  52223. arc?: number;
  52224. faceColors?: Color4[];
  52225. faceUV?: Vector4[];
  52226. updatable?: boolean;
  52227. hasRings?: boolean;
  52228. enclose?: boolean;
  52229. sideOrientation?: number;
  52230. frontUVs?: Vector4;
  52231. backUVs?: Vector4;
  52232. }, scene?: Nullable<Scene>): Mesh;
  52233. /**
  52234. * Creates a torus mesh
  52235. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  52236. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  52237. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  52238. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52239. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52240. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52241. * @param name defines the name of the mesh
  52242. * @param options defines the options used to create the mesh
  52243. * @param scene defines the hosting scene
  52244. * @returns the torus mesh
  52245. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  52246. */
  52247. static CreateTorus(name: string, options: {
  52248. diameter?: number;
  52249. thickness?: number;
  52250. tessellation?: number;
  52251. updatable?: boolean;
  52252. sideOrientation?: number;
  52253. frontUVs?: Vector4;
  52254. backUVs?: Vector4;
  52255. }, scene?: Nullable<Scene>): Mesh;
  52256. /**
  52257. * Creates a torus knot mesh
  52258. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  52259. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  52260. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  52261. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  52262. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52263. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52264. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52265. * @param name defines the name of the mesh
  52266. * @param options defines the options used to create the mesh
  52267. * @param scene defines the hosting scene
  52268. * @returns the torus knot mesh
  52269. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  52270. */
  52271. static CreateTorusKnot(name: string, options: {
  52272. radius?: number;
  52273. tube?: number;
  52274. radialSegments?: number;
  52275. tubularSegments?: number;
  52276. p?: number;
  52277. q?: number;
  52278. updatable?: boolean;
  52279. sideOrientation?: number;
  52280. frontUVs?: Vector4;
  52281. backUVs?: Vector4;
  52282. }, scene?: Nullable<Scene>): Mesh;
  52283. /**
  52284. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  52285. * * 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
  52286. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  52287. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  52288. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  52289. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  52290. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  52291. * * 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
  52292. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  52293. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52294. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  52295. * @param name defines the name of the new line system
  52296. * @param options defines the options used to create the line system
  52297. * @param scene defines the hosting scene
  52298. * @returns a new line system mesh
  52299. */
  52300. static CreateLineSystem(name: string, options: {
  52301. lines: Vector3[][];
  52302. updatable?: boolean;
  52303. instance?: Nullable<LinesMesh>;
  52304. colors?: Nullable<Color4[][]>;
  52305. useVertexAlpha?: boolean;
  52306. }, scene: Nullable<Scene>): LinesMesh;
  52307. /**
  52308. * Creates a line mesh
  52309. * 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
  52310. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  52311. * * The parameter `points` is an array successive Vector3
  52312. * * 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
  52313. * * The optional parameter `colors` is an array of successive Color4, one per line point
  52314. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  52315. * * When updating an instance, remember that only point positions can change, not the number of points
  52316. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52317. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  52318. * @param name defines the name of the new line system
  52319. * @param options defines the options used to create the line system
  52320. * @param scene defines the hosting scene
  52321. * @returns a new line mesh
  52322. */
  52323. static CreateLines(name: string, options: {
  52324. points: Vector3[];
  52325. updatable?: boolean;
  52326. instance?: Nullable<LinesMesh>;
  52327. colors?: Color4[];
  52328. useVertexAlpha?: boolean;
  52329. }, scene?: Nullable<Scene>): LinesMesh;
  52330. /**
  52331. * Creates a dashed line mesh
  52332. * * 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
  52333. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  52334. * * The parameter `points` is an array successive Vector3
  52335. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  52336. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  52337. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  52338. * * 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
  52339. * * When updating an instance, remember that only point positions can change, not the number of points
  52340. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52341. * @param name defines the name of the mesh
  52342. * @param options defines the options used to create the mesh
  52343. * @param scene defines the hosting scene
  52344. * @returns the dashed line mesh
  52345. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  52346. */
  52347. static CreateDashedLines(name: string, options: {
  52348. points: Vector3[];
  52349. dashSize?: number;
  52350. gapSize?: number;
  52351. dashNb?: number;
  52352. updatable?: boolean;
  52353. instance?: LinesMesh;
  52354. }, scene?: Nullable<Scene>): LinesMesh;
  52355. /**
  52356. * 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.
  52357. * * 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.
  52358. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  52359. * * 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.
  52360. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  52361. * * 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
  52362. * * 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
  52363. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  52364. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52365. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52366. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  52367. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52368. * @param name defines the name of the mesh
  52369. * @param options defines the options used to create the mesh
  52370. * @param scene defines the hosting scene
  52371. * @returns the extruded shape mesh
  52372. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52373. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  52374. */
  52375. static ExtrudeShape(name: string, options: {
  52376. shape: Vector3[];
  52377. path: Vector3[];
  52378. scale?: number;
  52379. rotation?: number;
  52380. cap?: number;
  52381. updatable?: boolean;
  52382. sideOrientation?: number;
  52383. frontUVs?: Vector4;
  52384. backUVs?: Vector4;
  52385. instance?: Mesh;
  52386. invertUV?: boolean;
  52387. }, scene?: Nullable<Scene>): Mesh;
  52388. /**
  52389. * Creates an custom extruded shape mesh.
  52390. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  52391. * * 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.
  52392. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  52393. * * 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
  52394. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  52395. * * 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
  52396. * * It must returns a float value that will be the scale value applied to the shape on each path point
  52397. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  52398. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  52399. * * 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
  52400. * * 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
  52401. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  52402. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52403. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52404. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  52405. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52406. * @param name defines the name of the mesh
  52407. * @param options defines the options used to create the mesh
  52408. * @param scene defines the hosting scene
  52409. * @returns the custom extruded shape mesh
  52410. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  52411. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52412. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  52413. */
  52414. static ExtrudeShapeCustom(name: string, options: {
  52415. shape: Vector3[];
  52416. path: Vector3[];
  52417. scaleFunction?: any;
  52418. rotationFunction?: any;
  52419. ribbonCloseArray?: boolean;
  52420. ribbonClosePath?: boolean;
  52421. cap?: number;
  52422. updatable?: boolean;
  52423. sideOrientation?: number;
  52424. frontUVs?: Vector4;
  52425. backUVs?: Vector4;
  52426. instance?: Mesh;
  52427. invertUV?: boolean;
  52428. }, scene?: Nullable<Scene>): Mesh;
  52429. /**
  52430. * Creates lathe mesh.
  52431. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  52432. * * 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
  52433. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  52434. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  52435. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  52436. * * 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
  52437. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  52438. * * 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
  52439. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52440. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52441. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  52442. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52443. * @param name defines the name of the mesh
  52444. * @param options defines the options used to create the mesh
  52445. * @param scene defines the hosting scene
  52446. * @returns the lathe mesh
  52447. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  52448. */
  52449. static CreateLathe(name: string, options: {
  52450. shape: Vector3[];
  52451. radius?: number;
  52452. tessellation?: number;
  52453. clip?: number;
  52454. arc?: number;
  52455. closed?: boolean;
  52456. updatable?: boolean;
  52457. sideOrientation?: number;
  52458. frontUVs?: Vector4;
  52459. backUVs?: Vector4;
  52460. cap?: number;
  52461. invertUV?: boolean;
  52462. }, scene?: Nullable<Scene>): Mesh;
  52463. /**
  52464. * Creates a plane mesh
  52465. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  52466. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  52467. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  52468. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52469. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52470. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52471. * @param name defines the name of the mesh
  52472. * @param options defines the options used to create the mesh
  52473. * @param scene defines the hosting scene
  52474. * @returns the plane mesh
  52475. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  52476. */
  52477. static CreatePlane(name: string, options: {
  52478. size?: number;
  52479. width?: number;
  52480. height?: number;
  52481. sideOrientation?: number;
  52482. frontUVs?: Vector4;
  52483. backUVs?: Vector4;
  52484. updatable?: boolean;
  52485. sourcePlane?: Plane;
  52486. }, scene?: Nullable<Scene>): Mesh;
  52487. /**
  52488. * Creates a ground mesh
  52489. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  52490. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  52491. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52492. * @param name defines the name of the mesh
  52493. * @param options defines the options used to create the mesh
  52494. * @param scene defines the hosting scene
  52495. * @returns the ground mesh
  52496. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  52497. */
  52498. static CreateGround(name: string, options: {
  52499. width?: number;
  52500. height?: number;
  52501. subdivisions?: number;
  52502. subdivisionsX?: number;
  52503. subdivisionsY?: number;
  52504. updatable?: boolean;
  52505. }, scene?: Nullable<Scene>): Mesh;
  52506. /**
  52507. * Creates a tiled ground mesh
  52508. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  52509. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  52510. * * 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
  52511. * * 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
  52512. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52513. * @param name defines the name of the mesh
  52514. * @param options defines the options used to create the mesh
  52515. * @param scene defines the hosting scene
  52516. * @returns the tiled ground mesh
  52517. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  52518. */
  52519. static CreateTiledGround(name: string, options: {
  52520. xmin: number;
  52521. zmin: number;
  52522. xmax: number;
  52523. zmax: number;
  52524. subdivisions?: {
  52525. w: number;
  52526. h: number;
  52527. };
  52528. precision?: {
  52529. w: number;
  52530. h: number;
  52531. };
  52532. updatable?: boolean;
  52533. }, scene?: Nullable<Scene>): Mesh;
  52534. /**
  52535. * Creates a ground mesh from a height map
  52536. * * The parameter `url` sets the URL of the height map image resource.
  52537. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  52538. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  52539. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  52540. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  52541. * * 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.
  52542. * * 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).
  52543. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  52544. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52545. * @param name defines the name of the mesh
  52546. * @param url defines the url to the height map
  52547. * @param options defines the options used to create the mesh
  52548. * @param scene defines the hosting scene
  52549. * @returns the ground mesh
  52550. * @see https://doc.babylonjs.com/babylon101/height_map
  52551. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  52552. */
  52553. static CreateGroundFromHeightMap(name: string, url: string, options: {
  52554. width?: number;
  52555. height?: number;
  52556. subdivisions?: number;
  52557. minHeight?: number;
  52558. maxHeight?: number;
  52559. colorFilter?: Color3;
  52560. alphaFilter?: number;
  52561. updatable?: boolean;
  52562. onReady?: (mesh: GroundMesh) => void;
  52563. }, scene?: Nullable<Scene>): GroundMesh;
  52564. /**
  52565. * Creates a polygon mesh
  52566. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  52567. * * 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
  52568. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  52569. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52570. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  52571. * * Remember you can only change the shape positions, not their number when updating a polygon
  52572. * @param name defines the name of the mesh
  52573. * @param options defines the options used to create the mesh
  52574. * @param scene defines the hosting scene
  52575. * @param earcutInjection can be used to inject your own earcut reference
  52576. * @returns the polygon mesh
  52577. */
  52578. static CreatePolygon(name: string, options: {
  52579. shape: Vector3[];
  52580. holes?: Vector3[][];
  52581. depth?: number;
  52582. faceUV?: Vector4[];
  52583. faceColors?: Color4[];
  52584. updatable?: boolean;
  52585. sideOrientation?: number;
  52586. frontUVs?: Vector4;
  52587. backUVs?: Vector4;
  52588. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  52589. /**
  52590. * Creates an extruded polygon mesh, with depth in the Y direction.
  52591. * * 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)
  52592. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  52593. * @param name defines the name of the mesh
  52594. * @param options defines the options used to create the mesh
  52595. * @param scene defines the hosting scene
  52596. * @param earcutInjection can be used to inject your own earcut reference
  52597. * @returns the polygon mesh
  52598. */
  52599. static ExtrudePolygon(name: string, options: {
  52600. shape: Vector3[];
  52601. holes?: Vector3[][];
  52602. depth?: number;
  52603. faceUV?: Vector4[];
  52604. faceColors?: Color4[];
  52605. updatable?: boolean;
  52606. sideOrientation?: number;
  52607. frontUVs?: Vector4;
  52608. backUVs?: Vector4;
  52609. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  52610. /**
  52611. * Creates a tube mesh.
  52612. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  52613. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  52614. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  52615. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  52616. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  52617. * * 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)
  52618. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  52619. * * 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
  52620. * * 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
  52621. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52622. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52623. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  52624. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52625. * @param name defines the name of the mesh
  52626. * @param options defines the options used to create the mesh
  52627. * @param scene defines the hosting scene
  52628. * @returns the tube mesh
  52629. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52630. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  52631. */
  52632. static CreateTube(name: string, options: {
  52633. path: Vector3[];
  52634. radius?: number;
  52635. tessellation?: number;
  52636. radiusFunction?: {
  52637. (i: number, distance: number): number;
  52638. };
  52639. cap?: number;
  52640. arc?: number;
  52641. updatable?: boolean;
  52642. sideOrientation?: number;
  52643. frontUVs?: Vector4;
  52644. backUVs?: Vector4;
  52645. instance?: Mesh;
  52646. invertUV?: boolean;
  52647. }, scene?: Nullable<Scene>): Mesh;
  52648. /**
  52649. * Creates a polyhedron mesh
  52650. * * 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
  52651. * * The parameter `size` (positive float, default 1) sets the polygon size
  52652. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  52653. * * 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`
  52654. * * 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
  52655. * * 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)`)
  52656. * * 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
  52657. * * 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
  52658. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52659. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52660. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52661. * @param name defines the name of the mesh
  52662. * @param options defines the options used to create the mesh
  52663. * @param scene defines the hosting scene
  52664. * @returns the polyhedron mesh
  52665. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  52666. */
  52667. static CreatePolyhedron(name: string, options: {
  52668. type?: number;
  52669. size?: number;
  52670. sizeX?: number;
  52671. sizeY?: number;
  52672. sizeZ?: number;
  52673. custom?: any;
  52674. faceUV?: Vector4[];
  52675. faceColors?: Color4[];
  52676. flat?: boolean;
  52677. updatable?: boolean;
  52678. sideOrientation?: number;
  52679. frontUVs?: Vector4;
  52680. backUVs?: Vector4;
  52681. }, scene?: Nullable<Scene>): Mesh;
  52682. /**
  52683. * Creates a decal mesh.
  52684. * 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
  52685. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  52686. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  52687. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  52688. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  52689. * @param name defines the name of the mesh
  52690. * @param sourceMesh defines the mesh where the decal must be applied
  52691. * @param options defines the options used to create the mesh
  52692. * @param scene defines the hosting scene
  52693. * @returns the decal mesh
  52694. * @see https://doc.babylonjs.com/how_to/decals
  52695. */
  52696. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  52697. position?: Vector3;
  52698. normal?: Vector3;
  52699. size?: Vector3;
  52700. angle?: number;
  52701. }): Mesh;
  52702. }
  52703. }
  52704. declare module "babylonjs/Meshes/meshSimplification" {
  52705. import { Mesh } from "babylonjs/Meshes/mesh";
  52706. /**
  52707. * A simplifier interface for future simplification implementations
  52708. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  52709. */
  52710. export interface ISimplifier {
  52711. /**
  52712. * Simplification of a given mesh according to the given settings.
  52713. * Since this requires computation, it is assumed that the function runs async.
  52714. * @param settings The settings of the simplification, including quality and distance
  52715. * @param successCallback A callback that will be called after the mesh was simplified.
  52716. * @param errorCallback in case of an error, this callback will be called. optional.
  52717. */
  52718. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  52719. }
  52720. /**
  52721. * Expected simplification settings.
  52722. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  52723. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  52724. */
  52725. export interface ISimplificationSettings {
  52726. /**
  52727. * Gets or sets the expected quality
  52728. */
  52729. quality: number;
  52730. /**
  52731. * Gets or sets the distance when this optimized version should be used
  52732. */
  52733. distance: number;
  52734. /**
  52735. * Gets an already optimized mesh
  52736. */
  52737. optimizeMesh?: boolean;
  52738. }
  52739. /**
  52740. * Class used to specify simplification options
  52741. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  52742. */
  52743. export class SimplificationSettings implements ISimplificationSettings {
  52744. /** expected quality */
  52745. quality: number;
  52746. /** distance when this optimized version should be used */
  52747. distance: number;
  52748. /** already optimized mesh */
  52749. optimizeMesh?: boolean | undefined;
  52750. /**
  52751. * Creates a SimplificationSettings
  52752. * @param quality expected quality
  52753. * @param distance distance when this optimized version should be used
  52754. * @param optimizeMesh already optimized mesh
  52755. */
  52756. constructor(
  52757. /** expected quality */
  52758. quality: number,
  52759. /** distance when this optimized version should be used */
  52760. distance: number,
  52761. /** already optimized mesh */
  52762. optimizeMesh?: boolean | undefined);
  52763. }
  52764. /**
  52765. * Interface used to define a simplification task
  52766. */
  52767. export interface ISimplificationTask {
  52768. /**
  52769. * Array of settings
  52770. */
  52771. settings: Array<ISimplificationSettings>;
  52772. /**
  52773. * Simplification type
  52774. */
  52775. simplificationType: SimplificationType;
  52776. /**
  52777. * Mesh to simplify
  52778. */
  52779. mesh: Mesh;
  52780. /**
  52781. * Callback called on success
  52782. */
  52783. successCallback?: () => void;
  52784. /**
  52785. * Defines if parallel processing can be used
  52786. */
  52787. parallelProcessing: boolean;
  52788. }
  52789. /**
  52790. * Queue used to order the simplification tasks
  52791. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  52792. */
  52793. export class SimplificationQueue {
  52794. private _simplificationArray;
  52795. /**
  52796. * Gets a boolean indicating that the process is still running
  52797. */
  52798. running: boolean;
  52799. /**
  52800. * Creates a new queue
  52801. */
  52802. constructor();
  52803. /**
  52804. * Adds a new simplification task
  52805. * @param task defines a task to add
  52806. */
  52807. addTask(task: ISimplificationTask): void;
  52808. /**
  52809. * Execute next task
  52810. */
  52811. executeNext(): void;
  52812. /**
  52813. * Execute a simplification task
  52814. * @param task defines the task to run
  52815. */
  52816. runSimplification(task: ISimplificationTask): void;
  52817. private getSimplifier;
  52818. }
  52819. /**
  52820. * The implemented types of simplification
  52821. * At the moment only Quadratic Error Decimation is implemented
  52822. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  52823. */
  52824. export enum SimplificationType {
  52825. /** Quadratic error decimation */
  52826. QUADRATIC = 0
  52827. }
  52828. }
  52829. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  52830. import { Scene } from "babylonjs/scene";
  52831. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  52832. import { ISceneComponent } from "babylonjs/sceneComponent";
  52833. module "babylonjs/scene" {
  52834. interface Scene {
  52835. /** @hidden (Backing field) */
  52836. _simplificationQueue: SimplificationQueue;
  52837. /**
  52838. * Gets or sets the simplification queue attached to the scene
  52839. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  52840. */
  52841. simplificationQueue: SimplificationQueue;
  52842. }
  52843. }
  52844. module "babylonjs/Meshes/mesh" {
  52845. interface Mesh {
  52846. /**
  52847. * Simplify the mesh according to the given array of settings.
  52848. * Function will return immediately and will simplify async
  52849. * @param settings a collection of simplification settings
  52850. * @param parallelProcessing should all levels calculate parallel or one after the other
  52851. * @param simplificationType the type of simplification to run
  52852. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  52853. * @returns the current mesh
  52854. */
  52855. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  52856. }
  52857. }
  52858. /**
  52859. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  52860. * created in a scene
  52861. */
  52862. export class SimplicationQueueSceneComponent implements ISceneComponent {
  52863. /**
  52864. * The component name helpfull to identify the component in the list of scene components.
  52865. */
  52866. readonly name: string;
  52867. /**
  52868. * The scene the component belongs to.
  52869. */
  52870. scene: Scene;
  52871. /**
  52872. * Creates a new instance of the component for the given scene
  52873. * @param scene Defines the scene to register the component in
  52874. */
  52875. constructor(scene: Scene);
  52876. /**
  52877. * Registers the component in a given scene
  52878. */
  52879. register(): void;
  52880. /**
  52881. * Rebuilds the elements related to this component in case of
  52882. * context lost for instance.
  52883. */
  52884. rebuild(): void;
  52885. /**
  52886. * Disposes the component and the associated ressources
  52887. */
  52888. dispose(): void;
  52889. private _beforeCameraUpdate;
  52890. }
  52891. }
  52892. declare module "babylonjs/Meshes/Builders/index" {
  52893. export * from "babylonjs/Meshes/Builders/boxBuilder";
  52894. export * from "babylonjs/Meshes/Builders/discBuilder";
  52895. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  52896. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  52897. export * from "babylonjs/Meshes/Builders/hemisphereBuilder";
  52898. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  52899. export * from "babylonjs/Meshes/Builders/torusBuilder";
  52900. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  52901. export * from "babylonjs/Meshes/Builders/linesBuilder";
  52902. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  52903. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  52904. export * from "babylonjs/Meshes/Builders/latheBuilder";
  52905. export * from "babylonjs/Meshes/Builders/planeBuilder";
  52906. export * from "babylonjs/Meshes/Builders/groundBuilder";
  52907. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  52908. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  52909. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  52910. export * from "babylonjs/Meshes/Builders/decalBuilder";
  52911. }
  52912. declare module "babylonjs/Meshes/index" {
  52913. export * from "babylonjs/Meshes/abstractMesh";
  52914. export * from "babylonjs/Meshes/buffer";
  52915. export * from "babylonjs/Meshes/Compression/index";
  52916. export * from "babylonjs/Meshes/csg";
  52917. export * from "babylonjs/Meshes/geometry";
  52918. export * from "babylonjs/Meshes/groundMesh";
  52919. export * from "babylonjs/Meshes/trailMesh";
  52920. export * from "babylonjs/Meshes/instancedMesh";
  52921. export * from "babylonjs/Meshes/linesMesh";
  52922. export * from "babylonjs/Meshes/mesh";
  52923. export * from "babylonjs/Meshes/mesh.vertexData";
  52924. export * from "babylonjs/Meshes/meshBuilder";
  52925. export * from "babylonjs/Meshes/meshSimplification";
  52926. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  52927. export * from "babylonjs/Meshes/polygonMesh";
  52928. export * from "babylonjs/Meshes/subMesh";
  52929. export * from "babylonjs/Meshes/transformNode";
  52930. export * from "babylonjs/Meshes/Builders/index";
  52931. }
  52932. declare module "babylonjs/Morph/index" {
  52933. export * from "babylonjs/Morph/morphTarget";
  52934. export * from "babylonjs/Morph/morphTargetManager";
  52935. }
  52936. declare module "babylonjs/Offline/database" {
  52937. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  52938. /**
  52939. * Class used to enable access to IndexedDB
  52940. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  52941. */
  52942. export class Database implements IOfflineProvider {
  52943. private _callbackManifestChecked;
  52944. private _currentSceneUrl;
  52945. private _db;
  52946. private _enableSceneOffline;
  52947. private _enableTexturesOffline;
  52948. private _manifestVersionFound;
  52949. private _mustUpdateRessources;
  52950. private _hasReachedQuota;
  52951. private _isSupported;
  52952. private _idbFactory;
  52953. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  52954. private static IsUASupportingBlobStorage;
  52955. /**
  52956. * Gets a boolean indicating if Database storate is enabled (off by default)
  52957. */
  52958. static IDBStorageEnabled: boolean;
  52959. /**
  52960. * Gets a boolean indicating if scene must be saved in the database
  52961. */
  52962. readonly enableSceneOffline: boolean;
  52963. /**
  52964. * Gets a boolean indicating if textures must be saved in the database
  52965. */
  52966. readonly enableTexturesOffline: boolean;
  52967. /**
  52968. * Creates a new Database
  52969. * @param urlToScene defines the url to load the scene
  52970. * @param callbackManifestChecked defines the callback to use when manifest is checked
  52971. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  52972. */
  52973. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  52974. private static _ParseURL;
  52975. private static _ReturnFullUrlLocation;
  52976. private _checkManifestFile;
  52977. /**
  52978. * Open the database and make it available
  52979. * @param successCallback defines the callback to call on success
  52980. * @param errorCallback defines the callback to call on error
  52981. */
  52982. open(successCallback: () => void, errorCallback: () => void): void;
  52983. /**
  52984. * Loads an image from the database
  52985. * @param url defines the url to load from
  52986. * @param image defines the target DOM image
  52987. */
  52988. loadImage(url: string, image: HTMLImageElement): void;
  52989. private _loadImageFromDBAsync;
  52990. private _saveImageIntoDBAsync;
  52991. private _checkVersionFromDB;
  52992. private _loadVersionFromDBAsync;
  52993. private _saveVersionIntoDBAsync;
  52994. /**
  52995. * Loads a file from database
  52996. * @param url defines the URL to load from
  52997. * @param sceneLoaded defines a callback to call on success
  52998. * @param progressCallBack defines a callback to call when progress changed
  52999. * @param errorCallback defines a callback to call on error
  53000. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  53001. */
  53002. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  53003. private _loadFileAsync;
  53004. private _saveFileAsync;
  53005. /**
  53006. * Validates if xhr data is correct
  53007. * @param xhr defines the request to validate
  53008. * @param dataType defines the expected data type
  53009. * @returns true if data is correct
  53010. */
  53011. private static _ValidateXHRData;
  53012. }
  53013. }
  53014. declare module "babylonjs/Offline/index" {
  53015. export * from "babylonjs/Offline/database";
  53016. export * from "babylonjs/Offline/IOfflineProvider";
  53017. }
  53018. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  53019. /** @hidden */
  53020. export var gpuUpdateParticlesPixelShader: {
  53021. name: string;
  53022. shader: string;
  53023. };
  53024. }
  53025. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  53026. /** @hidden */
  53027. export var gpuUpdateParticlesVertexShader: {
  53028. name: string;
  53029. shader: string;
  53030. };
  53031. }
  53032. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  53033. /** @hidden */
  53034. export var clipPlaneFragmentDeclaration2: {
  53035. name: string;
  53036. shader: string;
  53037. };
  53038. }
  53039. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  53040. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  53041. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  53042. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  53043. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  53044. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  53045. /** @hidden */
  53046. export var gpuRenderParticlesPixelShader: {
  53047. name: string;
  53048. shader: string;
  53049. };
  53050. }
  53051. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  53052. /** @hidden */
  53053. export var clipPlaneVertexDeclaration2: {
  53054. name: string;
  53055. shader: string;
  53056. };
  53057. }
  53058. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  53059. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  53060. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  53061. /** @hidden */
  53062. export var gpuRenderParticlesVertexShader: {
  53063. name: string;
  53064. shader: string;
  53065. };
  53066. }
  53067. declare module "babylonjs/Particles/gpuParticleSystem" {
  53068. import { Nullable } from "babylonjs/types";
  53069. import { IAnimatable, IValueGradient, Color3Gradient } from "babylonjs/Misc/tools";
  53070. import { Observable } from "babylonjs/Misc/observable";
  53071. import { Color4, Color3 } from "babylonjs/Maths/math";
  53072. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  53073. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  53074. import { Scene, IDisposable } from "babylonjs/scene";
  53075. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  53076. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  53077. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  53078. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  53079. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  53080. /**
  53081. * This represents a GPU particle system in Babylon
  53082. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  53083. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  53084. */
  53085. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  53086. /**
  53087. * The layer mask we are rendering the particles through.
  53088. */
  53089. layerMask: number;
  53090. private _capacity;
  53091. private _activeCount;
  53092. private _currentActiveCount;
  53093. private _accumulatedCount;
  53094. private _renderEffect;
  53095. private _updateEffect;
  53096. private _buffer0;
  53097. private _buffer1;
  53098. private _spriteBuffer;
  53099. private _updateVAO;
  53100. private _renderVAO;
  53101. private _targetIndex;
  53102. private _sourceBuffer;
  53103. private _targetBuffer;
  53104. private _engine;
  53105. private _currentRenderId;
  53106. private _started;
  53107. private _stopped;
  53108. private _timeDelta;
  53109. private _randomTexture;
  53110. private _randomTexture2;
  53111. private _attributesStrideSize;
  53112. private _updateEffectOptions;
  53113. private _randomTextureSize;
  53114. private _actualFrame;
  53115. private readonly _rawTextureWidth;
  53116. /**
  53117. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  53118. */
  53119. static readonly IsSupported: boolean;
  53120. /**
  53121. * An event triggered when the system is disposed.
  53122. */
  53123. onDisposeObservable: Observable<GPUParticleSystem>;
  53124. /**
  53125. * Gets the maximum number of particles active at the same time.
  53126. * @returns The max number of active particles.
  53127. */
  53128. getCapacity(): number;
  53129. /**
  53130. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  53131. * to override the particles.
  53132. */
  53133. forceDepthWrite: boolean;
  53134. /**
  53135. * Gets or set the number of active particles
  53136. */
  53137. activeParticleCount: number;
  53138. private _preWarmDone;
  53139. /**
  53140. * Is this system ready to be used/rendered
  53141. * @return true if the system is ready
  53142. */
  53143. isReady(): boolean;
  53144. /**
  53145. * Gets if the system has been started. (Note: this will still be true after stop is called)
  53146. * @returns True if it has been started, otherwise false.
  53147. */
  53148. isStarted(): boolean;
  53149. /**
  53150. * Starts the particle system and begins to emit
  53151. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  53152. */
  53153. start(delay?: number): void;
  53154. /**
  53155. * Stops the particle system.
  53156. */
  53157. stop(): void;
  53158. /**
  53159. * Remove all active particles
  53160. */
  53161. reset(): void;
  53162. /**
  53163. * Returns the string "GPUParticleSystem"
  53164. * @returns a string containing the class name
  53165. */
  53166. getClassName(): string;
  53167. private _colorGradientsTexture;
  53168. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  53169. /**
  53170. * Adds a new color gradient
  53171. * @param gradient defines the gradient to use (between 0 and 1)
  53172. * @param color1 defines the color to affect to the specified gradient
  53173. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  53174. * @returns the current particle system
  53175. */
  53176. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  53177. /**
  53178. * Remove a specific color gradient
  53179. * @param gradient defines the gradient to remove
  53180. * @returns the current particle system
  53181. */
  53182. removeColorGradient(gradient: number): GPUParticleSystem;
  53183. private _angularSpeedGradientsTexture;
  53184. private _sizeGradientsTexture;
  53185. private _velocityGradientsTexture;
  53186. private _limitVelocityGradientsTexture;
  53187. private _dragGradientsTexture;
  53188. private _addFactorGradient;
  53189. /**
  53190. * Adds a new size gradient
  53191. * @param gradient defines the gradient to use (between 0 and 1)
  53192. * @param factor defines the size factor to affect to the specified gradient
  53193. * @returns the current particle system
  53194. */
  53195. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  53196. /**
  53197. * Remove a specific size gradient
  53198. * @param gradient defines the gradient to remove
  53199. * @returns the current particle system
  53200. */
  53201. removeSizeGradient(gradient: number): GPUParticleSystem;
  53202. /**
  53203. * Adds a new angular speed gradient
  53204. * @param gradient defines the gradient to use (between 0 and 1)
  53205. * @param factor defines the angular speed to affect to the specified gradient
  53206. * @returns the current particle system
  53207. */
  53208. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  53209. /**
  53210. * Remove a specific angular speed gradient
  53211. * @param gradient defines the gradient to remove
  53212. * @returns the current particle system
  53213. */
  53214. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  53215. /**
  53216. * Adds a new velocity gradient
  53217. * @param gradient defines the gradient to use (between 0 and 1)
  53218. * @param factor defines the velocity to affect to the specified gradient
  53219. * @returns the current particle system
  53220. */
  53221. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  53222. /**
  53223. * Remove a specific velocity gradient
  53224. * @param gradient defines the gradient to remove
  53225. * @returns the current particle system
  53226. */
  53227. removeVelocityGradient(gradient: number): GPUParticleSystem;
  53228. /**
  53229. * Adds a new limit velocity gradient
  53230. * @param gradient defines the gradient to use (between 0 and 1)
  53231. * @param factor defines the limit velocity value to affect to the specified gradient
  53232. * @returns the current particle system
  53233. */
  53234. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  53235. /**
  53236. * Remove a specific limit velocity gradient
  53237. * @param gradient defines the gradient to remove
  53238. * @returns the current particle system
  53239. */
  53240. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  53241. /**
  53242. * Adds a new drag gradient
  53243. * @param gradient defines the gradient to use (between 0 and 1)
  53244. * @param factor defines the drag value to affect to the specified gradient
  53245. * @returns the current particle system
  53246. */
  53247. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  53248. /**
  53249. * Remove a specific drag gradient
  53250. * @param gradient defines the gradient to remove
  53251. * @returns the current particle system
  53252. */
  53253. removeDragGradient(gradient: number): GPUParticleSystem;
  53254. /**
  53255. * Not supported by GPUParticleSystem
  53256. * @param gradient defines the gradient to use (between 0 and 1)
  53257. * @param factor defines the emit rate value to affect to the specified gradient
  53258. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  53259. * @returns the current particle system
  53260. */
  53261. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  53262. /**
  53263. * Not supported by GPUParticleSystem
  53264. * @param gradient defines the gradient to remove
  53265. * @returns the current particle system
  53266. */
  53267. removeEmitRateGradient(gradient: number): IParticleSystem;
  53268. /**
  53269. * Not supported by GPUParticleSystem
  53270. * @param gradient defines the gradient to use (between 0 and 1)
  53271. * @param factor defines the start size value to affect to the specified gradient
  53272. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  53273. * @returns the current particle system
  53274. */
  53275. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  53276. /**
  53277. * Not supported by GPUParticleSystem
  53278. * @param gradient defines the gradient to remove
  53279. * @returns the current particle system
  53280. */
  53281. removeStartSizeGradient(gradient: number): IParticleSystem;
  53282. /**
  53283. * Not supported by GPUParticleSystem
  53284. * @param gradient defines the gradient to use (between 0 and 1)
  53285. * @param min defines the color remap minimal range
  53286. * @param max defines the color remap maximal range
  53287. * @returns the current particle system
  53288. */
  53289. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  53290. /**
  53291. * Not supported by GPUParticleSystem
  53292. * @param gradient defines the gradient to remove
  53293. * @returns the current particle system
  53294. */
  53295. removeColorRemapGradient(): IParticleSystem;
  53296. /**
  53297. * Not supported by GPUParticleSystem
  53298. * @param gradient defines the gradient to use (between 0 and 1)
  53299. * @param min defines the alpha remap minimal range
  53300. * @param max defines the alpha remap maximal range
  53301. * @returns the current particle system
  53302. */
  53303. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  53304. /**
  53305. * Not supported by GPUParticleSystem
  53306. * @param gradient defines the gradient to remove
  53307. * @returns the current particle system
  53308. */
  53309. removeAlphaRemapGradient(): IParticleSystem;
  53310. /**
  53311. * Not supported by GPUParticleSystem
  53312. * @param gradient defines the gradient to use (between 0 and 1)
  53313. * @param color defines the color to affect to the specified gradient
  53314. * @returns the current particle system
  53315. */
  53316. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  53317. /**
  53318. * Not supported by GPUParticleSystem
  53319. * @param gradient defines the gradient to remove
  53320. * @returns the current particle system
  53321. */
  53322. removeRampGradient(): IParticleSystem;
  53323. /**
  53324. * Not supported by GPUParticleSystem
  53325. * @returns the list of ramp gradients
  53326. */
  53327. getRampGradients(): Nullable<Array<Color3Gradient>>;
  53328. /**
  53329. * Not supported by GPUParticleSystem
  53330. * Gets or sets a boolean indicating that ramp gradients must be used
  53331. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  53332. */
  53333. useRampGradients: boolean;
  53334. /**
  53335. * Not supported by GPUParticleSystem
  53336. * @param gradient defines the gradient to use (between 0 and 1)
  53337. * @param factor defines the life time factor to affect to the specified gradient
  53338. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  53339. * @returns the current particle system
  53340. */
  53341. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  53342. /**
  53343. * Not supported by GPUParticleSystem
  53344. * @param gradient defines the gradient to remove
  53345. * @returns the current particle system
  53346. */
  53347. removeLifeTimeGradient(gradient: number): IParticleSystem;
  53348. /**
  53349. * Instantiates a GPU particle system.
  53350. * 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.
  53351. * @param name The name of the particle system
  53352. * @param options The options used to create the system
  53353. * @param scene The scene the particle system belongs to
  53354. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  53355. */
  53356. constructor(name: string, options: Partial<{
  53357. capacity: number;
  53358. randomTextureSize: number;
  53359. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  53360. protected _reset(): void;
  53361. private _createUpdateVAO;
  53362. private _createRenderVAO;
  53363. private _initialize;
  53364. /** @hidden */
  53365. _recreateUpdateEffect(): void;
  53366. /** @hidden */
  53367. _recreateRenderEffect(): void;
  53368. /**
  53369. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  53370. * @param preWarm defines if we are in the pre-warmimg phase
  53371. */
  53372. animate(preWarm?: boolean): void;
  53373. private _createFactorGradientTexture;
  53374. private _createSizeGradientTexture;
  53375. private _createAngularSpeedGradientTexture;
  53376. private _createVelocityGradientTexture;
  53377. private _createLimitVelocityGradientTexture;
  53378. private _createDragGradientTexture;
  53379. private _createColorGradientTexture;
  53380. /**
  53381. * Renders the particle system in its current state
  53382. * @param preWarm defines if the system should only update the particles but not render them
  53383. * @returns the current number of particles
  53384. */
  53385. render(preWarm?: boolean): number;
  53386. /**
  53387. * Rebuilds the particle system
  53388. */
  53389. rebuild(): void;
  53390. private _releaseBuffers;
  53391. private _releaseVAOs;
  53392. /**
  53393. * Disposes the particle system and free the associated resources
  53394. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  53395. */
  53396. dispose(disposeTexture?: boolean): void;
  53397. /**
  53398. * Clones the particle system.
  53399. * @param name The name of the cloned object
  53400. * @param newEmitter The new emitter to use
  53401. * @returns the cloned particle system
  53402. */
  53403. clone(name: string, newEmitter: any): GPUParticleSystem;
  53404. /**
  53405. * Serializes the particle system to a JSON object.
  53406. * @returns the JSON object
  53407. */
  53408. serialize(): any;
  53409. /**
  53410. * Parses a JSON object to create a GPU particle system.
  53411. * @param parsedParticleSystem The JSON object to parse
  53412. * @param scene The scene to create the particle system in
  53413. * @param rootUrl The root url to use to load external dependencies like texture
  53414. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  53415. * @returns the parsed GPU particle system
  53416. */
  53417. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  53418. }
  53419. }
  53420. declare module "babylonjs/Particles/particleSystemSet" {
  53421. import { Nullable } from "babylonjs/types";
  53422. import { Color3 } from "babylonjs/Maths/math";
  53423. import { TransformNode } from "babylonjs/Meshes/transformNode";
  53424. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53425. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  53426. import { Scene, IDisposable } from "babylonjs/scene";
  53427. /**
  53428. * Represents a set of particle systems working together to create a specific effect
  53429. */
  53430. export class ParticleSystemSet implements IDisposable {
  53431. private _emitterCreationOptions;
  53432. private _emitterNode;
  53433. /**
  53434. * Gets the particle system list
  53435. */
  53436. systems: IParticleSystem[];
  53437. /**
  53438. * Gets the emitter node used with this set
  53439. */
  53440. readonly emitterNode: Nullable<TransformNode>;
  53441. /**
  53442. * Creates a new emitter mesh as a sphere
  53443. * @param options defines the options used to create the sphere
  53444. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  53445. * @param scene defines the hosting scene
  53446. */
  53447. setEmitterAsSphere(options: {
  53448. diameter: number;
  53449. segments: number;
  53450. color: Color3;
  53451. }, renderingGroupId: number, scene: Scene): void;
  53452. /**
  53453. * Starts all particle systems of the set
  53454. * @param emitter defines an optional mesh to use as emitter for the particle systems
  53455. */
  53456. start(emitter?: AbstractMesh): void;
  53457. /**
  53458. * Release all associated resources
  53459. */
  53460. dispose(): void;
  53461. /**
  53462. * Serialize the set into a JSON compatible object
  53463. * @returns a JSON compatible representation of the set
  53464. */
  53465. serialize(): any;
  53466. /**
  53467. * Parse a new ParticleSystemSet from a serialized source
  53468. * @param data defines a JSON compatible representation of the set
  53469. * @param scene defines the hosting scene
  53470. * @param gpu defines if we want GPU particles or CPU particles
  53471. * @returns a new ParticleSystemSet
  53472. */
  53473. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  53474. }
  53475. }
  53476. declare module "babylonjs/Particles/particleHelper" {
  53477. import { Nullable } from "babylonjs/types";
  53478. import { Scene } from "babylonjs/scene";
  53479. import { Vector3 } from "babylonjs/Maths/math";
  53480. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53481. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  53482. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  53483. /**
  53484. * This class is made for on one-liner static method to help creating particle system set.
  53485. */
  53486. export class ParticleHelper {
  53487. /**
  53488. * Gets or sets base Assets URL
  53489. */
  53490. static BaseAssetsUrl: string;
  53491. /**
  53492. * Create a default particle system that you can tweak
  53493. * @param emitter defines the emitter to use
  53494. * @param capacity defines the system capacity (default is 500 particles)
  53495. * @param scene defines the hosting scene
  53496. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  53497. * @returns the new Particle system
  53498. */
  53499. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  53500. /**
  53501. * This is the main static method (one-liner) of this helper to create different particle systems
  53502. * @param type This string represents the type to the particle system to create
  53503. * @param scene The scene where the particle system should live
  53504. * @param gpu If the system will use gpu
  53505. * @returns the ParticleSystemSet created
  53506. */
  53507. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  53508. /**
  53509. * Static function used to export a particle system to a ParticleSystemSet variable.
  53510. * Please note that the emitter shape is not exported
  53511. * @param systems defines the particle systems to export
  53512. * @returns the created particle system set
  53513. */
  53514. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  53515. }
  53516. }
  53517. declare module "babylonjs/Particles/particleSystemComponent" {
  53518. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  53519. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  53520. import "babylonjs/Shaders/particles.vertex";
  53521. module "babylonjs/Engines/engine" {
  53522. interface Engine {
  53523. /**
  53524. * Create an effect to use with particle systems.
  53525. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  53526. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  53527. * @param uniformsNames defines a list of attribute names
  53528. * @param samplers defines an array of string used to represent textures
  53529. * @param defines defines the string containing the defines to use to compile the shaders
  53530. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  53531. * @param onCompiled defines a function to call when the effect creation is successful
  53532. * @param onError defines a function to call when the effect creation has failed
  53533. * @returns the new Effect
  53534. */
  53535. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  53536. }
  53537. }
  53538. module "babylonjs/Meshes/mesh" {
  53539. interface Mesh {
  53540. /**
  53541. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  53542. * @returns an array of IParticleSystem
  53543. */
  53544. getEmittedParticleSystems(): IParticleSystem[];
  53545. /**
  53546. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  53547. * @returns an array of IParticleSystem
  53548. */
  53549. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  53550. }
  53551. }
  53552. /**
  53553. * @hidden
  53554. */
  53555. export var _IDoNeedToBeInTheBuild: number;
  53556. }
  53557. declare module "babylonjs/Particles/index" {
  53558. export * from "babylonjs/Particles/baseParticleSystem";
  53559. export * from "babylonjs/Particles/EmitterTypes/index";
  53560. export * from "babylonjs/Particles/gpuParticleSystem";
  53561. export * from "babylonjs/Particles/IParticleSystem";
  53562. export * from "babylonjs/Particles/particle";
  53563. export * from "babylonjs/Particles/particleHelper";
  53564. export * from "babylonjs/Particles/particleSystem";
  53565. export * from "babylonjs/Particles/particleSystemComponent";
  53566. export * from "babylonjs/Particles/particleSystemSet";
  53567. export * from "babylonjs/Particles/solidParticle";
  53568. export * from "babylonjs/Particles/solidParticleSystem";
  53569. export * from "babylonjs/Particles/subEmitter";
  53570. }
  53571. declare module "babylonjs/Physics/physicsEngineComponent" {
  53572. import { Nullable } from "babylonjs/types";
  53573. import { Observable, Observer } from "babylonjs/Misc/observable";
  53574. import { Vector3 } from "babylonjs/Maths/math";
  53575. import { Mesh } from "babylonjs/Meshes/mesh";
  53576. import { ISceneComponent } from "babylonjs/sceneComponent";
  53577. import { Scene } from "babylonjs/scene";
  53578. import { Node } from "babylonjs/node";
  53579. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  53580. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  53581. module "babylonjs/scene" {
  53582. interface Scene {
  53583. /** @hidden (Backing field) */
  53584. _physicsEngine: Nullable<IPhysicsEngine>;
  53585. /**
  53586. * Gets the current physics engine
  53587. * @returns a IPhysicsEngine or null if none attached
  53588. */
  53589. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  53590. /**
  53591. * Enables physics to the current scene
  53592. * @param gravity defines the scene's gravity for the physics engine
  53593. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  53594. * @return a boolean indicating if the physics engine was initialized
  53595. */
  53596. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  53597. /**
  53598. * Disables and disposes the physics engine associated with the scene
  53599. */
  53600. disablePhysicsEngine(): void;
  53601. /**
  53602. * Gets a boolean indicating if there is an active physics engine
  53603. * @returns a boolean indicating if there is an active physics engine
  53604. */
  53605. isPhysicsEnabled(): boolean;
  53606. /**
  53607. * Deletes a physics compound impostor
  53608. * @param compound defines the compound to delete
  53609. */
  53610. deleteCompoundImpostor(compound: any): void;
  53611. /**
  53612. * An event triggered when physic simulation is about to be run
  53613. */
  53614. onBeforePhysicsObservable: Observable<Scene>;
  53615. /**
  53616. * An event triggered when physic simulation has been done
  53617. */
  53618. onAfterPhysicsObservable: Observable<Scene>;
  53619. }
  53620. }
  53621. module "babylonjs/Meshes/abstractMesh" {
  53622. interface AbstractMesh {
  53623. /** @hidden */
  53624. _physicsImpostor: Nullable<PhysicsImpostor>;
  53625. /**
  53626. * Gets or sets impostor used for physic simulation
  53627. * @see http://doc.babylonjs.com/features/physics_engine
  53628. */
  53629. physicsImpostor: Nullable<PhysicsImpostor>;
  53630. /**
  53631. * Gets the current physics impostor
  53632. * @see http://doc.babylonjs.com/features/physics_engine
  53633. * @returns a physics impostor or null
  53634. */
  53635. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  53636. /** Apply a physic impulse to the mesh
  53637. * @param force defines the force to apply
  53638. * @param contactPoint defines where to apply the force
  53639. * @returns the current mesh
  53640. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  53641. */
  53642. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  53643. /**
  53644. * Creates a physic joint between two meshes
  53645. * @param otherMesh defines the other mesh to use
  53646. * @param pivot1 defines the pivot to use on this mesh
  53647. * @param pivot2 defines the pivot to use on the other mesh
  53648. * @param options defines additional options (can be plugin dependent)
  53649. * @returns the current mesh
  53650. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  53651. */
  53652. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  53653. /** @hidden */
  53654. _disposePhysicsObserver: Nullable<Observer<Node>>;
  53655. }
  53656. }
  53657. /**
  53658. * Defines the physics engine scene component responsible to manage a physics engine
  53659. */
  53660. export class PhysicsEngineSceneComponent implements ISceneComponent {
  53661. /**
  53662. * The component name helpful to identify the component in the list of scene components.
  53663. */
  53664. readonly name: string;
  53665. /**
  53666. * The scene the component belongs to.
  53667. */
  53668. scene: Scene;
  53669. /**
  53670. * Creates a new instance of the component for the given scene
  53671. * @param scene Defines the scene to register the component in
  53672. */
  53673. constructor(scene: Scene);
  53674. /**
  53675. * Registers the component in a given scene
  53676. */
  53677. register(): void;
  53678. /**
  53679. * Rebuilds the elements related to this component in case of
  53680. * context lost for instance.
  53681. */
  53682. rebuild(): void;
  53683. /**
  53684. * Disposes the component and the associated ressources
  53685. */
  53686. dispose(): void;
  53687. }
  53688. }
  53689. declare module "babylonjs/Physics/physicsHelper" {
  53690. import { Nullable } from "babylonjs/types";
  53691. import { Vector3 } from "babylonjs/Maths/math";
  53692. import { Mesh } from "babylonjs/Meshes/mesh";
  53693. import { Scene } from "babylonjs/scene";
  53694. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  53695. /**
  53696. * A helper for physics simulations
  53697. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  53698. */
  53699. export class PhysicsHelper {
  53700. private _scene;
  53701. private _physicsEngine;
  53702. /**
  53703. * Initializes the Physics helper
  53704. * @param scene Babylon.js scene
  53705. */
  53706. constructor(scene: Scene);
  53707. /**
  53708. * Applies a radial explosion impulse
  53709. * @param origin the origin of the explosion
  53710. * @param radiusOrEventOptions the radius or the options of radial explosion
  53711. * @param strength the explosion strength
  53712. * @param falloff possible options: Constant & Linear. Defaults to Constant
  53713. * @returns A physics radial explosion event, or null
  53714. */
  53715. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  53716. /**
  53717. * Applies a radial explosion force
  53718. * @param origin the origin of the explosion
  53719. * @param radiusOrEventOptions the radius or the options of radial explosion
  53720. * @param strength the explosion strength
  53721. * @param falloff possible options: Constant & Linear. Defaults to Constant
  53722. * @returns A physics radial explosion event, or null
  53723. */
  53724. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  53725. /**
  53726. * Creates a gravitational field
  53727. * @param origin the origin of the explosion
  53728. * @param radiusOrEventOptions the radius or the options of radial explosion
  53729. * @param strength the explosion strength
  53730. * @param falloff possible options: Constant & Linear. Defaults to Constant
  53731. * @returns A physics gravitational field event, or null
  53732. */
  53733. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  53734. /**
  53735. * Creates a physics updraft event
  53736. * @param origin the origin of the updraft
  53737. * @param radiusOrEventOptions the radius or the options of the updraft
  53738. * @param strength the strength of the updraft
  53739. * @param height the height of the updraft
  53740. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  53741. * @returns A physics updraft event, or null
  53742. */
  53743. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  53744. /**
  53745. * Creates a physics vortex event
  53746. * @param origin the of the vortex
  53747. * @param radiusOrEventOptions the radius or the options of the vortex
  53748. * @param strength the strength of the vortex
  53749. * @param height the height of the vortex
  53750. * @returns a Physics vortex event, or null
  53751. * A physics vortex event or null
  53752. */
  53753. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  53754. }
  53755. /**
  53756. * Represents a physics radial explosion event
  53757. */
  53758. class PhysicsRadialExplosionEvent {
  53759. private _scene;
  53760. private _options;
  53761. private _sphere;
  53762. private _dataFetched;
  53763. /**
  53764. * Initializes a radial explosioin event
  53765. * @param _scene BabylonJS scene
  53766. * @param _options The options for the vortex event
  53767. */
  53768. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  53769. /**
  53770. * Returns the data related to the radial explosion event (sphere).
  53771. * @returns The radial explosion event data
  53772. */
  53773. getData(): PhysicsRadialExplosionEventData;
  53774. /**
  53775. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  53776. * @param impostor A physics imposter
  53777. * @param origin the origin of the explosion
  53778. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  53779. */
  53780. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  53781. /**
  53782. * Triggers affecterd impostors callbacks
  53783. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  53784. */
  53785. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  53786. /**
  53787. * Disposes the sphere.
  53788. * @param force Specifies if the sphere should be disposed by force
  53789. */
  53790. dispose(force?: boolean): void;
  53791. /*** Helpers ***/
  53792. private _prepareSphere;
  53793. private _intersectsWithSphere;
  53794. }
  53795. /**
  53796. * Represents a gravitational field event
  53797. */
  53798. class PhysicsGravitationalFieldEvent {
  53799. private _physicsHelper;
  53800. private _scene;
  53801. private _origin;
  53802. private _options;
  53803. private _tickCallback;
  53804. private _sphere;
  53805. private _dataFetched;
  53806. /**
  53807. * Initializes the physics gravitational field event
  53808. * @param _physicsHelper A physics helper
  53809. * @param _scene BabylonJS scene
  53810. * @param _origin The origin position of the gravitational field event
  53811. * @param _options The options for the vortex event
  53812. */
  53813. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  53814. /**
  53815. * Returns the data related to the gravitational field event (sphere).
  53816. * @returns A gravitational field event
  53817. */
  53818. getData(): PhysicsGravitationalFieldEventData;
  53819. /**
  53820. * Enables the gravitational field.
  53821. */
  53822. enable(): void;
  53823. /**
  53824. * Disables the gravitational field.
  53825. */
  53826. disable(): void;
  53827. /**
  53828. * Disposes the sphere.
  53829. * @param force The force to dispose from the gravitational field event
  53830. */
  53831. dispose(force?: boolean): void;
  53832. private _tick;
  53833. }
  53834. /**
  53835. * Represents a physics updraft event
  53836. */
  53837. class PhysicsUpdraftEvent {
  53838. private _scene;
  53839. private _origin;
  53840. private _options;
  53841. private _physicsEngine;
  53842. private _originTop;
  53843. private _originDirection;
  53844. private _tickCallback;
  53845. private _cylinder;
  53846. private _cylinderPosition;
  53847. private _dataFetched;
  53848. /**
  53849. * Initializes the physics updraft event
  53850. * @param _scene BabylonJS scene
  53851. * @param _origin The origin position of the updraft
  53852. * @param _options The options for the updraft event
  53853. */
  53854. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  53855. /**
  53856. * Returns the data related to the updraft event (cylinder).
  53857. * @returns A physics updraft event
  53858. */
  53859. getData(): PhysicsUpdraftEventData;
  53860. /**
  53861. * Enables the updraft.
  53862. */
  53863. enable(): void;
  53864. /**
  53865. * Disables the updraft.
  53866. */
  53867. disable(): void;
  53868. /**
  53869. * Disposes the cylinder.
  53870. * @param force Specifies if the updraft should be disposed by force
  53871. */
  53872. dispose(force?: boolean): void;
  53873. private getImpostorHitData;
  53874. private _tick;
  53875. /*** Helpers ***/
  53876. private _prepareCylinder;
  53877. private _intersectsWithCylinder;
  53878. }
  53879. /**
  53880. * Represents a physics vortex event
  53881. */
  53882. class PhysicsVortexEvent {
  53883. private _scene;
  53884. private _origin;
  53885. private _options;
  53886. private _physicsEngine;
  53887. private _originTop;
  53888. private _tickCallback;
  53889. private _cylinder;
  53890. private _cylinderPosition;
  53891. private _dataFetched;
  53892. /**
  53893. * Initializes the physics vortex event
  53894. * @param _scene The BabylonJS scene
  53895. * @param _origin The origin position of the vortex
  53896. * @param _options The options for the vortex event
  53897. */
  53898. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  53899. /**
  53900. * Returns the data related to the vortex event (cylinder).
  53901. * @returns The physics vortex event data
  53902. */
  53903. getData(): PhysicsVortexEventData;
  53904. /**
  53905. * Enables the vortex.
  53906. */
  53907. enable(): void;
  53908. /**
  53909. * Disables the cortex.
  53910. */
  53911. disable(): void;
  53912. /**
  53913. * Disposes the sphere.
  53914. * @param force
  53915. */
  53916. dispose(force?: boolean): void;
  53917. private getImpostorHitData;
  53918. private _tick;
  53919. /*** Helpers ***/
  53920. private _prepareCylinder;
  53921. private _intersectsWithCylinder;
  53922. }
  53923. /**
  53924. * Options fot the radial explosion event
  53925. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  53926. */
  53927. export class PhysicsRadialExplosionEventOptions {
  53928. /**
  53929. * The radius of the sphere for the radial explosion.
  53930. */
  53931. radius: number;
  53932. /**
  53933. * The strenth of the explosion.
  53934. */
  53935. strength: number;
  53936. /**
  53937. * The strenght of the force in correspondence to the distance of the affected object
  53938. */
  53939. falloff: PhysicsRadialImpulseFalloff;
  53940. /**
  53941. * Sphere options for the radial explosion.
  53942. */
  53943. sphere: {
  53944. segments: number;
  53945. diameter: number;
  53946. };
  53947. /**
  53948. * Sphere options for the radial explosion.
  53949. */
  53950. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  53951. }
  53952. /**
  53953. * Options fot the updraft event
  53954. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  53955. */
  53956. export class PhysicsUpdraftEventOptions {
  53957. /**
  53958. * The radius of the cylinder for the vortex
  53959. */
  53960. radius: number;
  53961. /**
  53962. * The strenth of the updraft.
  53963. */
  53964. strength: number;
  53965. /**
  53966. * The height of the cylinder for the updraft.
  53967. */
  53968. height: number;
  53969. /**
  53970. * The mode for the the updraft.
  53971. */
  53972. updraftMode: PhysicsUpdraftMode;
  53973. }
  53974. /**
  53975. * Options fot the vortex event
  53976. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  53977. */
  53978. export class PhysicsVortexEventOptions {
  53979. /**
  53980. * The radius of the cylinder for the vortex
  53981. */
  53982. radius: number;
  53983. /**
  53984. * The strenth of the vortex.
  53985. */
  53986. strength: number;
  53987. /**
  53988. * The height of the cylinder for the vortex.
  53989. */
  53990. height: number;
  53991. /**
  53992. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  53993. */
  53994. centripetalForceThreshold: number;
  53995. /**
  53996. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  53997. */
  53998. centripetalForceMultiplier: number;
  53999. /**
  54000. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  54001. */
  54002. centrifugalForceMultiplier: number;
  54003. /**
  54004. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  54005. */
  54006. updraftForceMultiplier: number;
  54007. }
  54008. /**
  54009. * The strenght of the force in correspondence to the distance of the affected object
  54010. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54011. */
  54012. export enum PhysicsRadialImpulseFalloff {
  54013. /** Defines that impulse is constant in strength across it's whole radius */
  54014. Constant = 0,
  54015. /** Defines that impulse gets weaker if it's further from the origin */
  54016. Linear = 1
  54017. }
  54018. /**
  54019. * The strength of the force in correspondence to the distance of the affected object
  54020. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54021. */
  54022. export enum PhysicsUpdraftMode {
  54023. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  54024. Center = 0,
  54025. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  54026. Perpendicular = 1
  54027. }
  54028. /**
  54029. * Interface for a physics hit data
  54030. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54031. */
  54032. export interface PhysicsHitData {
  54033. /**
  54034. * The force applied at the contact point
  54035. */
  54036. force: Vector3;
  54037. /**
  54038. * The contact point
  54039. */
  54040. contactPoint: Vector3;
  54041. /**
  54042. * The distance from the origin to the contact point
  54043. */
  54044. distanceFromOrigin: number;
  54045. }
  54046. /**
  54047. * Interface for radial explosion event data
  54048. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54049. */
  54050. export interface PhysicsRadialExplosionEventData {
  54051. /**
  54052. * A sphere used for the radial explosion event
  54053. */
  54054. sphere: Mesh;
  54055. }
  54056. /**
  54057. * Interface for gravitational field event data
  54058. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54059. */
  54060. export interface PhysicsGravitationalFieldEventData {
  54061. /**
  54062. * A sphere mesh used for the gravitational field event
  54063. */
  54064. sphere: Mesh;
  54065. }
  54066. /**
  54067. * Interface for updraft event data
  54068. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54069. */
  54070. export interface PhysicsUpdraftEventData {
  54071. /**
  54072. * A cylinder used for the updraft event
  54073. */
  54074. cylinder: Mesh;
  54075. }
  54076. /**
  54077. * Interface for vortex event data
  54078. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54079. */
  54080. export interface PhysicsVortexEventData {
  54081. /**
  54082. * A cylinder used for the vortex event
  54083. */
  54084. cylinder: Mesh;
  54085. }
  54086. /**
  54087. * Interface for an affected physics impostor
  54088. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54089. */
  54090. export interface PhysicsAffectedImpostorWithData {
  54091. /**
  54092. * The impostor affected by the effect
  54093. */
  54094. impostor: PhysicsImpostor;
  54095. /**
  54096. * The data about the hit/horce from the explosion
  54097. */
  54098. hitData: PhysicsHitData;
  54099. }
  54100. }
  54101. declare module "babylonjs/Physics/Plugins/index" {
  54102. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  54103. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  54104. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  54105. }
  54106. declare module "babylonjs/Physics/index" {
  54107. export * from "babylonjs/Physics/IPhysicsEngine";
  54108. export * from "babylonjs/Physics/physicsEngine";
  54109. export * from "babylonjs/Physics/physicsEngineComponent";
  54110. export * from "babylonjs/Physics/physicsHelper";
  54111. export * from "babylonjs/Physics/physicsImpostor";
  54112. export * from "babylonjs/Physics/physicsJoint";
  54113. export * from "babylonjs/Physics/Plugins/index";
  54114. }
  54115. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  54116. /** @hidden */
  54117. export var blackAndWhitePixelShader: {
  54118. name: string;
  54119. shader: string;
  54120. };
  54121. }
  54122. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  54123. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54124. import { Camera } from "babylonjs/Cameras/camera";
  54125. import { Engine } from "babylonjs/Engines/engine";
  54126. import "babylonjs/Shaders/blackAndWhite.fragment";
  54127. /**
  54128. * Post process used to render in black and white
  54129. */
  54130. export class BlackAndWhitePostProcess extends PostProcess {
  54131. /**
  54132. * Linear about to convert he result to black and white (default: 1)
  54133. */
  54134. degree: number;
  54135. /**
  54136. * Creates a black and white post process
  54137. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  54138. * @param name The name of the effect.
  54139. * @param options The required width/height ratio to downsize to before computing the render pass.
  54140. * @param camera The camera to apply the render pass to.
  54141. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54142. * @param engine The engine which the post process will be applied. (default: current engine)
  54143. * @param reusable If the post process can be reused on the same frame. (default: false)
  54144. */
  54145. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  54146. }
  54147. }
  54148. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  54149. import { Nullable } from "babylonjs/types";
  54150. import { Camera } from "babylonjs/Cameras/camera";
  54151. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  54152. import { Engine } from "babylonjs/Engines/engine";
  54153. /**
  54154. * This represents a set of one or more post processes in Babylon.
  54155. * A post process can be used to apply a shader to a texture after it is rendered.
  54156. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  54157. */
  54158. export class PostProcessRenderEffect {
  54159. private _postProcesses;
  54160. private _getPostProcesses;
  54161. private _singleInstance;
  54162. private _cameras;
  54163. private _indicesForCamera;
  54164. /**
  54165. * Name of the effect
  54166. * @hidden
  54167. */
  54168. _name: string;
  54169. /**
  54170. * Instantiates a post process render effect.
  54171. * A post process can be used to apply a shader to a texture after it is rendered.
  54172. * @param engine The engine the effect is tied to
  54173. * @param name The name of the effect
  54174. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  54175. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  54176. */
  54177. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  54178. /**
  54179. * Checks if all the post processes in the effect are supported.
  54180. */
  54181. readonly isSupported: boolean;
  54182. /**
  54183. * Updates the current state of the effect
  54184. * @hidden
  54185. */
  54186. _update(): void;
  54187. /**
  54188. * Attaches the effect on cameras
  54189. * @param cameras The camera to attach to.
  54190. * @hidden
  54191. */
  54192. _attachCameras(cameras: Camera): void;
  54193. /**
  54194. * Attaches the effect on cameras
  54195. * @param cameras The camera to attach to.
  54196. * @hidden
  54197. */
  54198. _attachCameras(cameras: Camera[]): void;
  54199. /**
  54200. * Detatches the effect on cameras
  54201. * @param cameras The camera to detatch from.
  54202. * @hidden
  54203. */
  54204. _detachCameras(cameras: Camera): void;
  54205. /**
  54206. * Detatches the effect on cameras
  54207. * @param cameras The camera to detatch from.
  54208. * @hidden
  54209. */
  54210. _detachCameras(cameras: Camera[]): void;
  54211. /**
  54212. * Enables the effect on given cameras
  54213. * @param cameras The camera to enable.
  54214. * @hidden
  54215. */
  54216. _enable(cameras: Camera): void;
  54217. /**
  54218. * Enables the effect on given cameras
  54219. * @param cameras The camera to enable.
  54220. * @hidden
  54221. */
  54222. _enable(cameras: Nullable<Camera[]>): void;
  54223. /**
  54224. * Disables the effect on the given cameras
  54225. * @param cameras The camera to disable.
  54226. * @hidden
  54227. */
  54228. _disable(cameras: Camera): void;
  54229. /**
  54230. * Disables the effect on the given cameras
  54231. * @param cameras The camera to disable.
  54232. * @hidden
  54233. */
  54234. _disable(cameras: Nullable<Camera[]>): void;
  54235. /**
  54236. * Gets a list of the post processes contained in the effect.
  54237. * @param camera The camera to get the post processes on.
  54238. * @returns The list of the post processes in the effect.
  54239. */
  54240. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  54241. }
  54242. }
  54243. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  54244. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  54245. /** @hidden */
  54246. export var extractHighlightsPixelShader: {
  54247. name: string;
  54248. shader: string;
  54249. };
  54250. }
  54251. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  54252. import { Nullable } from "babylonjs/types";
  54253. import { Camera } from "babylonjs/Cameras/camera";
  54254. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54255. import { Engine } from "babylonjs/Engines/engine";
  54256. import "babylonjs/Shaders/extractHighlights.fragment";
  54257. /**
  54258. * 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.
  54259. */
  54260. export class ExtractHighlightsPostProcess extends PostProcess {
  54261. /**
  54262. * The luminance threshold, pixels below this value will be set to black.
  54263. */
  54264. threshold: number;
  54265. /** @hidden */
  54266. _exposure: number;
  54267. /**
  54268. * Post process which has the input texture to be used when performing highlight extraction
  54269. * @hidden
  54270. */
  54271. _inputPostProcess: Nullable<PostProcess>;
  54272. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  54273. }
  54274. }
  54275. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  54276. /** @hidden */
  54277. export var bloomMergePixelShader: {
  54278. name: string;
  54279. shader: string;
  54280. };
  54281. }
  54282. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  54283. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54284. import { Nullable } from "babylonjs/types";
  54285. import { Engine } from "babylonjs/Engines/engine";
  54286. import { Camera } from "babylonjs/Cameras/camera";
  54287. import "babylonjs/Shaders/bloomMerge.fragment";
  54288. /**
  54289. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  54290. */
  54291. export class BloomMergePostProcess extends PostProcess {
  54292. /** Weight of the bloom to be added to the original input. */
  54293. weight: number;
  54294. /**
  54295. * Creates a new instance of @see BloomMergePostProcess
  54296. * @param name The name of the effect.
  54297. * @param originalFromInput Post process which's input will be used for the merge.
  54298. * @param blurred Blurred highlights post process which's output will be used.
  54299. * @param weight Weight of the bloom to be added to the original input.
  54300. * @param options The required width/height ratio to downsize to before computing the render pass.
  54301. * @param camera The camera to apply the render pass to.
  54302. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54303. * @param engine The engine which the post process will be applied. (default: current engine)
  54304. * @param reusable If the post process can be reused on the same frame. (default: false)
  54305. * @param textureType Type of textures used when performing the post process. (default: 0)
  54306. * @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)
  54307. */
  54308. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  54309. /** Weight of the bloom to be added to the original input. */
  54310. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  54311. }
  54312. }
  54313. declare module "babylonjs/PostProcesses/bloomEffect" {
  54314. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  54315. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  54316. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  54317. import { Camera } from "babylonjs/Cameras/camera";
  54318. import { Scene } from "babylonjs/scene";
  54319. /**
  54320. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  54321. */
  54322. export class BloomEffect extends PostProcessRenderEffect {
  54323. private bloomScale;
  54324. /**
  54325. * @hidden Internal
  54326. */
  54327. _effects: Array<PostProcess>;
  54328. /**
  54329. * @hidden Internal
  54330. */
  54331. _downscale: ExtractHighlightsPostProcess;
  54332. private _blurX;
  54333. private _blurY;
  54334. private _merge;
  54335. /**
  54336. * The luminance threshold to find bright areas of the image to bloom.
  54337. */
  54338. threshold: number;
  54339. /**
  54340. * The strength of the bloom.
  54341. */
  54342. weight: number;
  54343. /**
  54344. * Specifies the size of the bloom blur kernel, relative to the final output size
  54345. */
  54346. kernel: number;
  54347. /**
  54348. * Creates a new instance of @see BloomEffect
  54349. * @param scene The scene the effect belongs to.
  54350. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  54351. * @param bloomKernel The size of the kernel to be used when applying the blur.
  54352. * @param bloomWeight The the strength of bloom.
  54353. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  54354. * @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)
  54355. */
  54356. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  54357. /**
  54358. * Disposes each of the internal effects for a given camera.
  54359. * @param camera The camera to dispose the effect on.
  54360. */
  54361. disposeEffects(camera: Camera): void;
  54362. /**
  54363. * @hidden Internal
  54364. */
  54365. _updateEffects(): void;
  54366. /**
  54367. * Internal
  54368. * @returns if all the contained post processes are ready.
  54369. * @hidden
  54370. */
  54371. _isReady(): boolean;
  54372. }
  54373. }
  54374. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  54375. /** @hidden */
  54376. export var chromaticAberrationPixelShader: {
  54377. name: string;
  54378. shader: string;
  54379. };
  54380. }
  54381. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  54382. import { Vector2 } from "babylonjs/Maths/math";
  54383. import { Nullable } from "babylonjs/types";
  54384. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54385. import { Camera } from "babylonjs/Cameras/camera";
  54386. import { Engine } from "babylonjs/Engines/engine";
  54387. import "babylonjs/Shaders/chromaticAberration.fragment";
  54388. /**
  54389. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  54390. */
  54391. export class ChromaticAberrationPostProcess extends PostProcess {
  54392. /**
  54393. * The amount of seperation of rgb channels (default: 30)
  54394. */
  54395. aberrationAmount: number;
  54396. /**
  54397. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  54398. */
  54399. radialIntensity: number;
  54400. /**
  54401. * 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))
  54402. */
  54403. direction: Vector2;
  54404. /**
  54405. * 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))
  54406. */
  54407. centerPosition: Vector2;
  54408. /**
  54409. * Creates a new instance ChromaticAberrationPostProcess
  54410. * @param name The name of the effect.
  54411. * @param screenWidth The width of the screen to apply the effect on.
  54412. * @param screenHeight The height of the screen to apply the effect on.
  54413. * @param options The required width/height ratio to downsize to before computing the render pass.
  54414. * @param camera The camera to apply the render pass to.
  54415. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54416. * @param engine The engine which the post process will be applied. (default: current engine)
  54417. * @param reusable If the post process can be reused on the same frame. (default: false)
  54418. * @param textureType Type of textures used when performing the post process. (default: 0)
  54419. * @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)
  54420. */
  54421. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  54422. }
  54423. }
  54424. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  54425. /** @hidden */
  54426. export var circleOfConfusionPixelShader: {
  54427. name: string;
  54428. shader: string;
  54429. };
  54430. }
  54431. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  54432. import { Nullable } from "babylonjs/types";
  54433. import { Engine } from "babylonjs/Engines/engine";
  54434. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54435. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  54436. import { Camera } from "babylonjs/Cameras/camera";
  54437. import "babylonjs/Shaders/circleOfConfusion.fragment";
  54438. /**
  54439. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  54440. */
  54441. export class CircleOfConfusionPostProcess extends PostProcess {
  54442. /**
  54443. * 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.
  54444. */
  54445. lensSize: number;
  54446. /**
  54447. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  54448. */
  54449. fStop: number;
  54450. /**
  54451. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  54452. */
  54453. focusDistance: number;
  54454. /**
  54455. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  54456. */
  54457. focalLength: number;
  54458. private _depthTexture;
  54459. /**
  54460. * Creates a new instance CircleOfConfusionPostProcess
  54461. * @param name The name of the effect.
  54462. * @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.
  54463. * @param options The required width/height ratio to downsize to before computing the render pass.
  54464. * @param camera The camera to apply the render pass to.
  54465. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54466. * @param engine The engine which the post process will be applied. (default: current engine)
  54467. * @param reusable If the post process can be reused on the same frame. (default: false)
  54468. * @param textureType Type of textures used when performing the post process. (default: 0)
  54469. * @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)
  54470. */
  54471. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  54472. /**
  54473. * 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.
  54474. */
  54475. depthTexture: RenderTargetTexture;
  54476. }
  54477. }
  54478. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  54479. /** @hidden */
  54480. export var colorCorrectionPixelShader: {
  54481. name: string;
  54482. shader: string;
  54483. };
  54484. }
  54485. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  54486. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54487. import { Engine } from "babylonjs/Engines/engine";
  54488. import { Camera } from "babylonjs/Cameras/camera";
  54489. import "babylonjs/Shaders/colorCorrection.fragment";
  54490. /**
  54491. *
  54492. * This post-process allows the modification of rendered colors by using
  54493. * a 'look-up table' (LUT). This effect is also called Color Grading.
  54494. *
  54495. * The object needs to be provided an url to a texture containing the color
  54496. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  54497. * Use an image editing software to tweak the LUT to match your needs.
  54498. *
  54499. * For an example of a color LUT, see here:
  54500. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  54501. * For explanations on color grading, see here:
  54502. * @see http://udn.epicgames.com/Three/ColorGrading.html
  54503. *
  54504. */
  54505. export class ColorCorrectionPostProcess extends PostProcess {
  54506. private _colorTableTexture;
  54507. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  54508. }
  54509. }
  54510. declare module "babylonjs/Shaders/convolution.fragment" {
  54511. /** @hidden */
  54512. export var convolutionPixelShader: {
  54513. name: string;
  54514. shader: string;
  54515. };
  54516. }
  54517. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  54518. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54519. import { Nullable } from "babylonjs/types";
  54520. import { Camera } from "babylonjs/Cameras/camera";
  54521. import { Engine } from "babylonjs/Engines/engine";
  54522. import "babylonjs/Shaders/convolution.fragment";
  54523. /**
  54524. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  54525. * input texture to perform effects such as edge detection or sharpening
  54526. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  54527. */
  54528. export class ConvolutionPostProcess extends PostProcess {
  54529. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  54530. kernel: number[];
  54531. /**
  54532. * Creates a new instance ConvolutionPostProcess
  54533. * @param name The name of the effect.
  54534. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  54535. * @param options The required width/height ratio to downsize to before computing the render pass.
  54536. * @param camera The camera to apply the render pass to.
  54537. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54538. * @param engine The engine which the post process will be applied. (default: current engine)
  54539. * @param reusable If the post process can be reused on the same frame. (default: false)
  54540. * @param textureType Type of textures used when performing the post process. (default: 0)
  54541. */
  54542. constructor(name: string,
  54543. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  54544. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  54545. /**
  54546. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  54547. */
  54548. static EdgeDetect0Kernel: number[];
  54549. /**
  54550. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  54551. */
  54552. static EdgeDetect1Kernel: number[];
  54553. /**
  54554. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  54555. */
  54556. static EdgeDetect2Kernel: number[];
  54557. /**
  54558. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  54559. */
  54560. static SharpenKernel: number[];
  54561. /**
  54562. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  54563. */
  54564. static EmbossKernel: number[];
  54565. /**
  54566. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  54567. */
  54568. static GaussianKernel: number[];
  54569. }
  54570. }
  54571. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  54572. import { Nullable } from "babylonjs/types";
  54573. import { Vector2 } from "babylonjs/Maths/math";
  54574. import { Camera } from "babylonjs/Cameras/camera";
  54575. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54576. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  54577. import { Engine } from "babylonjs/Engines/engine";
  54578. import { Scene } from "babylonjs/scene";
  54579. /**
  54580. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  54581. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  54582. * based on samples that have a large difference in distance than the center pixel.
  54583. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  54584. */
  54585. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  54586. direction: Vector2;
  54587. /**
  54588. * Creates a new instance CircleOfConfusionPostProcess
  54589. * @param name The name of the effect.
  54590. * @param scene The scene the effect belongs to.
  54591. * @param direction The direction the blur should be applied.
  54592. * @param kernel The size of the kernel used to blur.
  54593. * @param options The required width/height ratio to downsize to before computing the render pass.
  54594. * @param camera The camera to apply the render pass to.
  54595. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  54596. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  54597. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54598. * @param engine The engine which the post process will be applied. (default: current engine)
  54599. * @param reusable If the post process can be reused on the same frame. (default: false)
  54600. * @param textureType Type of textures used when performing the post process. (default: 0)
  54601. * @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)
  54602. */
  54603. 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);
  54604. }
  54605. }
  54606. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  54607. /** @hidden */
  54608. export var depthOfFieldMergePixelShader: {
  54609. name: string;
  54610. shader: string;
  54611. };
  54612. }
  54613. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  54614. import { Nullable } from "babylonjs/types";
  54615. import { Camera } from "babylonjs/Cameras/camera";
  54616. import { Effect } from "babylonjs/Materials/effect";
  54617. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54618. import { Engine } from "babylonjs/Engines/engine";
  54619. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  54620. /**
  54621. * Options to be set when merging outputs from the default pipeline.
  54622. */
  54623. export class DepthOfFieldMergePostProcessOptions {
  54624. /**
  54625. * The original image to merge on top of
  54626. */
  54627. originalFromInput: PostProcess;
  54628. /**
  54629. * Parameters to perform the merge of the depth of field effect
  54630. */
  54631. depthOfField?: {
  54632. circleOfConfusion: PostProcess;
  54633. blurSteps: Array<PostProcess>;
  54634. };
  54635. /**
  54636. * Parameters to perform the merge of bloom effect
  54637. */
  54638. bloom?: {
  54639. blurred: PostProcess;
  54640. weight: number;
  54641. };
  54642. }
  54643. /**
  54644. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  54645. */
  54646. export class DepthOfFieldMergePostProcess extends PostProcess {
  54647. private blurSteps;
  54648. /**
  54649. * Creates a new instance of DepthOfFieldMergePostProcess
  54650. * @param name The name of the effect.
  54651. * @param originalFromInput Post process which's input will be used for the merge.
  54652. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  54653. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  54654. * @param options The required width/height ratio to downsize to before computing the render pass.
  54655. * @param camera The camera to apply the render pass to.
  54656. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54657. * @param engine The engine which the post process will be applied. (default: current engine)
  54658. * @param reusable If the post process can be reused on the same frame. (default: false)
  54659. * @param textureType Type of textures used when performing the post process. (default: 0)
  54660. * @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)
  54661. */
  54662. 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);
  54663. /**
  54664. * Updates the effect with the current post process compile time values and recompiles the shader.
  54665. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  54666. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  54667. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  54668. * @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
  54669. * @param onCompiled Called when the shader has been compiled.
  54670. * @param onError Called if there is an error when compiling a shader.
  54671. */
  54672. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  54673. }
  54674. }
  54675. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  54676. import { Nullable } from "babylonjs/types";
  54677. import { Camera } from "babylonjs/Cameras/camera";
  54678. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  54679. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  54680. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  54681. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  54682. import { Scene } from "babylonjs/scene";
  54683. /**
  54684. * Specifies the level of max blur that should be applied when using the depth of field effect
  54685. */
  54686. export enum DepthOfFieldEffectBlurLevel {
  54687. /**
  54688. * Subtle blur
  54689. */
  54690. Low = 0,
  54691. /**
  54692. * Medium blur
  54693. */
  54694. Medium = 1,
  54695. /**
  54696. * Large blur
  54697. */
  54698. High = 2
  54699. }
  54700. /**
  54701. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  54702. */
  54703. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  54704. private _circleOfConfusion;
  54705. /**
  54706. * @hidden Internal, blurs from high to low
  54707. */
  54708. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  54709. private _depthOfFieldBlurY;
  54710. private _dofMerge;
  54711. /**
  54712. * @hidden Internal post processes in depth of field effect
  54713. */
  54714. _effects: Array<PostProcess>;
  54715. /**
  54716. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  54717. */
  54718. focalLength: number;
  54719. /**
  54720. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  54721. */
  54722. fStop: number;
  54723. /**
  54724. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  54725. */
  54726. focusDistance: number;
  54727. /**
  54728. * 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.
  54729. */
  54730. lensSize: number;
  54731. /**
  54732. * Creates a new instance DepthOfFieldEffect
  54733. * @param scene The scene the effect belongs to.
  54734. * @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.
  54735. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  54736. * @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)
  54737. */
  54738. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  54739. /**
  54740. * 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.
  54741. */
  54742. depthTexture: RenderTargetTexture;
  54743. /**
  54744. * Disposes each of the internal effects for a given camera.
  54745. * @param camera The camera to dispose the effect on.
  54746. */
  54747. disposeEffects(camera: Camera): void;
  54748. /**
  54749. * @hidden Internal
  54750. */
  54751. _updateEffects(): void;
  54752. /**
  54753. * Internal
  54754. * @returns if all the contained post processes are ready.
  54755. * @hidden
  54756. */
  54757. _isReady(): boolean;
  54758. }
  54759. }
  54760. declare module "babylonjs/Shaders/displayPass.fragment" {
  54761. /** @hidden */
  54762. export var displayPassPixelShader: {
  54763. name: string;
  54764. shader: string;
  54765. };
  54766. }
  54767. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  54768. import { Nullable } from "babylonjs/types";
  54769. import { Camera } from "babylonjs/Cameras/camera";
  54770. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54771. import { Engine } from "babylonjs/Engines/engine";
  54772. import "babylonjs/Shaders/displayPass.fragment";
  54773. /**
  54774. * DisplayPassPostProcess which produces an output the same as it's input
  54775. */
  54776. export class DisplayPassPostProcess extends PostProcess {
  54777. /**
  54778. * Creates the DisplayPassPostProcess
  54779. * @param name The name of the effect.
  54780. * @param options The required width/height ratio to downsize to before computing the render pass.
  54781. * @param camera The camera to apply the render pass to.
  54782. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54783. * @param engine The engine which the post process will be applied. (default: current engine)
  54784. * @param reusable If the post process can be reused on the same frame. (default: false)
  54785. */
  54786. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  54787. }
  54788. }
  54789. declare module "babylonjs/Shaders/filter.fragment" {
  54790. /** @hidden */
  54791. export var filterPixelShader: {
  54792. name: string;
  54793. shader: string;
  54794. };
  54795. }
  54796. declare module "babylonjs/PostProcesses/filterPostProcess" {
  54797. import { Nullable } from "babylonjs/types";
  54798. import { Matrix } from "babylonjs/Maths/math";
  54799. import { Camera } from "babylonjs/Cameras/camera";
  54800. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54801. import { Engine } from "babylonjs/Engines/engine";
  54802. import "babylonjs/Shaders/filter.fragment";
  54803. /**
  54804. * Applies a kernel filter to the image
  54805. */
  54806. export class FilterPostProcess extends PostProcess {
  54807. /** The matrix to be applied to the image */
  54808. kernelMatrix: Matrix;
  54809. /**
  54810. *
  54811. * @param name The name of the effect.
  54812. * @param kernelMatrix The matrix to be applied to the image
  54813. * @param options The required width/height ratio to downsize to before computing the render pass.
  54814. * @param camera The camera to apply the render pass to.
  54815. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54816. * @param engine The engine which the post process will be applied. (default: current engine)
  54817. * @param reusable If the post process can be reused on the same frame. (default: false)
  54818. */
  54819. constructor(name: string,
  54820. /** The matrix to be applied to the image */
  54821. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  54822. }
  54823. }
  54824. declare module "babylonjs/Shaders/fxaa.fragment" {
  54825. /** @hidden */
  54826. export var fxaaPixelShader: {
  54827. name: string;
  54828. shader: string;
  54829. };
  54830. }
  54831. declare module "babylonjs/Shaders/fxaa.vertex" {
  54832. /** @hidden */
  54833. export var fxaaVertexShader: {
  54834. name: string;
  54835. shader: string;
  54836. };
  54837. }
  54838. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  54839. import { Nullable } from "babylonjs/types";
  54840. import { Camera } from "babylonjs/Cameras/camera";
  54841. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54842. import { Engine } from "babylonjs/Engines/engine";
  54843. import "babylonjs/Shaders/fxaa.fragment";
  54844. import "babylonjs/Shaders/fxaa.vertex";
  54845. /**
  54846. * Fxaa post process
  54847. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  54848. */
  54849. export class FxaaPostProcess extends PostProcess {
  54850. /** @hidden */
  54851. texelWidth: number;
  54852. /** @hidden */
  54853. texelHeight: number;
  54854. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  54855. private _getDefines;
  54856. }
  54857. }
  54858. declare module "babylonjs/Shaders/grain.fragment" {
  54859. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  54860. /** @hidden */
  54861. export var grainPixelShader: {
  54862. name: string;
  54863. shader: string;
  54864. };
  54865. }
  54866. declare module "babylonjs/PostProcesses/grainPostProcess" {
  54867. import { Nullable } from "babylonjs/types";
  54868. import { Camera } from "babylonjs/Cameras/camera";
  54869. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54870. import { Engine } from "babylonjs/Engines/engine";
  54871. import "babylonjs/Shaders/grain.fragment";
  54872. /**
  54873. * The GrainPostProcess adds noise to the image at mid luminance levels
  54874. */
  54875. export class GrainPostProcess extends PostProcess {
  54876. /**
  54877. * The intensity of the grain added (default: 30)
  54878. */
  54879. intensity: number;
  54880. /**
  54881. * If the grain should be randomized on every frame
  54882. */
  54883. animated: boolean;
  54884. /**
  54885. * Creates a new instance of @see GrainPostProcess
  54886. * @param name The name of the effect.
  54887. * @param options The required width/height ratio to downsize to before computing the render pass.
  54888. * @param camera The camera to apply the render pass to.
  54889. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54890. * @param engine The engine which the post process will be applied. (default: current engine)
  54891. * @param reusable If the post process can be reused on the same frame. (default: false)
  54892. * @param textureType Type of textures used when performing the post process. (default: 0)
  54893. * @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)
  54894. */
  54895. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  54896. }
  54897. }
  54898. declare module "babylonjs/Shaders/highlights.fragment" {
  54899. /** @hidden */
  54900. export var highlightsPixelShader: {
  54901. name: string;
  54902. shader: string;
  54903. };
  54904. }
  54905. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  54906. import { Nullable } from "babylonjs/types";
  54907. import { Camera } from "babylonjs/Cameras/camera";
  54908. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54909. import { Engine } from "babylonjs/Engines/engine";
  54910. import "babylonjs/Shaders/highlights.fragment";
  54911. /**
  54912. * Extracts highlights from the image
  54913. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  54914. */
  54915. export class HighlightsPostProcess extends PostProcess {
  54916. /**
  54917. * Extracts highlights from the image
  54918. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  54919. * @param name The name of the effect.
  54920. * @param options The required width/height ratio to downsize to before computing the render pass.
  54921. * @param camera The camera to apply the render pass to.
  54922. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54923. * @param engine The engine which the post process will be applied. (default: current engine)
  54924. * @param reusable If the post process can be reused on the same frame. (default: false)
  54925. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  54926. */
  54927. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  54928. }
  54929. }
  54930. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  54931. /** @hidden */
  54932. export var mrtFragmentDeclaration: {
  54933. name: string;
  54934. shader: string;
  54935. };
  54936. }
  54937. declare module "babylonjs/Shaders/geometry.fragment" {
  54938. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  54939. /** @hidden */
  54940. export var geometryPixelShader: {
  54941. name: string;
  54942. shader: string;
  54943. };
  54944. }
  54945. declare module "babylonjs/Shaders/geometry.vertex" {
  54946. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  54947. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  54948. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  54949. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  54950. /** @hidden */
  54951. export var geometryVertexShader: {
  54952. name: string;
  54953. shader: string;
  54954. };
  54955. }
  54956. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  54957. import { Matrix } from "babylonjs/Maths/math";
  54958. import { SubMesh } from "babylonjs/Meshes/subMesh";
  54959. import { Mesh } from "babylonjs/Meshes/mesh";
  54960. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  54961. import { Effect } from "babylonjs/Materials/effect";
  54962. import { Scene } from "babylonjs/scene";
  54963. import "babylonjs/Shaders/geometry.fragment";
  54964. import "babylonjs/Shaders/geometry.vertex";
  54965. /**
  54966. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  54967. */
  54968. export class GeometryBufferRenderer {
  54969. /**
  54970. * Constant used to retrieve the position texture index in the G-Buffer textures array
  54971. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  54972. */
  54973. static readonly POSITION_TEXTURE_TYPE: number;
  54974. /**
  54975. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  54976. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  54977. */
  54978. static readonly VELOCITY_TEXTURE_TYPE: number;
  54979. /**
  54980. * Dictionary used to store the previous transformation matrices of each rendered mesh
  54981. * in order to compute objects velocities when enableVelocity is set to "true"
  54982. * @hidden
  54983. */
  54984. _previousTransformationMatrices: {
  54985. [index: number]: Matrix;
  54986. };
  54987. private _scene;
  54988. private _multiRenderTarget;
  54989. private _ratio;
  54990. private _enablePosition;
  54991. private _enableVelocity;
  54992. private _positionIndex;
  54993. private _velocityIndex;
  54994. protected _effect: Effect;
  54995. protected _cachedDefines: string;
  54996. /**
  54997. * Set the render list (meshes to be rendered) used in the G buffer.
  54998. */
  54999. renderList: Mesh[];
  55000. /**
  55001. * Gets wether or not G buffer are supported by the running hardware.
  55002. * This requires draw buffer supports
  55003. */
  55004. readonly isSupported: boolean;
  55005. /**
  55006. * Returns the index of the given texture type in the G-Buffer textures array
  55007. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  55008. * @returns the index of the given texture type in the G-Buffer textures array
  55009. */
  55010. getTextureIndex(textureType: number): number;
  55011. /**
  55012. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  55013. */
  55014. /**
  55015. * Sets whether or not objects positions are enabled for the G buffer.
  55016. */
  55017. enablePosition: boolean;
  55018. /**
  55019. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  55020. */
  55021. /**
  55022. * Sets wether or not objects velocities are enabled for the G buffer.
  55023. */
  55024. enableVelocity: boolean;
  55025. /**
  55026. * Gets the scene associated with the buffer.
  55027. */
  55028. readonly scene: Scene;
  55029. /**
  55030. * Gets the ratio used by the buffer during its creation.
  55031. * How big is the buffer related to the main canvas.
  55032. */
  55033. readonly ratio: number;
  55034. /** @hidden */
  55035. static _SceneComponentInitialization: (scene: Scene) => void;
  55036. /**
  55037. * Creates a new G Buffer for the scene
  55038. * @param scene The scene the buffer belongs to
  55039. * @param ratio How big is the buffer related to the main canvas.
  55040. */
  55041. constructor(scene: Scene, ratio?: number);
  55042. /**
  55043. * Checks wether everything is ready to render a submesh to the G buffer.
  55044. * @param subMesh the submesh to check readiness for
  55045. * @param useInstances is the mesh drawn using instance or not
  55046. * @returns true if ready otherwise false
  55047. */
  55048. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  55049. /**
  55050. * Gets the current underlying G Buffer.
  55051. * @returns the buffer
  55052. */
  55053. getGBuffer(): MultiRenderTarget;
  55054. /**
  55055. * Gets the number of samples used to render the buffer (anti aliasing).
  55056. */
  55057. /**
  55058. * Sets the number of samples used to render the buffer (anti aliasing).
  55059. */
  55060. samples: number;
  55061. /**
  55062. * Disposes the renderer and frees up associated resources.
  55063. */
  55064. dispose(): void;
  55065. protected _createRenderTargets(): void;
  55066. }
  55067. }
  55068. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  55069. import { Nullable } from "babylonjs/types";
  55070. import { Scene } from "babylonjs/scene";
  55071. import { ISceneComponent } from "babylonjs/sceneComponent";
  55072. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  55073. module "babylonjs/scene" {
  55074. interface Scene {
  55075. /** @hidden (Backing field) */
  55076. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  55077. /**
  55078. * Gets or Sets the current geometry buffer associated to the scene.
  55079. */
  55080. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  55081. /**
  55082. * Enables a GeometryBufferRender and associates it with the scene
  55083. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  55084. * @returns the GeometryBufferRenderer
  55085. */
  55086. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  55087. /**
  55088. * Disables the GeometryBufferRender associated with the scene
  55089. */
  55090. disableGeometryBufferRenderer(): void;
  55091. }
  55092. }
  55093. /**
  55094. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  55095. * in several rendering techniques.
  55096. */
  55097. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  55098. /**
  55099. * The component name helpful to identify the component in the list of scene components.
  55100. */
  55101. readonly name: string;
  55102. /**
  55103. * The scene the component belongs to.
  55104. */
  55105. scene: Scene;
  55106. /**
  55107. * Creates a new instance of the component for the given scene
  55108. * @param scene Defines the scene to register the component in
  55109. */
  55110. constructor(scene: Scene);
  55111. /**
  55112. * Registers the component in a given scene
  55113. */
  55114. register(): void;
  55115. /**
  55116. * Rebuilds the elements related to this component in case of
  55117. * context lost for instance.
  55118. */
  55119. rebuild(): void;
  55120. /**
  55121. * Disposes the component and the associated ressources
  55122. */
  55123. dispose(): void;
  55124. private _gatherRenderTargets;
  55125. }
  55126. }
  55127. declare module "babylonjs/Shaders/motionBlur.fragment" {
  55128. /** @hidden */
  55129. export var motionBlurPixelShader: {
  55130. name: string;
  55131. shader: string;
  55132. };
  55133. }
  55134. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  55135. import { Nullable } from "babylonjs/types";
  55136. import { Camera } from "babylonjs/Cameras/camera";
  55137. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  55138. import { Scene } from "babylonjs/scene";
  55139. import "babylonjs/Animations/animatable";
  55140. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  55141. import "babylonjs/Shaders/motionBlur.fragment";
  55142. import { Engine } from "babylonjs/Engines/engine";
  55143. /**
  55144. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  55145. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  55146. * As an example, all you have to do is to create the post-process:
  55147. * var mb = new BABYLON.MotionBlurPostProcess(
  55148. * 'mb', // The name of the effect.
  55149. * scene, // The scene containing the objects to blur according to their velocity.
  55150. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  55151. * camera // The camera to apply the render pass to.
  55152. * );
  55153. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  55154. */
  55155. export class MotionBlurPostProcess extends PostProcess {
  55156. /**
  55157. * Defines how much the image is blurred by the movement. Default value is equal to 1
  55158. */
  55159. motionStrength: number;
  55160. /**
  55161. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  55162. */
  55163. /**
  55164. * Sets the number of iterations to be used for motion blur quality
  55165. */
  55166. motionBlurSamples: number;
  55167. private _motionBlurSamples;
  55168. private _geometryBufferRenderer;
  55169. /**
  55170. * Creates a new instance MotionBlurPostProcess
  55171. * @param name The name of the effect.
  55172. * @param scene The scene containing the objects to blur according to their velocity.
  55173. * @param options The required width/height ratio to downsize to before computing the render pass.
  55174. * @param camera The camera to apply the render pass to.
  55175. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55176. * @param engine The engine which the post process will be applied. (default: current engine)
  55177. * @param reusable If the post process can be reused on the same frame. (default: false)
  55178. * @param textureType Type of textures used when performing the post process. (default: 0)
  55179. * @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)
  55180. */
  55181. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  55182. /**
  55183. * Disposes the post process.
  55184. * @param camera The camera to dispose the post process on.
  55185. */
  55186. dispose(camera?: Camera): void;
  55187. }
  55188. }
  55189. declare module "babylonjs/Shaders/refraction.fragment" {
  55190. /** @hidden */
  55191. export var refractionPixelShader: {
  55192. name: string;
  55193. shader: string;
  55194. };
  55195. }
  55196. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  55197. import { Color3 } from "babylonjs/Maths/math";
  55198. import { Camera } from "babylonjs/Cameras/camera";
  55199. import { Texture } from "babylonjs/Materials/Textures/texture";
  55200. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  55201. import { Engine } from "babylonjs/Engines/engine";
  55202. import "babylonjs/Shaders/refraction.fragment";
  55203. /**
  55204. * Post process which applies a refractin texture
  55205. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  55206. */
  55207. export class RefractionPostProcess extends PostProcess {
  55208. /** the base color of the refraction (used to taint the rendering) */
  55209. color: Color3;
  55210. /** simulated refraction depth */
  55211. depth: number;
  55212. /** the coefficient of the base color (0 to remove base color tainting) */
  55213. colorLevel: number;
  55214. private _refTexture;
  55215. private _ownRefractionTexture;
  55216. /**
  55217. * Gets or sets the refraction texture
  55218. * Please note that you are responsible for disposing the texture if you set it manually
  55219. */
  55220. refractionTexture: Texture;
  55221. /**
  55222. * Initializes the RefractionPostProcess
  55223. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  55224. * @param name The name of the effect.
  55225. * @param refractionTextureUrl Url of the refraction texture to use
  55226. * @param color the base color of the refraction (used to taint the rendering)
  55227. * @param depth simulated refraction depth
  55228. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  55229. * @param camera The camera to apply the render pass to.
  55230. * @param options The required width/height ratio to downsize to before computing the render pass.
  55231. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55232. * @param engine The engine which the post process will be applied. (default: current engine)
  55233. * @param reusable If the post process can be reused on the same frame. (default: false)
  55234. */
  55235. constructor(name: string, refractionTextureUrl: string,
  55236. /** the base color of the refraction (used to taint the rendering) */
  55237. color: Color3,
  55238. /** simulated refraction depth */
  55239. depth: number,
  55240. /** the coefficient of the base color (0 to remove base color tainting) */
  55241. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  55242. /**
  55243. * Disposes of the post process
  55244. * @param camera Camera to dispose post process on
  55245. */
  55246. dispose(camera: Camera): void;
  55247. }
  55248. }
  55249. declare module "babylonjs/Shaders/sharpen.fragment" {
  55250. /** @hidden */
  55251. export var sharpenPixelShader: {
  55252. name: string;
  55253. shader: string;
  55254. };
  55255. }
  55256. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  55257. import { Nullable } from "babylonjs/types";
  55258. import { Camera } from "babylonjs/Cameras/camera";
  55259. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  55260. import "babylonjs/Shaders/sharpen.fragment";
  55261. import { Engine } from "babylonjs/Engines/engine";
  55262. /**
  55263. * The SharpenPostProcess applies a sharpen kernel to every pixel
  55264. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  55265. */
  55266. export class SharpenPostProcess extends PostProcess {
  55267. /**
  55268. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  55269. */
  55270. colorAmount: number;
  55271. /**
  55272. * How much sharpness should be applied (default: 0.3)
  55273. */
  55274. edgeAmount: number;
  55275. /**
  55276. * Creates a new instance ConvolutionPostProcess
  55277. * @param name The name of the effect.
  55278. * @param options The required width/height ratio to downsize to before computing the render pass.
  55279. * @param camera The camera to apply the render pass to.
  55280. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55281. * @param engine The engine which the post process will be applied. (default: current engine)
  55282. * @param reusable If the post process can be reused on the same frame. (default: false)
  55283. * @param textureType Type of textures used when performing the post process. (default: 0)
  55284. * @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)
  55285. */
  55286. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  55287. }
  55288. }
  55289. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  55290. import { Nullable } from "babylonjs/types";
  55291. import { Camera } from "babylonjs/Cameras/camera";
  55292. import { Engine } from "babylonjs/Engines/engine";
  55293. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  55294. import { IInspectable } from "babylonjs/Misc/iInspectable";
  55295. /**
  55296. * PostProcessRenderPipeline
  55297. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  55298. */
  55299. export class PostProcessRenderPipeline {
  55300. private engine;
  55301. private _renderEffects;
  55302. private _renderEffectsForIsolatedPass;
  55303. /**
  55304. * List of inspectable custom properties (used by the Inspector)
  55305. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  55306. */
  55307. inspectableCustomProperties: IInspectable[];
  55308. /**
  55309. * @hidden
  55310. */
  55311. protected _cameras: Camera[];
  55312. /** @hidden */
  55313. _name: string;
  55314. /**
  55315. * Gets pipeline name
  55316. */
  55317. readonly name: string;
  55318. /**
  55319. * Initializes a PostProcessRenderPipeline
  55320. * @param engine engine to add the pipeline to
  55321. * @param name name of the pipeline
  55322. */
  55323. constructor(engine: Engine, name: string);
  55324. /**
  55325. * Gets the class name
  55326. * @returns "PostProcessRenderPipeline"
  55327. */
  55328. getClassName(): string;
  55329. /**
  55330. * If all the render effects in the pipeline are supported
  55331. */
  55332. readonly isSupported: boolean;
  55333. /**
  55334. * Adds an effect to the pipeline
  55335. * @param renderEffect the effect to add
  55336. */
  55337. addEffect(renderEffect: PostProcessRenderEffect): void;
  55338. /** @hidden */
  55339. _rebuild(): void;
  55340. /** @hidden */
  55341. _enableEffect(renderEffectName: string, cameras: Camera): void;
  55342. /** @hidden */
  55343. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  55344. /** @hidden */
  55345. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  55346. /** @hidden */
  55347. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  55348. /** @hidden */
  55349. _attachCameras(cameras: Camera, unique: boolean): void;
  55350. /** @hidden */
  55351. _attachCameras(cameras: Camera[], unique: boolean): void;
  55352. /** @hidden */
  55353. _detachCameras(cameras: Camera): void;
  55354. /** @hidden */
  55355. _detachCameras(cameras: Nullable<Camera[]>): void;
  55356. /** @hidden */
  55357. _update(): void;
  55358. /** @hidden */
  55359. _reset(): void;
  55360. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  55361. /**
  55362. * Disposes of the pipeline
  55363. */
  55364. dispose(): void;
  55365. }
  55366. }
  55367. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  55368. import { Camera } from "babylonjs/Cameras/camera";
  55369. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  55370. /**
  55371. * PostProcessRenderPipelineManager class
  55372. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  55373. */
  55374. export class PostProcessRenderPipelineManager {
  55375. private _renderPipelines;
  55376. /**
  55377. * Initializes a PostProcessRenderPipelineManager
  55378. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  55379. */
  55380. constructor();
  55381. /**
  55382. * Gets the list of supported render pipelines
  55383. */
  55384. readonly supportedPipelines: PostProcessRenderPipeline[];
  55385. /**
  55386. * Adds a pipeline to the manager
  55387. * @param renderPipeline The pipeline to add
  55388. */
  55389. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  55390. /**
  55391. * Attaches a camera to the pipeline
  55392. * @param renderPipelineName The name of the pipeline to attach to
  55393. * @param cameras the camera to attach
  55394. * @param unique if the camera can be attached multiple times to the pipeline
  55395. */
  55396. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  55397. /**
  55398. * Detaches a camera from the pipeline
  55399. * @param renderPipelineName The name of the pipeline to detach from
  55400. * @param cameras the camera to detach
  55401. */
  55402. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  55403. /**
  55404. * Enables an effect by name on a pipeline
  55405. * @param renderPipelineName the name of the pipeline to enable the effect in
  55406. * @param renderEffectName the name of the effect to enable
  55407. * @param cameras the cameras that the effect should be enabled on
  55408. */
  55409. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  55410. /**
  55411. * Disables an effect by name on a pipeline
  55412. * @param renderPipelineName the name of the pipeline to disable the effect in
  55413. * @param renderEffectName the name of the effect to disable
  55414. * @param cameras the cameras that the effect should be disabled on
  55415. */
  55416. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  55417. /**
  55418. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  55419. */
  55420. update(): void;
  55421. /** @hidden */
  55422. _rebuild(): void;
  55423. /**
  55424. * Disposes of the manager and pipelines
  55425. */
  55426. dispose(): void;
  55427. }
  55428. }
  55429. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  55430. import { ISceneComponent } from "babylonjs/sceneComponent";
  55431. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  55432. import { Scene } from "babylonjs/scene";
  55433. module "babylonjs/scene" {
  55434. interface Scene {
  55435. /** @hidden (Backing field) */
  55436. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  55437. /**
  55438. * Gets the postprocess render pipeline manager
  55439. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  55440. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  55441. */
  55442. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  55443. }
  55444. }
  55445. /**
  55446. * Defines the Render Pipeline scene component responsible to rendering pipelines
  55447. */
  55448. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  55449. /**
  55450. * The component name helpfull to identify the component in the list of scene components.
  55451. */
  55452. readonly name: string;
  55453. /**
  55454. * The scene the component belongs to.
  55455. */
  55456. scene: Scene;
  55457. /**
  55458. * Creates a new instance of the component for the given scene
  55459. * @param scene Defines the scene to register the component in
  55460. */
  55461. constructor(scene: Scene);
  55462. /**
  55463. * Registers the component in a given scene
  55464. */
  55465. register(): void;
  55466. /**
  55467. * Rebuilds the elements related to this component in case of
  55468. * context lost for instance.
  55469. */
  55470. rebuild(): void;
  55471. /**
  55472. * Disposes the component and the associated ressources
  55473. */
  55474. dispose(): void;
  55475. private _gatherRenderTargets;
  55476. }
  55477. }
  55478. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  55479. import { IAnimatable } from "babylonjs/Misc/tools";
  55480. import { Camera } from "babylonjs/Cameras/camera";
  55481. import { IDisposable } from "babylonjs/scene";
  55482. import { Scene } from "babylonjs/scene";
  55483. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  55484. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  55485. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  55486. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  55487. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  55488. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  55489. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  55490. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  55491. import { Animation } from "babylonjs/Animations/animation";
  55492. /**
  55493. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  55494. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  55495. */
  55496. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  55497. private _scene;
  55498. private _camerasToBeAttached;
  55499. /**
  55500. * ID of the sharpen post process,
  55501. */
  55502. private readonly SharpenPostProcessId;
  55503. /**
  55504. * @ignore
  55505. * ID of the image processing post process;
  55506. */
  55507. readonly ImageProcessingPostProcessId: string;
  55508. /**
  55509. * @ignore
  55510. * ID of the Fast Approximate Anti-Aliasing post process;
  55511. */
  55512. readonly FxaaPostProcessId: string;
  55513. /**
  55514. * ID of the chromatic aberration post process,
  55515. */
  55516. private readonly ChromaticAberrationPostProcessId;
  55517. /**
  55518. * ID of the grain post process
  55519. */
  55520. private readonly GrainPostProcessId;
  55521. /**
  55522. * Sharpen post process which will apply a sharpen convolution to enhance edges
  55523. */
  55524. sharpen: SharpenPostProcess;
  55525. private _sharpenEffect;
  55526. private bloom;
  55527. /**
  55528. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  55529. */
  55530. depthOfField: DepthOfFieldEffect;
  55531. /**
  55532. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  55533. */
  55534. fxaa: FxaaPostProcess;
  55535. /**
  55536. * Image post processing pass used to perform operations such as tone mapping or color grading.
  55537. */
  55538. imageProcessing: ImageProcessingPostProcess;
  55539. /**
  55540. * Chromatic aberration post process which will shift rgb colors in the image
  55541. */
  55542. chromaticAberration: ChromaticAberrationPostProcess;
  55543. private _chromaticAberrationEffect;
  55544. /**
  55545. * Grain post process which add noise to the image
  55546. */
  55547. grain: GrainPostProcess;
  55548. private _grainEffect;
  55549. /**
  55550. * Glow post process which adds a glow to emissive areas of the image
  55551. */
  55552. private _glowLayer;
  55553. /**
  55554. * Animations which can be used to tweak settings over a period of time
  55555. */
  55556. animations: Animation[];
  55557. private _imageProcessingConfigurationObserver;
  55558. private _sharpenEnabled;
  55559. private _bloomEnabled;
  55560. private _depthOfFieldEnabled;
  55561. private _depthOfFieldBlurLevel;
  55562. private _fxaaEnabled;
  55563. private _imageProcessingEnabled;
  55564. private _defaultPipelineTextureType;
  55565. private _bloomScale;
  55566. private _chromaticAberrationEnabled;
  55567. private _grainEnabled;
  55568. private _buildAllowed;
  55569. /**
  55570. * Gets active scene
  55571. */
  55572. readonly scene: Scene;
  55573. /**
  55574. * Enable or disable the sharpen process from the pipeline
  55575. */
  55576. sharpenEnabled: boolean;
  55577. private _resizeObserver;
  55578. private _hardwareScaleLevel;
  55579. private _bloomKernel;
  55580. /**
  55581. * Specifies the size of the bloom blur kernel, relative to the final output size
  55582. */
  55583. bloomKernel: number;
  55584. /**
  55585. * Specifies the weight of the bloom in the final rendering
  55586. */
  55587. private _bloomWeight;
  55588. /**
  55589. * Specifies the luma threshold for the area that will be blurred by the bloom
  55590. */
  55591. private _bloomThreshold;
  55592. private _hdr;
  55593. /**
  55594. * The strength of the bloom.
  55595. */
  55596. bloomWeight: number;
  55597. /**
  55598. * The strength of the bloom.
  55599. */
  55600. bloomThreshold: number;
  55601. /**
  55602. * The scale of the bloom, lower value will provide better performance.
  55603. */
  55604. bloomScale: number;
  55605. /**
  55606. * Enable or disable the bloom from the pipeline
  55607. */
  55608. bloomEnabled: boolean;
  55609. private _rebuildBloom;
  55610. /**
  55611. * If the depth of field is enabled.
  55612. */
  55613. depthOfFieldEnabled: boolean;
  55614. /**
  55615. * Blur level of the depth of field effect. (Higher blur will effect performance)
  55616. */
  55617. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  55618. /**
  55619. * If the anti aliasing is enabled.
  55620. */
  55621. fxaaEnabled: boolean;
  55622. private _samples;
  55623. /**
  55624. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  55625. */
  55626. samples: number;
  55627. /**
  55628. * If image processing is enabled.
  55629. */
  55630. imageProcessingEnabled: boolean;
  55631. /**
  55632. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  55633. */
  55634. glowLayerEnabled: boolean;
  55635. /**
  55636. * Enable or disable the chromaticAberration process from the pipeline
  55637. */
  55638. chromaticAberrationEnabled: boolean;
  55639. /**
  55640. * Enable or disable the grain process from the pipeline
  55641. */
  55642. grainEnabled: boolean;
  55643. /**
  55644. * @constructor
  55645. * @param name - The rendering pipeline name (default: "")
  55646. * @param hdr - If high dynamic range textures should be used (default: true)
  55647. * @param scene - The scene linked to this pipeline (default: the last created scene)
  55648. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  55649. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  55650. */
  55651. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  55652. /**
  55653. * Get the class name
  55654. * @returns "DefaultRenderingPipeline"
  55655. */
  55656. getClassName(): string;
  55657. /**
  55658. * Force the compilation of the entire pipeline.
  55659. */
  55660. prepare(): void;
  55661. private _hasCleared;
  55662. private _prevPostProcess;
  55663. private _prevPrevPostProcess;
  55664. private _setAutoClearAndTextureSharing;
  55665. private _depthOfFieldSceneObserver;
  55666. private _buildPipeline;
  55667. private _disposePostProcesses;
  55668. /**
  55669. * Adds a camera to the pipeline
  55670. * @param camera the camera to be added
  55671. */
  55672. addCamera(camera: Camera): void;
  55673. /**
  55674. * Removes a camera from the pipeline
  55675. * @param camera the camera to remove
  55676. */
  55677. removeCamera(camera: Camera): void;
  55678. /**
  55679. * Dispose of the pipeline and stop all post processes
  55680. */
  55681. dispose(): void;
  55682. /**
  55683. * Serialize the rendering pipeline (Used when exporting)
  55684. * @returns the serialized object
  55685. */
  55686. serialize(): any;
  55687. /**
  55688. * Parse the serialized pipeline
  55689. * @param source Source pipeline.
  55690. * @param scene The scene to load the pipeline to.
  55691. * @param rootUrl The URL of the serialized pipeline.
  55692. * @returns An instantiated pipeline from the serialized object.
  55693. */
  55694. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  55695. }
  55696. }
  55697. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  55698. /** @hidden */
  55699. export var lensHighlightsPixelShader: {
  55700. name: string;
  55701. shader: string;
  55702. };
  55703. }
  55704. declare module "babylonjs/Shaders/depthOfField.fragment" {
  55705. /** @hidden */
  55706. export var depthOfFieldPixelShader: {
  55707. name: string;
  55708. shader: string;
  55709. };
  55710. }
  55711. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  55712. import { Camera } from "babylonjs/Cameras/camera";
  55713. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  55714. import { Scene } from "babylonjs/scene";
  55715. import "babylonjs/Shaders/chromaticAberration.fragment";
  55716. import "babylonjs/Shaders/lensHighlights.fragment";
  55717. import "babylonjs/Shaders/depthOfField.fragment";
  55718. /**
  55719. * BABYLON.JS Chromatic Aberration GLSL Shader
  55720. * Author: Olivier Guyot
  55721. * Separates very slightly R, G and B colors on the edges of the screen
  55722. * Inspired by Francois Tarlier & Martins Upitis
  55723. */
  55724. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  55725. /**
  55726. * @ignore
  55727. * The chromatic aberration PostProcess id in the pipeline
  55728. */
  55729. LensChromaticAberrationEffect: string;
  55730. /**
  55731. * @ignore
  55732. * The highlights enhancing PostProcess id in the pipeline
  55733. */
  55734. HighlightsEnhancingEffect: string;
  55735. /**
  55736. * @ignore
  55737. * The depth-of-field PostProcess id in the pipeline
  55738. */
  55739. LensDepthOfFieldEffect: string;
  55740. private _scene;
  55741. private _depthTexture;
  55742. private _grainTexture;
  55743. private _chromaticAberrationPostProcess;
  55744. private _highlightsPostProcess;
  55745. private _depthOfFieldPostProcess;
  55746. private _edgeBlur;
  55747. private _grainAmount;
  55748. private _chromaticAberration;
  55749. private _distortion;
  55750. private _highlightsGain;
  55751. private _highlightsThreshold;
  55752. private _dofDistance;
  55753. private _dofAperture;
  55754. private _dofDarken;
  55755. private _dofPentagon;
  55756. private _blurNoise;
  55757. /**
  55758. * @constructor
  55759. *
  55760. * Effect parameters are as follow:
  55761. * {
  55762. * chromatic_aberration: number; // from 0 to x (1 for realism)
  55763. * edge_blur: number; // from 0 to x (1 for realism)
  55764. * distortion: number; // from 0 to x (1 for realism)
  55765. * grain_amount: number; // from 0 to 1
  55766. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  55767. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  55768. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  55769. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  55770. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  55771. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  55772. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  55773. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  55774. * }
  55775. * Note: if an effect parameter is unset, effect is disabled
  55776. *
  55777. * @param name The rendering pipeline name
  55778. * @param parameters - An object containing all parameters (see above)
  55779. * @param scene The scene linked to this pipeline
  55780. * @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)
  55781. * @param cameras The array of cameras that the rendering pipeline will be attached to
  55782. */
  55783. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  55784. /**
  55785. * Get the class name
  55786. * @returns "LensRenderingPipeline"
  55787. */
  55788. getClassName(): string;
  55789. /**
  55790. * Gets associated scene
  55791. */
  55792. readonly scene: Scene;
  55793. /**
  55794. * Gets or sets the edge blur
  55795. */
  55796. edgeBlur: number;
  55797. /**
  55798. * Gets or sets the grain amount
  55799. */
  55800. grainAmount: number;
  55801. /**
  55802. * Gets or sets the chromatic aberration amount
  55803. */
  55804. chromaticAberration: number;
  55805. /**
  55806. * Gets or sets the depth of field aperture
  55807. */
  55808. dofAperture: number;
  55809. /**
  55810. * Gets or sets the edge distortion
  55811. */
  55812. edgeDistortion: number;
  55813. /**
  55814. * Gets or sets the depth of field distortion
  55815. */
  55816. dofDistortion: number;
  55817. /**
  55818. * Gets or sets the darken out of focus amount
  55819. */
  55820. darkenOutOfFocus: number;
  55821. /**
  55822. * Gets or sets a boolean indicating if blur noise is enabled
  55823. */
  55824. blurNoise: boolean;
  55825. /**
  55826. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  55827. */
  55828. pentagonBokeh: boolean;
  55829. /**
  55830. * Gets or sets the highlight grain amount
  55831. */
  55832. highlightsGain: number;
  55833. /**
  55834. * Gets or sets the highlight threshold
  55835. */
  55836. highlightsThreshold: number;
  55837. /**
  55838. * Sets the amount of blur at the edges
  55839. * @param amount blur amount
  55840. */
  55841. setEdgeBlur(amount: number): void;
  55842. /**
  55843. * Sets edge blur to 0
  55844. */
  55845. disableEdgeBlur(): void;
  55846. /**
  55847. * Sets the amout of grain
  55848. * @param amount Amount of grain
  55849. */
  55850. setGrainAmount(amount: number): void;
  55851. /**
  55852. * Set grain amount to 0
  55853. */
  55854. disableGrain(): void;
  55855. /**
  55856. * Sets the chromatic aberration amount
  55857. * @param amount amount of chromatic aberration
  55858. */
  55859. setChromaticAberration(amount: number): void;
  55860. /**
  55861. * Sets chromatic aberration amount to 0
  55862. */
  55863. disableChromaticAberration(): void;
  55864. /**
  55865. * Sets the EdgeDistortion amount
  55866. * @param amount amount of EdgeDistortion
  55867. */
  55868. setEdgeDistortion(amount: number): void;
  55869. /**
  55870. * Sets edge distortion to 0
  55871. */
  55872. disableEdgeDistortion(): void;
  55873. /**
  55874. * Sets the FocusDistance amount
  55875. * @param amount amount of FocusDistance
  55876. */
  55877. setFocusDistance(amount: number): void;
  55878. /**
  55879. * Disables depth of field
  55880. */
  55881. disableDepthOfField(): void;
  55882. /**
  55883. * Sets the Aperture amount
  55884. * @param amount amount of Aperture
  55885. */
  55886. setAperture(amount: number): void;
  55887. /**
  55888. * Sets the DarkenOutOfFocus amount
  55889. * @param amount amount of DarkenOutOfFocus
  55890. */
  55891. setDarkenOutOfFocus(amount: number): void;
  55892. private _pentagonBokehIsEnabled;
  55893. /**
  55894. * Creates a pentagon bokeh effect
  55895. */
  55896. enablePentagonBokeh(): void;
  55897. /**
  55898. * Disables the pentagon bokeh effect
  55899. */
  55900. disablePentagonBokeh(): void;
  55901. /**
  55902. * Enables noise blur
  55903. */
  55904. enableNoiseBlur(): void;
  55905. /**
  55906. * Disables noise blur
  55907. */
  55908. disableNoiseBlur(): void;
  55909. /**
  55910. * Sets the HighlightsGain amount
  55911. * @param amount amount of HighlightsGain
  55912. */
  55913. setHighlightsGain(amount: number): void;
  55914. /**
  55915. * Sets the HighlightsThreshold amount
  55916. * @param amount amount of HighlightsThreshold
  55917. */
  55918. setHighlightsThreshold(amount: number): void;
  55919. /**
  55920. * Disables highlights
  55921. */
  55922. disableHighlights(): void;
  55923. /**
  55924. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  55925. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  55926. */
  55927. dispose(disableDepthRender?: boolean): void;
  55928. private _createChromaticAberrationPostProcess;
  55929. private _createHighlightsPostProcess;
  55930. private _createDepthOfFieldPostProcess;
  55931. private _createGrainTexture;
  55932. }
  55933. }
  55934. declare module "babylonjs/Shaders/ssao2.fragment" {
  55935. /** @hidden */
  55936. export var ssao2PixelShader: {
  55937. name: string;
  55938. shader: string;
  55939. };
  55940. }
  55941. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  55942. /** @hidden */
  55943. export var ssaoCombinePixelShader: {
  55944. name: string;
  55945. shader: string;
  55946. };
  55947. }
  55948. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  55949. import { Camera } from "babylonjs/Cameras/camera";
  55950. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  55951. import { Scene } from "babylonjs/scene";
  55952. import "babylonjs/Shaders/ssao2.fragment";
  55953. import "babylonjs/Shaders/ssaoCombine.fragment";
  55954. /**
  55955. * Render pipeline to produce ssao effect
  55956. */
  55957. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  55958. /**
  55959. * @ignore
  55960. * The PassPostProcess id in the pipeline that contains the original scene color
  55961. */
  55962. SSAOOriginalSceneColorEffect: string;
  55963. /**
  55964. * @ignore
  55965. * The SSAO PostProcess id in the pipeline
  55966. */
  55967. SSAORenderEffect: string;
  55968. /**
  55969. * @ignore
  55970. * The horizontal blur PostProcess id in the pipeline
  55971. */
  55972. SSAOBlurHRenderEffect: string;
  55973. /**
  55974. * @ignore
  55975. * The vertical blur PostProcess id in the pipeline
  55976. */
  55977. SSAOBlurVRenderEffect: string;
  55978. /**
  55979. * @ignore
  55980. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  55981. */
  55982. SSAOCombineRenderEffect: string;
  55983. /**
  55984. * The output strength of the SSAO post-process. Default value is 1.0.
  55985. */
  55986. totalStrength: number;
  55987. /**
  55988. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  55989. */
  55990. maxZ: number;
  55991. /**
  55992. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  55993. */
  55994. minZAspect: number;
  55995. private _samples;
  55996. /**
  55997. * Number of samples used for the SSAO calculations. Default value is 8
  55998. */
  55999. samples: number;
  56000. private _textureSamples;
  56001. /**
  56002. * Number of samples to use for antialiasing
  56003. */
  56004. textureSamples: number;
  56005. /**
  56006. * Ratio object used for SSAO ratio and blur ratio
  56007. */
  56008. private _ratio;
  56009. /**
  56010. * Dynamically generated sphere sampler.
  56011. */
  56012. private _sampleSphere;
  56013. /**
  56014. * Blur filter offsets
  56015. */
  56016. private _samplerOffsets;
  56017. private _expensiveBlur;
  56018. /**
  56019. * If bilateral blur should be used
  56020. */
  56021. expensiveBlur: boolean;
  56022. /**
  56023. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  56024. */
  56025. radius: number;
  56026. /**
  56027. * The base color of the SSAO post-process
  56028. * The final result is "base + ssao" between [0, 1]
  56029. */
  56030. base: number;
  56031. /**
  56032. * Support test.
  56033. */
  56034. static readonly IsSupported: boolean;
  56035. private _scene;
  56036. private _depthTexture;
  56037. private _normalTexture;
  56038. private _randomTexture;
  56039. private _originalColorPostProcess;
  56040. private _ssaoPostProcess;
  56041. private _blurHPostProcess;
  56042. private _blurVPostProcess;
  56043. private _ssaoCombinePostProcess;
  56044. private _firstUpdate;
  56045. /**
  56046. * Gets active scene
  56047. */
  56048. readonly scene: Scene;
  56049. /**
  56050. * @constructor
  56051. * @param name The rendering pipeline name
  56052. * @param scene The scene linked to this pipeline
  56053. * @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 }
  56054. * @param cameras The array of cameras that the rendering pipeline will be attached to
  56055. */
  56056. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  56057. /**
  56058. * Get the class name
  56059. * @returns "SSAO2RenderingPipeline"
  56060. */
  56061. getClassName(): string;
  56062. /**
  56063. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  56064. */
  56065. dispose(disableGeometryBufferRenderer?: boolean): void;
  56066. private _createBlurPostProcess;
  56067. /** @hidden */
  56068. _rebuild(): void;
  56069. private _bits;
  56070. private _radicalInverse_VdC;
  56071. private _hammersley;
  56072. private _hemisphereSample_uniform;
  56073. private _generateHemisphere;
  56074. private _createSSAOPostProcess;
  56075. private _createSSAOCombinePostProcess;
  56076. private _createRandomTexture;
  56077. /**
  56078. * Serialize the rendering pipeline (Used when exporting)
  56079. * @returns the serialized object
  56080. */
  56081. serialize(): any;
  56082. /**
  56083. * Parse the serialized pipeline
  56084. * @param source Source pipeline.
  56085. * @param scene The scene to load the pipeline to.
  56086. * @param rootUrl The URL of the serialized pipeline.
  56087. * @returns An instantiated pipeline from the serialized object.
  56088. */
  56089. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  56090. }
  56091. }
  56092. declare module "babylonjs/Shaders/ssao.fragment" {
  56093. /** @hidden */
  56094. export var ssaoPixelShader: {
  56095. name: string;
  56096. shader: string;
  56097. };
  56098. }
  56099. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  56100. import { Camera } from "babylonjs/Cameras/camera";
  56101. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  56102. import { Scene } from "babylonjs/scene";
  56103. import "babylonjs/Shaders/ssao.fragment";
  56104. import "babylonjs/Shaders/ssaoCombine.fragment";
  56105. /**
  56106. * Render pipeline to produce ssao effect
  56107. */
  56108. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  56109. /**
  56110. * @ignore
  56111. * The PassPostProcess id in the pipeline that contains the original scene color
  56112. */
  56113. SSAOOriginalSceneColorEffect: string;
  56114. /**
  56115. * @ignore
  56116. * The SSAO PostProcess id in the pipeline
  56117. */
  56118. SSAORenderEffect: string;
  56119. /**
  56120. * @ignore
  56121. * The horizontal blur PostProcess id in the pipeline
  56122. */
  56123. SSAOBlurHRenderEffect: string;
  56124. /**
  56125. * @ignore
  56126. * The vertical blur PostProcess id in the pipeline
  56127. */
  56128. SSAOBlurVRenderEffect: string;
  56129. /**
  56130. * @ignore
  56131. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  56132. */
  56133. SSAOCombineRenderEffect: string;
  56134. /**
  56135. * The output strength of the SSAO post-process. Default value is 1.0.
  56136. */
  56137. totalStrength: number;
  56138. /**
  56139. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  56140. */
  56141. radius: number;
  56142. /**
  56143. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  56144. * Must not be equal to fallOff and superior to fallOff.
  56145. * Default value is 0.0075
  56146. */
  56147. area: number;
  56148. /**
  56149. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  56150. * Must not be equal to area and inferior to area.
  56151. * Default value is 0.000001
  56152. */
  56153. fallOff: number;
  56154. /**
  56155. * The base color of the SSAO post-process
  56156. * The final result is "base + ssao" between [0, 1]
  56157. */
  56158. base: number;
  56159. private _scene;
  56160. private _depthTexture;
  56161. private _randomTexture;
  56162. private _originalColorPostProcess;
  56163. private _ssaoPostProcess;
  56164. private _blurHPostProcess;
  56165. private _blurVPostProcess;
  56166. private _ssaoCombinePostProcess;
  56167. private _firstUpdate;
  56168. /**
  56169. * Gets active scene
  56170. */
  56171. readonly scene: Scene;
  56172. /**
  56173. * @constructor
  56174. * @param name - The rendering pipeline name
  56175. * @param scene - The scene linked to this pipeline
  56176. * @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 }
  56177. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  56178. */
  56179. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  56180. /**
  56181. * Get the class name
  56182. * @returns "SSAORenderingPipeline"
  56183. */
  56184. getClassName(): string;
  56185. /**
  56186. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  56187. */
  56188. dispose(disableDepthRender?: boolean): void;
  56189. private _createBlurPostProcess;
  56190. /** @hidden */
  56191. _rebuild(): void;
  56192. private _createSSAOPostProcess;
  56193. private _createSSAOCombinePostProcess;
  56194. private _createRandomTexture;
  56195. }
  56196. }
  56197. declare module "babylonjs/Shaders/standard.fragment" {
  56198. /** @hidden */
  56199. export var standardPixelShader: {
  56200. name: string;
  56201. shader: string;
  56202. };
  56203. }
  56204. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  56205. import { Nullable } from "babylonjs/types";
  56206. import { IAnimatable } from "babylonjs/Misc/tools";
  56207. import { Camera } from "babylonjs/Cameras/camera";
  56208. import { Texture } from "babylonjs/Materials/Textures/texture";
  56209. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  56210. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  56211. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  56212. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  56213. import { IDisposable } from "babylonjs/scene";
  56214. import { SpotLight } from "babylonjs/Lights/spotLight";
  56215. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  56216. import { Scene } from "babylonjs/scene";
  56217. import { Animation } from "babylonjs/Animations/animation";
  56218. import "babylonjs/Shaders/standard.fragment";
  56219. /**
  56220. * Standard rendering pipeline
  56221. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  56222. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  56223. */
  56224. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  56225. /**
  56226. * Public members
  56227. */
  56228. /**
  56229. * Post-process which contains the original scene color before the pipeline applies all the effects
  56230. */
  56231. originalPostProcess: Nullable<PostProcess>;
  56232. /**
  56233. * Post-process used to down scale an image x4
  56234. */
  56235. downSampleX4PostProcess: Nullable<PostProcess>;
  56236. /**
  56237. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  56238. */
  56239. brightPassPostProcess: Nullable<PostProcess>;
  56240. /**
  56241. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  56242. */
  56243. blurHPostProcesses: PostProcess[];
  56244. /**
  56245. * Post-process array storing all the vertical blur post-processes used by the pipeline
  56246. */
  56247. blurVPostProcesses: PostProcess[];
  56248. /**
  56249. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  56250. */
  56251. textureAdderPostProcess: Nullable<PostProcess>;
  56252. /**
  56253. * Post-process used to create volumetric lighting effect
  56254. */
  56255. volumetricLightPostProcess: Nullable<PostProcess>;
  56256. /**
  56257. * Post-process used to smooth the previous volumetric light post-process on the X axis
  56258. */
  56259. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  56260. /**
  56261. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  56262. */
  56263. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  56264. /**
  56265. * Post-process used to merge the volumetric light effect and the real scene color
  56266. */
  56267. volumetricLightMergePostProces: Nullable<PostProcess>;
  56268. /**
  56269. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  56270. */
  56271. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  56272. /**
  56273. * Base post-process used to calculate the average luminance of the final image for HDR
  56274. */
  56275. luminancePostProcess: Nullable<PostProcess>;
  56276. /**
  56277. * Post-processes used to create down sample post-processes in order to get
  56278. * the average luminance of the final image for HDR
  56279. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  56280. */
  56281. luminanceDownSamplePostProcesses: PostProcess[];
  56282. /**
  56283. * Post-process used to create a HDR effect (light adaptation)
  56284. */
  56285. hdrPostProcess: Nullable<PostProcess>;
  56286. /**
  56287. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  56288. */
  56289. textureAdderFinalPostProcess: Nullable<PostProcess>;
  56290. /**
  56291. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  56292. */
  56293. lensFlareFinalPostProcess: Nullable<PostProcess>;
  56294. /**
  56295. * Post-process used to merge the final HDR post-process and the real scene color
  56296. */
  56297. hdrFinalPostProcess: Nullable<PostProcess>;
  56298. /**
  56299. * Post-process used to create a lens flare effect
  56300. */
  56301. lensFlarePostProcess: Nullable<PostProcess>;
  56302. /**
  56303. * Post-process that merges the result of the lens flare post-process and the real scene color
  56304. */
  56305. lensFlareComposePostProcess: Nullable<PostProcess>;
  56306. /**
  56307. * Post-process used to create a motion blur effect
  56308. */
  56309. motionBlurPostProcess: Nullable<PostProcess>;
  56310. /**
  56311. * Post-process used to create a depth of field effect
  56312. */
  56313. depthOfFieldPostProcess: Nullable<PostProcess>;
  56314. /**
  56315. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  56316. */
  56317. fxaaPostProcess: Nullable<FxaaPostProcess>;
  56318. /**
  56319. * Represents the brightness threshold in order to configure the illuminated surfaces
  56320. */
  56321. brightThreshold: number;
  56322. /**
  56323. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  56324. */
  56325. blurWidth: number;
  56326. /**
  56327. * Sets if the blur for highlighted surfaces must be only horizontal
  56328. */
  56329. horizontalBlur: boolean;
  56330. /**
  56331. * Gets the overall exposure used by the pipeline
  56332. */
  56333. /**
  56334. * Sets the overall exposure used by the pipeline
  56335. */
  56336. exposure: number;
  56337. /**
  56338. * Texture used typically to simulate "dirty" on camera lens
  56339. */
  56340. lensTexture: Nullable<Texture>;
  56341. /**
  56342. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  56343. */
  56344. volumetricLightCoefficient: number;
  56345. /**
  56346. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  56347. */
  56348. volumetricLightPower: number;
  56349. /**
  56350. * Used the set the blur intensity to smooth the volumetric lights
  56351. */
  56352. volumetricLightBlurScale: number;
  56353. /**
  56354. * Light (spot or directional) used to generate the volumetric lights rays
  56355. * The source light must have a shadow generate so the pipeline can get its
  56356. * depth map
  56357. */
  56358. sourceLight: Nullable<SpotLight | DirectionalLight>;
  56359. /**
  56360. * For eye adaptation, represents the minimum luminance the eye can see
  56361. */
  56362. hdrMinimumLuminance: number;
  56363. /**
  56364. * For eye adaptation, represents the decrease luminance speed
  56365. */
  56366. hdrDecreaseRate: number;
  56367. /**
  56368. * For eye adaptation, represents the increase luminance speed
  56369. */
  56370. hdrIncreaseRate: number;
  56371. /**
  56372. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  56373. */
  56374. /**
  56375. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  56376. */
  56377. hdrAutoExposure: boolean;
  56378. /**
  56379. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  56380. */
  56381. lensColorTexture: Nullable<Texture>;
  56382. /**
  56383. * The overall strengh for the lens flare effect
  56384. */
  56385. lensFlareStrength: number;
  56386. /**
  56387. * Dispersion coefficient for lens flare ghosts
  56388. */
  56389. lensFlareGhostDispersal: number;
  56390. /**
  56391. * Main lens flare halo width
  56392. */
  56393. lensFlareHaloWidth: number;
  56394. /**
  56395. * Based on the lens distortion effect, defines how much the lens flare result
  56396. * is distorted
  56397. */
  56398. lensFlareDistortionStrength: number;
  56399. /**
  56400. * Lens star texture must be used to simulate rays on the flares and is available
  56401. * in the documentation
  56402. */
  56403. lensStarTexture: Nullable<Texture>;
  56404. /**
  56405. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  56406. * flare effect by taking account of the dirt texture
  56407. */
  56408. lensFlareDirtTexture: Nullable<Texture>;
  56409. /**
  56410. * Represents the focal length for the depth of field effect
  56411. */
  56412. depthOfFieldDistance: number;
  56413. /**
  56414. * Represents the blur intensity for the blurred part of the depth of field effect
  56415. */
  56416. depthOfFieldBlurWidth: number;
  56417. /**
  56418. * For motion blur, defines how much the image is blurred by the movement
  56419. */
  56420. motionStrength: number;
  56421. /**
  56422. * List of animations for the pipeline (IAnimatable implementation)
  56423. */
  56424. animations: Animation[];
  56425. /**
  56426. * Private members
  56427. */
  56428. private _scene;
  56429. private _currentDepthOfFieldSource;
  56430. private _basePostProcess;
  56431. private _fixedExposure;
  56432. private _currentExposure;
  56433. private _hdrAutoExposure;
  56434. private _hdrCurrentLuminance;
  56435. private _floatTextureType;
  56436. private _ratio;
  56437. private _bloomEnabled;
  56438. private _depthOfFieldEnabled;
  56439. private _vlsEnabled;
  56440. private _lensFlareEnabled;
  56441. private _hdrEnabled;
  56442. private _motionBlurEnabled;
  56443. private _fxaaEnabled;
  56444. private _motionBlurSamples;
  56445. private _volumetricLightStepsCount;
  56446. private _samples;
  56447. /**
  56448. * @ignore
  56449. * Specifies if the bloom pipeline is enabled
  56450. */
  56451. BloomEnabled: boolean;
  56452. /**
  56453. * @ignore
  56454. * Specifies if the depth of field pipeline is enabed
  56455. */
  56456. DepthOfFieldEnabled: boolean;
  56457. /**
  56458. * @ignore
  56459. * Specifies if the lens flare pipeline is enabed
  56460. */
  56461. LensFlareEnabled: boolean;
  56462. /**
  56463. * @ignore
  56464. * Specifies if the HDR pipeline is enabled
  56465. */
  56466. HDREnabled: boolean;
  56467. /**
  56468. * @ignore
  56469. * Specifies if the volumetric lights scattering effect is enabled
  56470. */
  56471. VLSEnabled: boolean;
  56472. /**
  56473. * @ignore
  56474. * Specifies if the motion blur effect is enabled
  56475. */
  56476. MotionBlurEnabled: boolean;
  56477. /**
  56478. * Specifies if anti-aliasing is enabled
  56479. */
  56480. fxaaEnabled: boolean;
  56481. /**
  56482. * Specifies the number of steps used to calculate the volumetric lights
  56483. * Typically in interval [50, 200]
  56484. */
  56485. volumetricLightStepsCount: number;
  56486. /**
  56487. * Specifies the number of samples used for the motion blur effect
  56488. * Typically in interval [16, 64]
  56489. */
  56490. motionBlurSamples: number;
  56491. /**
  56492. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  56493. */
  56494. samples: number;
  56495. /**
  56496. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  56497. * @constructor
  56498. * @param name The rendering pipeline name
  56499. * @param scene The scene linked to this pipeline
  56500. * @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)
  56501. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  56502. * @param cameras The array of cameras that the rendering pipeline will be attached to
  56503. */
  56504. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  56505. private _buildPipeline;
  56506. private _createDownSampleX4PostProcess;
  56507. private _createBrightPassPostProcess;
  56508. private _createBlurPostProcesses;
  56509. private _createTextureAdderPostProcess;
  56510. private _createVolumetricLightPostProcess;
  56511. private _createLuminancePostProcesses;
  56512. private _createHdrPostProcess;
  56513. private _createLensFlarePostProcess;
  56514. private _createDepthOfFieldPostProcess;
  56515. private _createMotionBlurPostProcess;
  56516. private _getDepthTexture;
  56517. private _disposePostProcesses;
  56518. /**
  56519. * Dispose of the pipeline and stop all post processes
  56520. */
  56521. dispose(): void;
  56522. /**
  56523. * Serialize the rendering pipeline (Used when exporting)
  56524. * @returns the serialized object
  56525. */
  56526. serialize(): any;
  56527. /**
  56528. * Parse the serialized pipeline
  56529. * @param source Source pipeline.
  56530. * @param scene The scene to load the pipeline to.
  56531. * @param rootUrl The URL of the serialized pipeline.
  56532. * @returns An instantiated pipeline from the serialized object.
  56533. */
  56534. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  56535. /**
  56536. * Luminance steps
  56537. */
  56538. static LuminanceSteps: number;
  56539. }
  56540. }
  56541. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  56542. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  56543. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  56544. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  56545. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  56546. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  56547. }
  56548. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  56549. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  56550. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  56551. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  56552. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  56553. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  56554. }
  56555. declare module "babylonjs/Shaders/tonemap.fragment" {
  56556. /** @hidden */
  56557. export var tonemapPixelShader: {
  56558. name: string;
  56559. shader: string;
  56560. };
  56561. }
  56562. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  56563. import { Camera } from "babylonjs/Cameras/camera";
  56564. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  56565. import "babylonjs/Shaders/tonemap.fragment";
  56566. import { Engine } from "babylonjs/Engines/engine";
  56567. /** Defines operator used for tonemapping */
  56568. export enum TonemappingOperator {
  56569. /** Hable */
  56570. Hable = 0,
  56571. /** Reinhard */
  56572. Reinhard = 1,
  56573. /** HejiDawson */
  56574. HejiDawson = 2,
  56575. /** Photographic */
  56576. Photographic = 3
  56577. }
  56578. /**
  56579. * Defines a post process to apply tone mapping
  56580. */
  56581. export class TonemapPostProcess extends PostProcess {
  56582. private _operator;
  56583. /** Defines the required exposure adjustement */
  56584. exposureAdjustment: number;
  56585. /**
  56586. * Creates a new TonemapPostProcess
  56587. * @param name defines the name of the postprocess
  56588. * @param _operator defines the operator to use
  56589. * @param exposureAdjustment defines the required exposure adjustement
  56590. * @param camera defines the camera to use (can be null)
  56591. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  56592. * @param engine defines the hosting engine (can be ignore if camera is set)
  56593. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  56594. */
  56595. constructor(name: string, _operator: TonemappingOperator,
  56596. /** Defines the required exposure adjustement */
  56597. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  56598. }
  56599. }
  56600. declare module "babylonjs/Shaders/depth.vertex" {
  56601. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  56602. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  56603. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  56604. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  56605. /** @hidden */
  56606. export var depthVertexShader: {
  56607. name: string;
  56608. shader: string;
  56609. };
  56610. }
  56611. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  56612. /** @hidden */
  56613. export var volumetricLightScatteringPixelShader: {
  56614. name: string;
  56615. shader: string;
  56616. };
  56617. }
  56618. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  56619. /** @hidden */
  56620. export var volumetricLightScatteringPassPixelShader: {
  56621. name: string;
  56622. shader: string;
  56623. };
  56624. }
  56625. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  56626. import { Vector3 } from "babylonjs/Maths/math";
  56627. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56628. import { Mesh } from "babylonjs/Meshes/mesh";
  56629. import { Camera } from "babylonjs/Cameras/camera";
  56630. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  56631. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  56632. import { Scene } from "babylonjs/scene";
  56633. import "babylonjs/Meshes/Builders/planeBuilder";
  56634. import "babylonjs/Shaders/depth.vertex";
  56635. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  56636. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  56637. import { Engine } from "babylonjs/Engines/engine";
  56638. /**
  56639. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  56640. */
  56641. export class VolumetricLightScatteringPostProcess extends PostProcess {
  56642. private _volumetricLightScatteringPass;
  56643. private _volumetricLightScatteringRTT;
  56644. private _viewPort;
  56645. private _screenCoordinates;
  56646. private _cachedDefines;
  56647. /**
  56648. * If not undefined, the mesh position is computed from the attached node position
  56649. */
  56650. attachedNode: {
  56651. position: Vector3;
  56652. };
  56653. /**
  56654. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  56655. */
  56656. customMeshPosition: Vector3;
  56657. /**
  56658. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  56659. */
  56660. useCustomMeshPosition: boolean;
  56661. /**
  56662. * If the post-process should inverse the light scattering direction
  56663. */
  56664. invert: boolean;
  56665. /**
  56666. * The internal mesh used by the post-process
  56667. */
  56668. mesh: Mesh;
  56669. /**
  56670. * @hidden
  56671. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  56672. */
  56673. useDiffuseColor: boolean;
  56674. /**
  56675. * Array containing the excluded meshes not rendered in the internal pass
  56676. */
  56677. excludedMeshes: AbstractMesh[];
  56678. /**
  56679. * Controls the overall intensity of the post-process
  56680. */
  56681. exposure: number;
  56682. /**
  56683. * Dissipates each sample's contribution in range [0, 1]
  56684. */
  56685. decay: number;
  56686. /**
  56687. * Controls the overall intensity of each sample
  56688. */
  56689. weight: number;
  56690. /**
  56691. * Controls the density of each sample
  56692. */
  56693. density: number;
  56694. /**
  56695. * @constructor
  56696. * @param name The post-process name
  56697. * @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)
  56698. * @param camera The camera that the post-process will be attached to
  56699. * @param mesh The mesh used to create the light scattering
  56700. * @param samples The post-process quality, default 100
  56701. * @param samplingModeThe post-process filtering mode
  56702. * @param engine The babylon engine
  56703. * @param reusable If the post-process is reusable
  56704. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  56705. */
  56706. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  56707. /**
  56708. * Returns the string "VolumetricLightScatteringPostProcess"
  56709. * @returns "VolumetricLightScatteringPostProcess"
  56710. */
  56711. getClassName(): string;
  56712. private _isReady;
  56713. /**
  56714. * Sets the new light position for light scattering effect
  56715. * @param position The new custom light position
  56716. */
  56717. setCustomMeshPosition(position: Vector3): void;
  56718. /**
  56719. * Returns the light position for light scattering effect
  56720. * @return Vector3 The custom light position
  56721. */
  56722. getCustomMeshPosition(): Vector3;
  56723. /**
  56724. * Disposes the internal assets and detaches the post-process from the camera
  56725. */
  56726. dispose(camera: Camera): void;
  56727. /**
  56728. * Returns the render target texture used by the post-process
  56729. * @return the render target texture used by the post-process
  56730. */
  56731. getPass(): RenderTargetTexture;
  56732. private _meshExcluded;
  56733. private _createPass;
  56734. private _updateMeshScreenCoordinates;
  56735. /**
  56736. * Creates a default mesh for the Volumeric Light Scattering post-process
  56737. * @param name The mesh name
  56738. * @param scene The scene where to create the mesh
  56739. * @return the default mesh
  56740. */
  56741. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  56742. }
  56743. }
  56744. declare module "babylonjs/PostProcesses/index" {
  56745. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  56746. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  56747. export * from "babylonjs/PostProcesses/bloomEffect";
  56748. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  56749. export * from "babylonjs/PostProcesses/blurPostProcess";
  56750. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  56751. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  56752. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  56753. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  56754. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  56755. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  56756. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  56757. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  56758. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  56759. export * from "babylonjs/PostProcesses/filterPostProcess";
  56760. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  56761. export * from "babylonjs/PostProcesses/grainPostProcess";
  56762. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  56763. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  56764. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  56765. export * from "babylonjs/PostProcesses/passPostProcess";
  56766. export * from "babylonjs/PostProcesses/postProcess";
  56767. export * from "babylonjs/PostProcesses/postProcessManager";
  56768. export * from "babylonjs/PostProcesses/refractionPostProcess";
  56769. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  56770. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  56771. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  56772. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  56773. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  56774. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  56775. export * from "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess";
  56776. }
  56777. declare module "babylonjs/Probes/index" {
  56778. export * from "babylonjs/Probes/reflectionProbe";
  56779. }
  56780. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  56781. import { Scene } from "babylonjs/scene";
  56782. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56783. import { Color3 } from "babylonjs/Maths/math";
  56784. import { SmartArray } from "babylonjs/Misc/smartArray";
  56785. import { ISceneComponent } from "babylonjs/sceneComponent";
  56786. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  56787. import "babylonjs/Meshes/Builders/boxBuilder";
  56788. import "babylonjs/Shaders/color.fragment";
  56789. import "babylonjs/Shaders/color.vertex";
  56790. module "babylonjs/scene" {
  56791. interface Scene {
  56792. /** @hidden (Backing field) */
  56793. _boundingBoxRenderer: BoundingBoxRenderer;
  56794. /** @hidden (Backing field) */
  56795. _forceShowBoundingBoxes: boolean;
  56796. /**
  56797. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  56798. */
  56799. forceShowBoundingBoxes: boolean;
  56800. /**
  56801. * Gets the bounding box renderer associated with the scene
  56802. * @returns a BoundingBoxRenderer
  56803. */
  56804. getBoundingBoxRenderer(): BoundingBoxRenderer;
  56805. }
  56806. }
  56807. module "babylonjs/Meshes/abstractMesh" {
  56808. interface AbstractMesh {
  56809. /** @hidden (Backing field) */
  56810. _showBoundingBox: boolean;
  56811. /**
  56812. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  56813. */
  56814. showBoundingBox: boolean;
  56815. }
  56816. }
  56817. /**
  56818. * Component responsible of rendering the bounding box of the meshes in a scene.
  56819. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  56820. */
  56821. export class BoundingBoxRenderer implements ISceneComponent {
  56822. /**
  56823. * The component name helpfull to identify the component in the list of scene components.
  56824. */
  56825. readonly name: string;
  56826. /**
  56827. * The scene the component belongs to.
  56828. */
  56829. scene: Scene;
  56830. /**
  56831. * Color of the bounding box lines placed in front of an object
  56832. */
  56833. frontColor: Color3;
  56834. /**
  56835. * Color of the bounding box lines placed behind an object
  56836. */
  56837. backColor: Color3;
  56838. /**
  56839. * Defines if the renderer should show the back lines or not
  56840. */
  56841. showBackLines: boolean;
  56842. /**
  56843. * @hidden
  56844. */
  56845. renderList: SmartArray<BoundingBox>;
  56846. private _colorShader;
  56847. private _vertexBuffers;
  56848. private _indexBuffer;
  56849. /**
  56850. * Instantiates a new bounding box renderer in a scene.
  56851. * @param scene the scene the renderer renders in
  56852. */
  56853. constructor(scene: Scene);
  56854. /**
  56855. * Registers the component in a given scene
  56856. */
  56857. register(): void;
  56858. private _evaluateSubMesh;
  56859. private _activeMesh;
  56860. private _prepareRessources;
  56861. private _createIndexBuffer;
  56862. /**
  56863. * Rebuilds the elements related to this component in case of
  56864. * context lost for instance.
  56865. */
  56866. rebuild(): void;
  56867. /**
  56868. * @hidden
  56869. */
  56870. reset(): void;
  56871. /**
  56872. * Render the bounding boxes of a specific rendering group
  56873. * @param renderingGroupId defines the rendering group to render
  56874. */
  56875. render(renderingGroupId: number): void;
  56876. /**
  56877. * In case of occlusion queries, we can render the occlusion bounding box through this method
  56878. * @param mesh Define the mesh to render the occlusion bounding box for
  56879. */
  56880. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  56881. /**
  56882. * Dispose and release the resources attached to this renderer.
  56883. */
  56884. dispose(): void;
  56885. }
  56886. }
  56887. declare module "babylonjs/Shaders/depth.fragment" {
  56888. /** @hidden */
  56889. export var depthPixelShader: {
  56890. name: string;
  56891. shader: string;
  56892. };
  56893. }
  56894. declare module "babylonjs/Rendering/depthRenderer" {
  56895. import { Nullable } from "babylonjs/types";
  56896. import { SubMesh } from "babylonjs/Meshes/subMesh";
  56897. import { Scene } from "babylonjs/scene";
  56898. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  56899. import { Camera } from "babylonjs/Cameras/camera";
  56900. import "babylonjs/Shaders/depth.fragment";
  56901. import "babylonjs/Shaders/depth.vertex";
  56902. /**
  56903. * This represents a depth renderer in Babylon.
  56904. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  56905. */
  56906. export class DepthRenderer {
  56907. private _scene;
  56908. private _depthMap;
  56909. private _effect;
  56910. private _cachedDefines;
  56911. private _camera;
  56912. /**
  56913. * Specifiess that the depth renderer will only be used within
  56914. * the camera it is created for.
  56915. * This can help forcing its rendering during the camera processing.
  56916. */
  56917. useOnlyInActiveCamera: boolean;
  56918. /** @hidden */
  56919. static _SceneComponentInitialization: (scene: Scene) => void;
  56920. /**
  56921. * Instantiates a depth renderer
  56922. * @param scene The scene the renderer belongs to
  56923. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  56924. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  56925. */
  56926. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  56927. /**
  56928. * Creates the depth rendering effect and checks if the effect is ready.
  56929. * @param subMesh The submesh to be used to render the depth map of
  56930. * @param useInstances If multiple world instances should be used
  56931. * @returns if the depth renderer is ready to render the depth map
  56932. */
  56933. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  56934. /**
  56935. * Gets the texture which the depth map will be written to.
  56936. * @returns The depth map texture
  56937. */
  56938. getDepthMap(): RenderTargetTexture;
  56939. /**
  56940. * Disposes of the depth renderer.
  56941. */
  56942. dispose(): void;
  56943. }
  56944. }
  56945. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  56946. import { Nullable } from "babylonjs/types";
  56947. import { Scene } from "babylonjs/scene";
  56948. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  56949. import { Camera } from "babylonjs/Cameras/camera";
  56950. import { ISceneComponent } from "babylonjs/sceneComponent";
  56951. module "babylonjs/scene" {
  56952. interface Scene {
  56953. /** @hidden (Backing field) */
  56954. _depthRenderer: {
  56955. [id: string]: DepthRenderer;
  56956. };
  56957. /**
  56958. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  56959. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  56960. * @returns the created depth renderer
  56961. */
  56962. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  56963. /**
  56964. * Disables a depth renderer for a given camera
  56965. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  56966. */
  56967. disableDepthRenderer(camera?: Nullable<Camera>): void;
  56968. }
  56969. }
  56970. /**
  56971. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  56972. * in several rendering techniques.
  56973. */
  56974. export class DepthRendererSceneComponent implements ISceneComponent {
  56975. /**
  56976. * The component name helpfull to identify the component in the list of scene components.
  56977. */
  56978. readonly name: string;
  56979. /**
  56980. * The scene the component belongs to.
  56981. */
  56982. scene: Scene;
  56983. /**
  56984. * Creates a new instance of the component for the given scene
  56985. * @param scene Defines the scene to register the component in
  56986. */
  56987. constructor(scene: Scene);
  56988. /**
  56989. * Registers the component in a given scene
  56990. */
  56991. register(): void;
  56992. /**
  56993. * Rebuilds the elements related to this component in case of
  56994. * context lost for instance.
  56995. */
  56996. rebuild(): void;
  56997. /**
  56998. * Disposes the component and the associated ressources
  56999. */
  57000. dispose(): void;
  57001. private _gatherRenderTargets;
  57002. private _gatherActiveCameraRenderTargets;
  57003. }
  57004. }
  57005. declare module "babylonjs/Shaders/outline.fragment" {
  57006. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  57007. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  57008. /** @hidden */
  57009. export var outlinePixelShader: {
  57010. name: string;
  57011. shader: string;
  57012. };
  57013. }
  57014. declare module "babylonjs/Shaders/outline.vertex" {
  57015. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  57016. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  57017. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  57018. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  57019. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  57020. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  57021. /** @hidden */
  57022. export var outlineVertexShader: {
  57023. name: string;
  57024. shader: string;
  57025. };
  57026. }
  57027. declare module "babylonjs/Rendering/outlineRenderer" {
  57028. import { SubMesh } from "babylonjs/Meshes/subMesh";
  57029. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  57030. import { Scene } from "babylonjs/scene";
  57031. import { ISceneComponent } from "babylonjs/sceneComponent";
  57032. import "babylonjs/Shaders/outline.fragment";
  57033. import "babylonjs/Shaders/outline.vertex";
  57034. module "babylonjs/scene" {
  57035. interface Scene {
  57036. /** @hidden */
  57037. _outlineRenderer: OutlineRenderer;
  57038. /**
  57039. * Gets the outline renderer associated with the scene
  57040. * @returns a OutlineRenderer
  57041. */
  57042. getOutlineRenderer(): OutlineRenderer;
  57043. }
  57044. }
  57045. module "babylonjs/Meshes/abstractMesh" {
  57046. interface AbstractMesh {
  57047. /** @hidden (Backing field) */
  57048. _renderOutline: boolean;
  57049. /**
  57050. * Gets or sets a boolean indicating if the outline must be rendered as well
  57051. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  57052. */
  57053. renderOutline: boolean;
  57054. /** @hidden (Backing field) */
  57055. _renderOverlay: boolean;
  57056. /**
  57057. * Gets or sets a boolean indicating if the overlay must be rendered as well
  57058. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  57059. */
  57060. renderOverlay: boolean;
  57061. }
  57062. }
  57063. /**
  57064. * This class is responsible to draw bothe outline/overlay of meshes.
  57065. * It should not be used directly but through the available method on mesh.
  57066. */
  57067. export class OutlineRenderer implements ISceneComponent {
  57068. /**
  57069. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  57070. */
  57071. private static _StencilReference;
  57072. /**
  57073. * The name of the component. Each component must have a unique name.
  57074. */
  57075. name: string;
  57076. /**
  57077. * The scene the component belongs to.
  57078. */
  57079. scene: Scene;
  57080. /**
  57081. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  57082. */
  57083. zOffset: number;
  57084. private _engine;
  57085. private _effect;
  57086. private _cachedDefines;
  57087. private _savedDepthWrite;
  57088. /**
  57089. * Instantiates a new outline renderer. (There could be only one per scene).
  57090. * @param scene Defines the scene it belongs to
  57091. */
  57092. constructor(scene: Scene);
  57093. /**
  57094. * Register the component to one instance of a scene.
  57095. */
  57096. register(): void;
  57097. /**
  57098. * Rebuilds the elements related to this component in case of
  57099. * context lost for instance.
  57100. */
  57101. rebuild(): void;
  57102. /**
  57103. * Disposes the component and the associated ressources.
  57104. */
  57105. dispose(): void;
  57106. /**
  57107. * Renders the outline in the canvas.
  57108. * @param subMesh Defines the sumesh to render
  57109. * @param batch Defines the batch of meshes in case of instances
  57110. * @param useOverlay Defines if the rendering is for the overlay or the outline
  57111. */
  57112. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  57113. /**
  57114. * Returns whether or not the outline renderer is ready for a given submesh.
  57115. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  57116. * @param subMesh Defines the submesh to check readyness for
  57117. * @param useInstances Defines wheter wee are trying to render instances or not
  57118. * @returns true if ready otherwise false
  57119. */
  57120. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  57121. private _beforeRenderingMesh;
  57122. private _afterRenderingMesh;
  57123. }
  57124. }
  57125. declare module "babylonjs/Rendering/index" {
  57126. export * from "babylonjs/Rendering/boundingBoxRenderer";
  57127. export * from "babylonjs/Rendering/depthRenderer";
  57128. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  57129. export * from "babylonjs/Rendering/edgesRenderer";
  57130. export * from "babylonjs/Rendering/geometryBufferRenderer";
  57131. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  57132. export * from "babylonjs/Rendering/outlineRenderer";
  57133. export * from "babylonjs/Rendering/renderingGroup";
  57134. export * from "babylonjs/Rendering/renderingManager";
  57135. export * from "babylonjs/Rendering/utilityLayerRenderer";
  57136. }
  57137. declare module "babylonjs/Sprites/index" {
  57138. export * from "babylonjs/Sprites/sprite";
  57139. export * from "babylonjs/Sprites/spriteManager";
  57140. export * from "babylonjs/Sprites/spriteSceneComponent";
  57141. }
  57142. declare module "babylonjs/Misc/assetsManager" {
  57143. import { Scene } from "babylonjs/scene";
  57144. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57145. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  57146. import { Skeleton } from "babylonjs/Bones/skeleton";
  57147. import { Observable } from "babylonjs/Misc/observable";
  57148. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  57149. import { Texture } from "babylonjs/Materials/Textures/texture";
  57150. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  57151. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  57152. import { EquiRectangularCubeTexture } from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  57153. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  57154. /**
  57155. * Defines the list of states available for a task inside a AssetsManager
  57156. */
  57157. export enum AssetTaskState {
  57158. /**
  57159. * Initialization
  57160. */
  57161. INIT = 0,
  57162. /**
  57163. * Running
  57164. */
  57165. RUNNING = 1,
  57166. /**
  57167. * Done
  57168. */
  57169. DONE = 2,
  57170. /**
  57171. * Error
  57172. */
  57173. ERROR = 3
  57174. }
  57175. /**
  57176. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  57177. */
  57178. export abstract class AbstractAssetTask {
  57179. /**
  57180. * Task name
  57181. */ name: string;
  57182. /**
  57183. * Callback called when the task is successful
  57184. */
  57185. onSuccess: (task: any) => void;
  57186. /**
  57187. * Callback called when the task is not successful
  57188. */
  57189. onError: (task: any, message?: string, exception?: any) => void;
  57190. /**
  57191. * Creates a new AssetsManager
  57192. * @param name defines the name of the task
  57193. */
  57194. constructor(
  57195. /**
  57196. * Task name
  57197. */ name: string);
  57198. private _isCompleted;
  57199. private _taskState;
  57200. private _errorObject;
  57201. /**
  57202. * Get if the task is completed
  57203. */
  57204. readonly isCompleted: boolean;
  57205. /**
  57206. * Gets the current state of the task
  57207. */
  57208. readonly taskState: AssetTaskState;
  57209. /**
  57210. * Gets the current error object (if task is in error)
  57211. */
  57212. readonly errorObject: {
  57213. message?: string;
  57214. exception?: any;
  57215. };
  57216. /**
  57217. * Internal only
  57218. * @hidden
  57219. */
  57220. _setErrorObject(message?: string, exception?: any): void;
  57221. /**
  57222. * Execute the current task
  57223. * @param scene defines the scene where you want your assets to be loaded
  57224. * @param onSuccess is a callback called when the task is successfully executed
  57225. * @param onError is a callback called if an error occurs
  57226. */
  57227. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57228. /**
  57229. * Execute the current task
  57230. * @param scene defines the scene where you want your assets to be loaded
  57231. * @param onSuccess is a callback called when the task is successfully executed
  57232. * @param onError is a callback called if an error occurs
  57233. */
  57234. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57235. /**
  57236. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  57237. * This can be used with failed tasks that have the reason for failure fixed.
  57238. */
  57239. reset(): void;
  57240. private onErrorCallback;
  57241. private onDoneCallback;
  57242. }
  57243. /**
  57244. * Define the interface used by progress events raised during assets loading
  57245. */
  57246. export interface IAssetsProgressEvent {
  57247. /**
  57248. * Defines the number of remaining tasks to process
  57249. */
  57250. remainingCount: number;
  57251. /**
  57252. * Defines the total number of tasks
  57253. */
  57254. totalCount: number;
  57255. /**
  57256. * Defines the task that was just processed
  57257. */
  57258. task: AbstractAssetTask;
  57259. }
  57260. /**
  57261. * Class used to share progress information about assets loading
  57262. */
  57263. export class AssetsProgressEvent implements IAssetsProgressEvent {
  57264. /**
  57265. * Defines the number of remaining tasks to process
  57266. */
  57267. remainingCount: number;
  57268. /**
  57269. * Defines the total number of tasks
  57270. */
  57271. totalCount: number;
  57272. /**
  57273. * Defines the task that was just processed
  57274. */
  57275. task: AbstractAssetTask;
  57276. /**
  57277. * Creates a AssetsProgressEvent
  57278. * @param remainingCount defines the number of remaining tasks to process
  57279. * @param totalCount defines the total number of tasks
  57280. * @param task defines the task that was just processed
  57281. */
  57282. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  57283. }
  57284. /**
  57285. * Define a task used by AssetsManager to load meshes
  57286. */
  57287. export class MeshAssetTask extends AbstractAssetTask {
  57288. /**
  57289. * Defines the name of the task
  57290. */
  57291. name: string;
  57292. /**
  57293. * Defines the list of mesh's names you want to load
  57294. */
  57295. meshesNames: any;
  57296. /**
  57297. * Defines the root url to use as a base to load your meshes and associated resources
  57298. */
  57299. rootUrl: string;
  57300. /**
  57301. * Defines the filename of the scene to load from
  57302. */
  57303. sceneFilename: string;
  57304. /**
  57305. * Gets the list of loaded meshes
  57306. */
  57307. loadedMeshes: Array<AbstractMesh>;
  57308. /**
  57309. * Gets the list of loaded particle systems
  57310. */
  57311. loadedParticleSystems: Array<IParticleSystem>;
  57312. /**
  57313. * Gets the list of loaded skeletons
  57314. */
  57315. loadedSkeletons: Array<Skeleton>;
  57316. /**
  57317. * Gets the list of loaded animation groups
  57318. */
  57319. loadedAnimationGroups: Array<AnimationGroup>;
  57320. /**
  57321. * Callback called when the task is successful
  57322. */
  57323. onSuccess: (task: MeshAssetTask) => void;
  57324. /**
  57325. * Callback called when the task is successful
  57326. */
  57327. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  57328. /**
  57329. * Creates a new MeshAssetTask
  57330. * @param name defines the name of the task
  57331. * @param meshesNames defines the list of mesh's names you want to load
  57332. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  57333. * @param sceneFilename defines the filename of the scene to load from
  57334. */
  57335. constructor(
  57336. /**
  57337. * Defines the name of the task
  57338. */
  57339. name: string,
  57340. /**
  57341. * Defines the list of mesh's names you want to load
  57342. */
  57343. meshesNames: any,
  57344. /**
  57345. * Defines the root url to use as a base to load your meshes and associated resources
  57346. */
  57347. rootUrl: string,
  57348. /**
  57349. * Defines the filename of the scene to load from
  57350. */
  57351. sceneFilename: string);
  57352. /**
  57353. * Execute the current task
  57354. * @param scene defines the scene where you want your assets to be loaded
  57355. * @param onSuccess is a callback called when the task is successfully executed
  57356. * @param onError is a callback called if an error occurs
  57357. */
  57358. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57359. }
  57360. /**
  57361. * Define a task used by AssetsManager to load text content
  57362. */
  57363. export class TextFileAssetTask extends AbstractAssetTask {
  57364. /**
  57365. * Defines the name of the task
  57366. */
  57367. name: string;
  57368. /**
  57369. * Defines the location of the file to load
  57370. */
  57371. url: string;
  57372. /**
  57373. * Gets the loaded text string
  57374. */
  57375. text: string;
  57376. /**
  57377. * Callback called when the task is successful
  57378. */
  57379. onSuccess: (task: TextFileAssetTask) => void;
  57380. /**
  57381. * Callback called when the task is successful
  57382. */
  57383. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  57384. /**
  57385. * Creates a new TextFileAssetTask object
  57386. * @param name defines the name of the task
  57387. * @param url defines the location of the file to load
  57388. */
  57389. constructor(
  57390. /**
  57391. * Defines the name of the task
  57392. */
  57393. name: string,
  57394. /**
  57395. * Defines the location of the file to load
  57396. */
  57397. url: string);
  57398. /**
  57399. * Execute the current task
  57400. * @param scene defines the scene where you want your assets to be loaded
  57401. * @param onSuccess is a callback called when the task is successfully executed
  57402. * @param onError is a callback called if an error occurs
  57403. */
  57404. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57405. }
  57406. /**
  57407. * Define a task used by AssetsManager to load binary data
  57408. */
  57409. export class BinaryFileAssetTask extends AbstractAssetTask {
  57410. /**
  57411. * Defines the name of the task
  57412. */
  57413. name: string;
  57414. /**
  57415. * Defines the location of the file to load
  57416. */
  57417. url: string;
  57418. /**
  57419. * Gets the lodaded data (as an array buffer)
  57420. */
  57421. data: ArrayBuffer;
  57422. /**
  57423. * Callback called when the task is successful
  57424. */
  57425. onSuccess: (task: BinaryFileAssetTask) => void;
  57426. /**
  57427. * Callback called when the task is successful
  57428. */
  57429. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  57430. /**
  57431. * Creates a new BinaryFileAssetTask object
  57432. * @param name defines the name of the new task
  57433. * @param url defines the location of the file to load
  57434. */
  57435. constructor(
  57436. /**
  57437. * Defines the name of the task
  57438. */
  57439. name: string,
  57440. /**
  57441. * Defines the location of the file to load
  57442. */
  57443. url: string);
  57444. /**
  57445. * Execute the current task
  57446. * @param scene defines the scene where you want your assets to be loaded
  57447. * @param onSuccess is a callback called when the task is successfully executed
  57448. * @param onError is a callback called if an error occurs
  57449. */
  57450. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57451. }
  57452. /**
  57453. * Define a task used by AssetsManager to load images
  57454. */
  57455. export class ImageAssetTask extends AbstractAssetTask {
  57456. /**
  57457. * Defines the name of the task
  57458. */
  57459. name: string;
  57460. /**
  57461. * Defines the location of the image to load
  57462. */
  57463. url: string;
  57464. /**
  57465. * Gets the loaded images
  57466. */
  57467. image: HTMLImageElement;
  57468. /**
  57469. * Callback called when the task is successful
  57470. */
  57471. onSuccess: (task: ImageAssetTask) => void;
  57472. /**
  57473. * Callback called when the task is successful
  57474. */
  57475. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  57476. /**
  57477. * Creates a new ImageAssetTask
  57478. * @param name defines the name of the task
  57479. * @param url defines the location of the image to load
  57480. */
  57481. constructor(
  57482. /**
  57483. * Defines the name of the task
  57484. */
  57485. name: string,
  57486. /**
  57487. * Defines the location of the image to load
  57488. */
  57489. url: string);
  57490. /**
  57491. * Execute the current task
  57492. * @param scene defines the scene where you want your assets to be loaded
  57493. * @param onSuccess is a callback called when the task is successfully executed
  57494. * @param onError is a callback called if an error occurs
  57495. */
  57496. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57497. }
  57498. /**
  57499. * Defines the interface used by texture loading tasks
  57500. */
  57501. export interface ITextureAssetTask<TEX extends BaseTexture> {
  57502. /**
  57503. * Gets the loaded texture
  57504. */
  57505. texture: TEX;
  57506. }
  57507. /**
  57508. * Define a task used by AssetsManager to load 2D textures
  57509. */
  57510. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  57511. /**
  57512. * Defines the name of the task
  57513. */
  57514. name: string;
  57515. /**
  57516. * Defines the location of the file to load
  57517. */
  57518. url: string;
  57519. /**
  57520. * Defines if mipmap should not be generated (default is false)
  57521. */
  57522. noMipmap?: boolean | undefined;
  57523. /**
  57524. * Defines if texture must be inverted on Y axis (default is false)
  57525. */
  57526. invertY?: boolean | undefined;
  57527. /**
  57528. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  57529. */
  57530. samplingMode: number;
  57531. /**
  57532. * Gets the loaded texture
  57533. */
  57534. texture: Texture;
  57535. /**
  57536. * Callback called when the task is successful
  57537. */
  57538. onSuccess: (task: TextureAssetTask) => void;
  57539. /**
  57540. * Callback called when the task is successful
  57541. */
  57542. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  57543. /**
  57544. * Creates a new TextureAssetTask object
  57545. * @param name defines the name of the task
  57546. * @param url defines the location of the file to load
  57547. * @param noMipmap defines if mipmap should not be generated (default is false)
  57548. * @param invertY defines if texture must be inverted on Y axis (default is false)
  57549. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  57550. */
  57551. constructor(
  57552. /**
  57553. * Defines the name of the task
  57554. */
  57555. name: string,
  57556. /**
  57557. * Defines the location of the file to load
  57558. */
  57559. url: string,
  57560. /**
  57561. * Defines if mipmap should not be generated (default is false)
  57562. */
  57563. noMipmap?: boolean | undefined,
  57564. /**
  57565. * Defines if texture must be inverted on Y axis (default is false)
  57566. */
  57567. invertY?: boolean | undefined,
  57568. /**
  57569. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  57570. */
  57571. samplingMode?: number);
  57572. /**
  57573. * Execute the current task
  57574. * @param scene defines the scene where you want your assets to be loaded
  57575. * @param onSuccess is a callback called when the task is successfully executed
  57576. * @param onError is a callback called if an error occurs
  57577. */
  57578. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57579. }
  57580. /**
  57581. * Define a task used by AssetsManager to load cube textures
  57582. */
  57583. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  57584. /**
  57585. * Defines the name of the task
  57586. */
  57587. name: string;
  57588. /**
  57589. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  57590. */
  57591. url: string;
  57592. /**
  57593. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  57594. */
  57595. extensions?: string[] | undefined;
  57596. /**
  57597. * Defines if mipmaps should not be generated (default is false)
  57598. */
  57599. noMipmap?: boolean | undefined;
  57600. /**
  57601. * Defines the explicit list of files (undefined by default)
  57602. */
  57603. files?: string[] | undefined;
  57604. /**
  57605. * Gets the loaded texture
  57606. */
  57607. texture: CubeTexture;
  57608. /**
  57609. * Callback called when the task is successful
  57610. */
  57611. onSuccess: (task: CubeTextureAssetTask) => void;
  57612. /**
  57613. * Callback called when the task is successful
  57614. */
  57615. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  57616. /**
  57617. * Creates a new CubeTextureAssetTask
  57618. * @param name defines the name of the task
  57619. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  57620. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  57621. * @param noMipmap defines if mipmaps should not be generated (default is false)
  57622. * @param files defines the explicit list of files (undefined by default)
  57623. */
  57624. constructor(
  57625. /**
  57626. * Defines the name of the task
  57627. */
  57628. name: string,
  57629. /**
  57630. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  57631. */
  57632. url: string,
  57633. /**
  57634. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  57635. */
  57636. extensions?: string[] | undefined,
  57637. /**
  57638. * Defines if mipmaps should not be generated (default is false)
  57639. */
  57640. noMipmap?: boolean | undefined,
  57641. /**
  57642. * Defines the explicit list of files (undefined by default)
  57643. */
  57644. files?: string[] | undefined);
  57645. /**
  57646. * Execute the current task
  57647. * @param scene defines the scene where you want your assets to be loaded
  57648. * @param onSuccess is a callback called when the task is successfully executed
  57649. * @param onError is a callback called if an error occurs
  57650. */
  57651. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57652. }
  57653. /**
  57654. * Define a task used by AssetsManager to load HDR cube textures
  57655. */
  57656. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  57657. /**
  57658. * Defines the name of the task
  57659. */
  57660. name: string;
  57661. /**
  57662. * Defines the location of the file to load
  57663. */
  57664. url: string;
  57665. /**
  57666. * Defines the desired size (the more it increases the longer the generation will be)
  57667. */
  57668. size: number;
  57669. /**
  57670. * Defines if mipmaps should not be generated (default is false)
  57671. */
  57672. noMipmap: boolean;
  57673. /**
  57674. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  57675. */
  57676. generateHarmonics: boolean;
  57677. /**
  57678. * 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)
  57679. */
  57680. gammaSpace: boolean;
  57681. /**
  57682. * Internal Use Only
  57683. */
  57684. reserved: boolean;
  57685. /**
  57686. * Gets the loaded texture
  57687. */
  57688. texture: HDRCubeTexture;
  57689. /**
  57690. * Callback called when the task is successful
  57691. */
  57692. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  57693. /**
  57694. * Callback called when the task is successful
  57695. */
  57696. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  57697. /**
  57698. * Creates a new HDRCubeTextureAssetTask object
  57699. * @param name defines the name of the task
  57700. * @param url defines the location of the file to load
  57701. * @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.
  57702. * @param noMipmap defines if mipmaps should not be generated (default is false)
  57703. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  57704. * @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)
  57705. * @param reserved Internal use only
  57706. */
  57707. constructor(
  57708. /**
  57709. * Defines the name of the task
  57710. */
  57711. name: string,
  57712. /**
  57713. * Defines the location of the file to load
  57714. */
  57715. url: string,
  57716. /**
  57717. * Defines the desired size (the more it increases the longer the generation will be)
  57718. */
  57719. size: number,
  57720. /**
  57721. * Defines if mipmaps should not be generated (default is false)
  57722. */
  57723. noMipmap?: boolean,
  57724. /**
  57725. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  57726. */
  57727. generateHarmonics?: boolean,
  57728. /**
  57729. * 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)
  57730. */
  57731. gammaSpace?: boolean,
  57732. /**
  57733. * Internal Use Only
  57734. */
  57735. reserved?: boolean);
  57736. /**
  57737. * Execute the current task
  57738. * @param scene defines the scene where you want your assets to be loaded
  57739. * @param onSuccess is a callback called when the task is successfully executed
  57740. * @param onError is a callback called if an error occurs
  57741. */
  57742. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57743. }
  57744. /**
  57745. * Define a task used by AssetsManager to load Equirectangular cube textures
  57746. */
  57747. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  57748. /**
  57749. * Defines the name of the task
  57750. */
  57751. name: string;
  57752. /**
  57753. * Defines the location of the file to load
  57754. */
  57755. url: string;
  57756. /**
  57757. * Defines the desired size (the more it increases the longer the generation will be)
  57758. */
  57759. size: number;
  57760. /**
  57761. * Defines if mipmaps should not be generated (default is false)
  57762. */
  57763. noMipmap: boolean;
  57764. /**
  57765. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  57766. * but the standard material would require them in Gamma space) (default is true)
  57767. */
  57768. gammaSpace: boolean;
  57769. /**
  57770. * Gets the loaded texture
  57771. */
  57772. texture: EquiRectangularCubeTexture;
  57773. /**
  57774. * Callback called when the task is successful
  57775. */
  57776. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  57777. /**
  57778. * Callback called when the task is successful
  57779. */
  57780. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  57781. /**
  57782. * Creates a new EquiRectangularCubeTextureAssetTask object
  57783. * @param name defines the name of the task
  57784. * @param url defines the location of the file to load
  57785. * @param size defines the desired size (the more it increases the longer the generation will be)
  57786. * If the size is omitted this implies you are using a preprocessed cubemap.
  57787. * @param noMipmap defines if mipmaps should not be generated (default is false)
  57788. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  57789. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  57790. * (default is true)
  57791. */
  57792. constructor(
  57793. /**
  57794. * Defines the name of the task
  57795. */
  57796. name: string,
  57797. /**
  57798. * Defines the location of the file to load
  57799. */
  57800. url: string,
  57801. /**
  57802. * Defines the desired size (the more it increases the longer the generation will be)
  57803. */
  57804. size: number,
  57805. /**
  57806. * Defines if mipmaps should not be generated (default is false)
  57807. */
  57808. noMipmap?: boolean,
  57809. /**
  57810. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  57811. * but the standard material would require them in Gamma space) (default is true)
  57812. */
  57813. gammaSpace?: boolean);
  57814. /**
  57815. * Execute the current task
  57816. * @param scene defines the scene where you want your assets to be loaded
  57817. * @param onSuccess is a callback called when the task is successfully executed
  57818. * @param onError is a callback called if an error occurs
  57819. */
  57820. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57821. }
  57822. /**
  57823. * This class can be used to easily import assets into a scene
  57824. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  57825. */
  57826. export class AssetsManager {
  57827. private _scene;
  57828. private _isLoading;
  57829. protected _tasks: AbstractAssetTask[];
  57830. protected _waitingTasksCount: number;
  57831. protected _totalTasksCount: number;
  57832. /**
  57833. * Callback called when all tasks are processed
  57834. */
  57835. onFinish: (tasks: AbstractAssetTask[]) => void;
  57836. /**
  57837. * Callback called when a task is successful
  57838. */
  57839. onTaskSuccess: (task: AbstractAssetTask) => void;
  57840. /**
  57841. * Callback called when a task had an error
  57842. */
  57843. onTaskError: (task: AbstractAssetTask) => void;
  57844. /**
  57845. * Callback called when a task is done (whatever the result is)
  57846. */
  57847. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  57848. /**
  57849. * Observable called when all tasks are processed
  57850. */
  57851. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  57852. /**
  57853. * Observable called when a task had an error
  57854. */
  57855. onTaskErrorObservable: Observable<AbstractAssetTask>;
  57856. /**
  57857. * Observable called when all tasks were executed
  57858. */
  57859. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  57860. /**
  57861. * Observable called when a task is done (whatever the result is)
  57862. */
  57863. onProgressObservable: Observable<IAssetsProgressEvent>;
  57864. /**
  57865. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  57866. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  57867. */
  57868. useDefaultLoadingScreen: boolean;
  57869. /**
  57870. * Creates a new AssetsManager
  57871. * @param scene defines the scene to work on
  57872. */
  57873. constructor(scene: Scene);
  57874. /**
  57875. * Add a MeshAssetTask to the list of active tasks
  57876. * @param taskName defines the name of the new task
  57877. * @param meshesNames defines the name of meshes to load
  57878. * @param rootUrl defines the root url to use to locate files
  57879. * @param sceneFilename defines the filename of the scene file
  57880. * @returns a new MeshAssetTask object
  57881. */
  57882. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  57883. /**
  57884. * Add a TextFileAssetTask to the list of active tasks
  57885. * @param taskName defines the name of the new task
  57886. * @param url defines the url of the file to load
  57887. * @returns a new TextFileAssetTask object
  57888. */
  57889. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  57890. /**
  57891. * Add a BinaryFileAssetTask to the list of active tasks
  57892. * @param taskName defines the name of the new task
  57893. * @param url defines the url of the file to load
  57894. * @returns a new BinaryFileAssetTask object
  57895. */
  57896. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  57897. /**
  57898. * Add a ImageAssetTask to the list of active tasks
  57899. * @param taskName defines the name of the new task
  57900. * @param url defines the url of the file to load
  57901. * @returns a new ImageAssetTask object
  57902. */
  57903. addImageTask(taskName: string, url: string): ImageAssetTask;
  57904. /**
  57905. * Add a TextureAssetTask to the list of active tasks
  57906. * @param taskName defines the name of the new task
  57907. * @param url defines the url of the file to load
  57908. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  57909. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  57910. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  57911. * @returns a new TextureAssetTask object
  57912. */
  57913. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  57914. /**
  57915. * Add a CubeTextureAssetTask to the list of active tasks
  57916. * @param taskName defines the name of the new task
  57917. * @param url defines the url of the file to load
  57918. * @param extensions defines the extension to use to load the cube map (can be null)
  57919. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  57920. * @param files defines the list of files to load (can be null)
  57921. * @returns a new CubeTextureAssetTask object
  57922. */
  57923. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  57924. /**
  57925. *
  57926. * Add a HDRCubeTextureAssetTask to the list of active tasks
  57927. * @param taskName defines the name of the new task
  57928. * @param url defines the url of the file to load
  57929. * @param size defines the size you want for the cubemap (can be null)
  57930. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  57931. * @param generateHarmonics defines if you want to automatically generate (true by default)
  57932. * @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)
  57933. * @param reserved Internal use only
  57934. * @returns a new HDRCubeTextureAssetTask object
  57935. */
  57936. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  57937. /**
  57938. *
  57939. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  57940. * @param taskName defines the name of the new task
  57941. * @param url defines the url of the file to load
  57942. * @param size defines the size you want for the cubemap (can be null)
  57943. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  57944. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  57945. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  57946. * @returns a new EquiRectangularCubeTextureAssetTask object
  57947. */
  57948. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  57949. /**
  57950. * Remove a task from the assets manager.
  57951. * @param task the task to remove
  57952. */
  57953. removeTask(task: AbstractAssetTask): void;
  57954. private _decreaseWaitingTasksCount;
  57955. private _runTask;
  57956. /**
  57957. * Reset the AssetsManager and remove all tasks
  57958. * @return the current instance of the AssetsManager
  57959. */
  57960. reset(): AssetsManager;
  57961. /**
  57962. * Start the loading process
  57963. * @return the current instance of the AssetsManager
  57964. */
  57965. load(): AssetsManager;
  57966. /**
  57967. * Start the loading process as an async operation
  57968. * @return a promise returning the list of failed tasks
  57969. */
  57970. loadAsync(): Promise<void>;
  57971. }
  57972. }
  57973. declare module "babylonjs/Misc/deferred" {
  57974. /**
  57975. * Wrapper class for promise with external resolve and reject.
  57976. */
  57977. export class Deferred<T> {
  57978. /**
  57979. * The promise associated with this deferred object.
  57980. */
  57981. readonly promise: Promise<T>;
  57982. private _resolve;
  57983. private _reject;
  57984. /**
  57985. * The resolve method of the promise associated with this deferred object.
  57986. */
  57987. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  57988. /**
  57989. * The reject method of the promise associated with this deferred object.
  57990. */
  57991. readonly reject: (reason?: any) => void;
  57992. /**
  57993. * Constructor for this deferred object.
  57994. */
  57995. constructor();
  57996. }
  57997. }
  57998. declare module "babylonjs/Misc/meshExploder" {
  57999. import { Mesh } from "babylonjs/Meshes/mesh";
  58000. /**
  58001. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  58002. */
  58003. export class MeshExploder {
  58004. private _centerMesh;
  58005. private _meshes;
  58006. private _meshesOrigins;
  58007. private _toCenterVectors;
  58008. private _scaledDirection;
  58009. private _newPosition;
  58010. private _centerPosition;
  58011. /**
  58012. * Explodes meshes from a center mesh.
  58013. * @param meshes The meshes to explode.
  58014. * @param centerMesh The mesh to be center of explosion.
  58015. */
  58016. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  58017. private _setCenterMesh;
  58018. /**
  58019. * Get class name
  58020. * @returns "MeshExploder"
  58021. */
  58022. getClassName(): string;
  58023. /**
  58024. * "Exploded meshes"
  58025. * @returns Array of meshes with the centerMesh at index 0.
  58026. */
  58027. getMeshes(): Array<Mesh>;
  58028. /**
  58029. * Explodes meshes giving a specific direction
  58030. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  58031. */
  58032. explode(direction?: number): void;
  58033. }
  58034. }
  58035. declare module "babylonjs/Misc/filesInput" {
  58036. import { Engine } from "babylonjs/Engines/engine";
  58037. import { Scene } from "babylonjs/scene";
  58038. import { SceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  58039. /**
  58040. * Class used to help managing file picking and drag'n'drop
  58041. */
  58042. export class FilesInput {
  58043. /**
  58044. * List of files ready to be loaded
  58045. */
  58046. static readonly FilesToLoad: {
  58047. [key: string]: File;
  58048. };
  58049. /**
  58050. * Callback called when a file is processed
  58051. */
  58052. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  58053. private _engine;
  58054. private _currentScene;
  58055. private _sceneLoadedCallback;
  58056. private _progressCallback;
  58057. private _additionalRenderLoopLogicCallback;
  58058. private _textureLoadingCallback;
  58059. private _startingProcessingFilesCallback;
  58060. private _onReloadCallback;
  58061. private _errorCallback;
  58062. private _elementToMonitor;
  58063. private _sceneFileToLoad;
  58064. private _filesToLoad;
  58065. /**
  58066. * Creates a new FilesInput
  58067. * @param engine defines the rendering engine
  58068. * @param scene defines the hosting scene
  58069. * @param sceneLoadedCallback callback called when scene is loaded
  58070. * @param progressCallback callback called to track progress
  58071. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  58072. * @param textureLoadingCallback callback called when a texture is loading
  58073. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  58074. * @param onReloadCallback callback called when a reload is requested
  58075. * @param errorCallback callback call if an error occurs
  58076. */
  58077. 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);
  58078. private _dragEnterHandler;
  58079. private _dragOverHandler;
  58080. private _dropHandler;
  58081. /**
  58082. * Calls this function to listen to drag'n'drop events on a specific DOM element
  58083. * @param elementToMonitor defines the DOM element to track
  58084. */
  58085. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  58086. /**
  58087. * Release all associated resources
  58088. */
  58089. dispose(): void;
  58090. private renderFunction;
  58091. private drag;
  58092. private drop;
  58093. private _traverseFolder;
  58094. private _processFiles;
  58095. /**
  58096. * Load files from a drop event
  58097. * @param event defines the drop event to use as source
  58098. */
  58099. loadFiles(event: any): void;
  58100. private _processReload;
  58101. /**
  58102. * Reload the current scene from the loaded files
  58103. */
  58104. reload(): void;
  58105. }
  58106. }
  58107. declare module "babylonjs/Misc/HighDynamicRange/index" {
  58108. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  58109. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  58110. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  58111. }
  58112. declare module "babylonjs/Misc/sceneOptimizer" {
  58113. import { Scene, IDisposable } from "babylonjs/scene";
  58114. import { Observable } from "babylonjs/Misc/observable";
  58115. /**
  58116. * Defines the root class used to create scene optimization to use with SceneOptimizer
  58117. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58118. */
  58119. export class SceneOptimization {
  58120. /**
  58121. * Defines the priority of this optimization (0 by default which means first in the list)
  58122. */
  58123. priority: number;
  58124. /**
  58125. * Gets a string describing the action executed by the current optimization
  58126. * @returns description string
  58127. */
  58128. getDescription(): string;
  58129. /**
  58130. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58131. * @param scene defines the current scene where to apply this optimization
  58132. * @param optimizer defines the current optimizer
  58133. * @returns true if everything that can be done was applied
  58134. */
  58135. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58136. /**
  58137. * Creates the SceneOptimization object
  58138. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  58139. * @param desc defines the description associated with the optimization
  58140. */
  58141. constructor(
  58142. /**
  58143. * Defines the priority of this optimization (0 by default which means first in the list)
  58144. */
  58145. priority?: number);
  58146. }
  58147. /**
  58148. * Defines an optimization used to reduce the size of render target textures
  58149. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58150. */
  58151. export class TextureOptimization extends SceneOptimization {
  58152. /**
  58153. * Defines the priority of this optimization (0 by default which means first in the list)
  58154. */
  58155. priority: number;
  58156. /**
  58157. * 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
  58158. */
  58159. maximumSize: number;
  58160. /**
  58161. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  58162. */
  58163. step: number;
  58164. /**
  58165. * Gets a string describing the action executed by the current optimization
  58166. * @returns description string
  58167. */
  58168. getDescription(): string;
  58169. /**
  58170. * Creates the TextureOptimization object
  58171. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  58172. * @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
  58173. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  58174. */
  58175. constructor(
  58176. /**
  58177. * Defines the priority of this optimization (0 by default which means first in the list)
  58178. */
  58179. priority?: number,
  58180. /**
  58181. * 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
  58182. */
  58183. maximumSize?: number,
  58184. /**
  58185. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  58186. */
  58187. step?: number);
  58188. /**
  58189. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58190. * @param scene defines the current scene where to apply this optimization
  58191. * @param optimizer defines the current optimizer
  58192. * @returns true if everything that can be done was applied
  58193. */
  58194. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58195. }
  58196. /**
  58197. * Defines an optimization used to increase or decrease the rendering resolution
  58198. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58199. */
  58200. export class HardwareScalingOptimization extends SceneOptimization {
  58201. /**
  58202. * Defines the priority of this optimization (0 by default which means first in the list)
  58203. */
  58204. priority: number;
  58205. /**
  58206. * Defines the maximum scale to use (2 by default)
  58207. */
  58208. maximumScale: number;
  58209. /**
  58210. * Defines the step to use between two passes (0.5 by default)
  58211. */
  58212. step: number;
  58213. private _currentScale;
  58214. private _directionOffset;
  58215. /**
  58216. * Gets a string describing the action executed by the current optimization
  58217. * @return description string
  58218. */
  58219. getDescription(): string;
  58220. /**
  58221. * Creates the HardwareScalingOptimization object
  58222. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  58223. * @param maximumScale defines the maximum scale to use (2 by default)
  58224. * @param step defines the step to use between two passes (0.5 by default)
  58225. */
  58226. constructor(
  58227. /**
  58228. * Defines the priority of this optimization (0 by default which means first in the list)
  58229. */
  58230. priority?: number,
  58231. /**
  58232. * Defines the maximum scale to use (2 by default)
  58233. */
  58234. maximumScale?: number,
  58235. /**
  58236. * Defines the step to use between two passes (0.5 by default)
  58237. */
  58238. step?: number);
  58239. /**
  58240. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58241. * @param scene defines the current scene where to apply this optimization
  58242. * @param optimizer defines the current optimizer
  58243. * @returns true if everything that can be done was applied
  58244. */
  58245. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58246. }
  58247. /**
  58248. * Defines an optimization used to remove shadows
  58249. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58250. */
  58251. export class ShadowsOptimization extends SceneOptimization {
  58252. /**
  58253. * Gets a string describing the action executed by the current optimization
  58254. * @return description string
  58255. */
  58256. getDescription(): string;
  58257. /**
  58258. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58259. * @param scene defines the current scene where to apply this optimization
  58260. * @param optimizer defines the current optimizer
  58261. * @returns true if everything that can be done was applied
  58262. */
  58263. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58264. }
  58265. /**
  58266. * Defines an optimization used to turn post-processes off
  58267. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58268. */
  58269. export class PostProcessesOptimization extends SceneOptimization {
  58270. /**
  58271. * Gets a string describing the action executed by the current optimization
  58272. * @return description string
  58273. */
  58274. getDescription(): string;
  58275. /**
  58276. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58277. * @param scene defines the current scene where to apply this optimization
  58278. * @param optimizer defines the current optimizer
  58279. * @returns true if everything that can be done was applied
  58280. */
  58281. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58282. }
  58283. /**
  58284. * Defines an optimization used to turn lens flares off
  58285. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58286. */
  58287. export class LensFlaresOptimization extends SceneOptimization {
  58288. /**
  58289. * Gets a string describing the action executed by the current optimization
  58290. * @return description string
  58291. */
  58292. getDescription(): string;
  58293. /**
  58294. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58295. * @param scene defines the current scene where to apply this optimization
  58296. * @param optimizer defines the current optimizer
  58297. * @returns true if everything that can be done was applied
  58298. */
  58299. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58300. }
  58301. /**
  58302. * Defines an optimization based on user defined callback.
  58303. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58304. */
  58305. export class CustomOptimization extends SceneOptimization {
  58306. /**
  58307. * Callback called to apply the custom optimization.
  58308. */
  58309. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  58310. /**
  58311. * Callback called to get custom description
  58312. */
  58313. onGetDescription: () => string;
  58314. /**
  58315. * Gets a string describing the action executed by the current optimization
  58316. * @returns description string
  58317. */
  58318. getDescription(): string;
  58319. /**
  58320. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58321. * @param scene defines the current scene where to apply this optimization
  58322. * @param optimizer defines the current optimizer
  58323. * @returns true if everything that can be done was applied
  58324. */
  58325. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58326. }
  58327. /**
  58328. * Defines an optimization used to turn particles off
  58329. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58330. */
  58331. export class ParticlesOptimization extends SceneOptimization {
  58332. /**
  58333. * Gets a string describing the action executed by the current optimization
  58334. * @return description string
  58335. */
  58336. getDescription(): string;
  58337. /**
  58338. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58339. * @param scene defines the current scene where to apply this optimization
  58340. * @param optimizer defines the current optimizer
  58341. * @returns true if everything that can be done was applied
  58342. */
  58343. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58344. }
  58345. /**
  58346. * Defines an optimization used to turn render targets off
  58347. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58348. */
  58349. export class RenderTargetsOptimization extends SceneOptimization {
  58350. /**
  58351. * Gets a string describing the action executed by the current optimization
  58352. * @return description string
  58353. */
  58354. getDescription(): string;
  58355. /**
  58356. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58357. * @param scene defines the current scene where to apply this optimization
  58358. * @param optimizer defines the current optimizer
  58359. * @returns true if everything that can be done was applied
  58360. */
  58361. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58362. }
  58363. /**
  58364. * Defines an optimization used to merge meshes with compatible materials
  58365. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58366. */
  58367. export class MergeMeshesOptimization extends SceneOptimization {
  58368. private static _UpdateSelectionTree;
  58369. /**
  58370. * Gets or sets a boolean which defines if optimization octree has to be updated
  58371. */
  58372. /**
  58373. * Gets or sets a boolean which defines if optimization octree has to be updated
  58374. */
  58375. static UpdateSelectionTree: boolean;
  58376. /**
  58377. * Gets a string describing the action executed by the current optimization
  58378. * @return description string
  58379. */
  58380. getDescription(): string;
  58381. private _canBeMerged;
  58382. /**
  58383. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58384. * @param scene defines the current scene where to apply this optimization
  58385. * @param optimizer defines the current optimizer
  58386. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  58387. * @returns true if everything that can be done was applied
  58388. */
  58389. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  58390. }
  58391. /**
  58392. * Defines a list of options used by SceneOptimizer
  58393. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58394. */
  58395. export class SceneOptimizerOptions {
  58396. /**
  58397. * Defines the target frame rate to reach (60 by default)
  58398. */
  58399. targetFrameRate: number;
  58400. /**
  58401. * Defines the interval between two checkes (2000ms by default)
  58402. */
  58403. trackerDuration: number;
  58404. /**
  58405. * Gets the list of optimizations to apply
  58406. */
  58407. optimizations: SceneOptimization[];
  58408. /**
  58409. * Creates a new list of options used by SceneOptimizer
  58410. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  58411. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  58412. */
  58413. constructor(
  58414. /**
  58415. * Defines the target frame rate to reach (60 by default)
  58416. */
  58417. targetFrameRate?: number,
  58418. /**
  58419. * Defines the interval between two checkes (2000ms by default)
  58420. */
  58421. trackerDuration?: number);
  58422. /**
  58423. * Add a new optimization
  58424. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  58425. * @returns the current SceneOptimizerOptions
  58426. */
  58427. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  58428. /**
  58429. * Add a new custom optimization
  58430. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  58431. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  58432. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  58433. * @returns the current SceneOptimizerOptions
  58434. */
  58435. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  58436. /**
  58437. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  58438. * @param targetFrameRate defines the target frame rate (60 by default)
  58439. * @returns a SceneOptimizerOptions object
  58440. */
  58441. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  58442. /**
  58443. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  58444. * @param targetFrameRate defines the target frame rate (60 by default)
  58445. * @returns a SceneOptimizerOptions object
  58446. */
  58447. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  58448. /**
  58449. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  58450. * @param targetFrameRate defines the target frame rate (60 by default)
  58451. * @returns a SceneOptimizerOptions object
  58452. */
  58453. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  58454. }
  58455. /**
  58456. * Class used to run optimizations in order to reach a target frame rate
  58457. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58458. */
  58459. export class SceneOptimizer implements IDisposable {
  58460. private _isRunning;
  58461. private _options;
  58462. private _scene;
  58463. private _currentPriorityLevel;
  58464. private _targetFrameRate;
  58465. private _trackerDuration;
  58466. private _currentFrameRate;
  58467. private _sceneDisposeObserver;
  58468. private _improvementMode;
  58469. /**
  58470. * Defines an observable called when the optimizer reaches the target frame rate
  58471. */
  58472. onSuccessObservable: Observable<SceneOptimizer>;
  58473. /**
  58474. * Defines an observable called when the optimizer enables an optimization
  58475. */
  58476. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  58477. /**
  58478. * Defines an observable called when the optimizer is not able to reach the target frame rate
  58479. */
  58480. onFailureObservable: Observable<SceneOptimizer>;
  58481. /**
  58482. * Gets a boolean indicating if the optimizer is in improvement mode
  58483. */
  58484. readonly isInImprovementMode: boolean;
  58485. /**
  58486. * Gets the current priority level (0 at start)
  58487. */
  58488. readonly currentPriorityLevel: number;
  58489. /**
  58490. * Gets the current frame rate checked by the SceneOptimizer
  58491. */
  58492. readonly currentFrameRate: number;
  58493. /**
  58494. * Gets or sets the current target frame rate (60 by default)
  58495. */
  58496. /**
  58497. * Gets or sets the current target frame rate (60 by default)
  58498. */
  58499. targetFrameRate: number;
  58500. /**
  58501. * Gets or sets the current interval between two checks (every 2000ms by default)
  58502. */
  58503. /**
  58504. * Gets or sets the current interval between two checks (every 2000ms by default)
  58505. */
  58506. trackerDuration: number;
  58507. /**
  58508. * Gets the list of active optimizations
  58509. */
  58510. readonly optimizations: SceneOptimization[];
  58511. /**
  58512. * Creates a new SceneOptimizer
  58513. * @param scene defines the scene to work on
  58514. * @param options defines the options to use with the SceneOptimizer
  58515. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  58516. * @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)
  58517. */
  58518. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  58519. /**
  58520. * Stops the current optimizer
  58521. */
  58522. stop(): void;
  58523. /**
  58524. * Reset the optimizer to initial step (current priority level = 0)
  58525. */
  58526. reset(): void;
  58527. /**
  58528. * Start the optimizer. By default it will try to reach a specific framerate
  58529. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  58530. */
  58531. start(): void;
  58532. private _checkCurrentState;
  58533. /**
  58534. * Release all resources
  58535. */
  58536. dispose(): void;
  58537. /**
  58538. * Helper function to create a SceneOptimizer with one single line of code
  58539. * @param scene defines the scene to work on
  58540. * @param options defines the options to use with the SceneOptimizer
  58541. * @param onSuccess defines a callback to call on success
  58542. * @param onFailure defines a callback to call on failure
  58543. * @returns the new SceneOptimizer object
  58544. */
  58545. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  58546. }
  58547. }
  58548. declare module "babylonjs/Misc/sceneSerializer" {
  58549. import { Scene } from "babylonjs/scene";
  58550. /**
  58551. * Class used to serialize a scene into a string
  58552. */
  58553. export class SceneSerializer {
  58554. /**
  58555. * Clear cache used by a previous serialization
  58556. */
  58557. static ClearCache(): void;
  58558. /**
  58559. * Serialize a scene into a JSON compatible object
  58560. * @param scene defines the scene to serialize
  58561. * @returns a JSON compatible object
  58562. */
  58563. static Serialize(scene: Scene): any;
  58564. /**
  58565. * Serialize a mesh into a JSON compatible object
  58566. * @param toSerialize defines the mesh to serialize
  58567. * @param withParents defines if parents must be serialized as well
  58568. * @param withChildren defines if children must be serialized as well
  58569. * @returns a JSON compatible object
  58570. */
  58571. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  58572. }
  58573. }
  58574. declare module "babylonjs/Misc/textureTools" {
  58575. import { Texture } from "babylonjs/Materials/Textures/texture";
  58576. /**
  58577. * Class used to host texture specific utilities
  58578. */
  58579. export class TextureTools {
  58580. /**
  58581. * Uses the GPU to create a copy texture rescaled at a given size
  58582. * @param texture Texture to copy from
  58583. * @param width defines the desired width
  58584. * @param height defines the desired height
  58585. * @param useBilinearMode defines if bilinear mode has to be used
  58586. * @return the generated texture
  58587. */
  58588. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  58589. }
  58590. }
  58591. declare module "babylonjs/Misc/videoRecorder" {
  58592. import { Nullable } from "babylonjs/types";
  58593. import { Engine } from "babylonjs/Engines/engine";
  58594. /**
  58595. * This represents the different options avilable for the video capture.
  58596. */
  58597. export interface VideoRecorderOptions {
  58598. /** Defines the mime type of the video */
  58599. mimeType: string;
  58600. /** Defines the video the video should be recorded at */
  58601. fps: number;
  58602. /** Defines the chunk size for the recording data */
  58603. recordChunckSize: number;
  58604. /** The audio tracks to attach to the record */
  58605. audioTracks?: MediaStreamTrack[];
  58606. }
  58607. /**
  58608. * This can helps recording videos from BabylonJS.
  58609. * This is based on the available WebRTC functionalities of the browser.
  58610. *
  58611. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  58612. */
  58613. export class VideoRecorder {
  58614. private static readonly _defaultOptions;
  58615. /**
  58616. * Returns wehther or not the VideoRecorder is available in your browser.
  58617. * @param engine Defines the Babylon Engine to check the support for
  58618. * @returns true if supported otherwise false
  58619. */
  58620. static IsSupported(engine: Engine): boolean;
  58621. private readonly _options;
  58622. private _canvas;
  58623. private _mediaRecorder;
  58624. private _recordedChunks;
  58625. private _fileName;
  58626. private _resolve;
  58627. private _reject;
  58628. /**
  58629. * True wether a recording is already in progress.
  58630. */
  58631. readonly isRecording: boolean;
  58632. /**
  58633. * Create a new VideoCapture object which can help converting what you see in Babylon to
  58634. * a video file.
  58635. * @param engine Defines the BabylonJS Engine you wish to record
  58636. * @param options Defines options that can be used to customized the capture
  58637. */
  58638. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  58639. /**
  58640. * Stops the current recording before the default capture timeout passed in the startRecording
  58641. * functions.
  58642. */
  58643. stopRecording(): void;
  58644. /**
  58645. * Starts recording the canvas for a max duration specified in parameters.
  58646. * @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.
  58647. * @param maxDuration Defines the maximum recording time in seconds.
  58648. * It default to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  58649. * @return a promise callback at the end of the recording with the video data in Blob.
  58650. */
  58651. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  58652. /**
  58653. * Releases internal resources used during the recording.
  58654. */
  58655. dispose(): void;
  58656. private _handleDataAvailable;
  58657. private _handleError;
  58658. private _handleStop;
  58659. }
  58660. }
  58661. declare module "babylonjs/Misc/screenshotTools" {
  58662. import { Camera } from "babylonjs/Cameras/camera";
  58663. import { Engine } from "babylonjs/Engines/engine";
  58664. /**
  58665. * Class containing a set of static utilities functions for screenshots
  58666. */
  58667. export class ScreenshotTools {
  58668. /**
  58669. * Captures a screenshot of the current rendering
  58670. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  58671. * @param engine defines the rendering engine
  58672. * @param camera defines the source camera
  58673. * @param size This parameter can be set to a single number or to an object with the
  58674. * following (optional) properties: precision, width, height. If a single number is passed,
  58675. * it will be used for both width and height. If an object is passed, the screenshot size
  58676. * will be derived from the parameters. The precision property is a multiplier allowing
  58677. * rendering at a higher or lower resolution
  58678. * @param successCallback defines the callback receives a single parameter which contains the
  58679. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  58680. * src parameter of an <img> to display it
  58681. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  58682. * Check your browser for supported MIME types
  58683. */
  58684. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  58685. /**
  58686. * Generates an image screenshot from the specified camera.
  58687. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  58688. * @param engine The engine to use for rendering
  58689. * @param camera The camera to use for rendering
  58690. * @param size This parameter can be set to a single number or to an object with the
  58691. * following (optional) properties: precision, width, height. If a single number is passed,
  58692. * it will be used for both width and height. If an object is passed, the screenshot size
  58693. * will be derived from the parameters. The precision property is a multiplier allowing
  58694. * rendering at a higher or lower resolution
  58695. * @param successCallback The callback receives a single parameter which contains the
  58696. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  58697. * src parameter of an <img> to display it
  58698. * @param mimeType The MIME type of the screenshot image (default: image/png).
  58699. * Check your browser for supported MIME types
  58700. * @param samples Texture samples (default: 1)
  58701. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  58702. * @param fileName A name for for the downloaded file.
  58703. */
  58704. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  58705. }
  58706. }
  58707. declare module "babylonjs/Misc/index" {
  58708. export * from "babylonjs/Misc/andOrNotEvaluator";
  58709. export * from "babylonjs/Misc/assetsManager";
  58710. export * from "babylonjs/Misc/dds";
  58711. export * from "babylonjs/Misc/decorators";
  58712. export * from "babylonjs/Misc/deferred";
  58713. export * from "babylonjs/Misc/environmentTextureTools";
  58714. export * from "babylonjs/Misc/meshExploder";
  58715. export * from "babylonjs/Misc/filesInput";
  58716. export * from "babylonjs/Misc/HighDynamicRange/index";
  58717. export * from "babylonjs/Misc/khronosTextureContainer";
  58718. export * from "babylonjs/Misc/observable";
  58719. export * from "babylonjs/Misc/performanceMonitor";
  58720. export * from "babylonjs/Misc/promise";
  58721. export * from "babylonjs/Misc/sceneOptimizer";
  58722. export * from "babylonjs/Misc/sceneSerializer";
  58723. export * from "babylonjs/Misc/smartArray";
  58724. export * from "babylonjs/Misc/stringDictionary";
  58725. export * from "babylonjs/Misc/tags";
  58726. export * from "babylonjs/Misc/textureTools";
  58727. export * from "babylonjs/Misc/tga";
  58728. export * from "babylonjs/Misc/tools";
  58729. export * from "babylonjs/Misc/videoRecorder";
  58730. export * from "babylonjs/Misc/virtualJoystick";
  58731. export * from "babylonjs/Misc/workerPool";
  58732. export * from "babylonjs/Misc/logger";
  58733. export * from "babylonjs/Misc/typeStore";
  58734. export * from "babylonjs/Misc/filesInputStore";
  58735. export * from "babylonjs/Misc/deepCopier";
  58736. export * from "babylonjs/Misc/pivotTools";
  58737. export * from "babylonjs/Misc/precisionDate";
  58738. export * from "babylonjs/Misc/screenshotTools";
  58739. export * from "babylonjs/Misc/typeStore";
  58740. export * from "babylonjs/Misc/webRequest";
  58741. export * from "babylonjs/Misc/iInspectable";
  58742. }
  58743. declare module "babylonjs/index" {
  58744. export * from "babylonjs/abstractScene";
  58745. export * from "babylonjs/Actions/index";
  58746. export * from "babylonjs/Animations/index";
  58747. export * from "babylonjs/assetContainer";
  58748. export * from "babylonjs/Audio/index";
  58749. export * from "babylonjs/Behaviors/index";
  58750. export * from "babylonjs/Bones/index";
  58751. export * from "babylonjs/Cameras/index";
  58752. export * from "babylonjs/Collisions/index";
  58753. export * from "babylonjs/Culling/index";
  58754. export * from "babylonjs/Debug/index";
  58755. export * from "babylonjs/Engines/index";
  58756. export * from "babylonjs/Events/index";
  58757. export * from "babylonjs/Gamepads/index";
  58758. export * from "babylonjs/Gizmos/index";
  58759. export * from "babylonjs/Helpers/index";
  58760. export * from "babylonjs/Instrumentation/index";
  58761. export * from "babylonjs/Layers/index";
  58762. export * from "babylonjs/LensFlares/index";
  58763. export * from "babylonjs/Lights/index";
  58764. export * from "babylonjs/Loading/index";
  58765. export * from "babylonjs/Materials/index";
  58766. export * from "babylonjs/Maths/index";
  58767. export * from "babylonjs/Meshes/index";
  58768. export * from "babylonjs/Morph/index";
  58769. export * from "babylonjs/node";
  58770. export * from "babylonjs/Offline/index";
  58771. export * from "babylonjs/Particles/index";
  58772. export * from "babylonjs/Physics/index";
  58773. export * from "babylonjs/PostProcesses/index";
  58774. export * from "babylonjs/Probes/index";
  58775. export * from "babylonjs/Rendering/index";
  58776. export * from "babylonjs/scene";
  58777. export * from "babylonjs/sceneComponent";
  58778. export * from "babylonjs/Sprites/index";
  58779. export * from "babylonjs/States/index";
  58780. export * from "babylonjs/Misc/index";
  58781. export * from "babylonjs/types";
  58782. }
  58783. declare module "babylonjs/Animations/pathCursor" {
  58784. import { Path2, Vector3 } from "babylonjs/Maths/math";
  58785. /**
  58786. * A cursor which tracks a point on a path
  58787. */
  58788. export class PathCursor {
  58789. private path;
  58790. /**
  58791. * Stores path cursor callbacks for when an onchange event is triggered
  58792. */
  58793. private _onchange;
  58794. /**
  58795. * The value of the path cursor
  58796. */
  58797. value: number;
  58798. /**
  58799. * The animation array of the path cursor
  58800. */
  58801. animations: Animation[];
  58802. /**
  58803. * Initializes the path cursor
  58804. * @param path The path to track
  58805. */
  58806. constructor(path: Path2);
  58807. /**
  58808. * Gets the cursor point on the path
  58809. * @returns A point on the path cursor at the cursor location
  58810. */
  58811. getPoint(): Vector3;
  58812. /**
  58813. * Moves the cursor ahead by the step amount
  58814. * @param step The amount to move the cursor forward
  58815. * @returns This path cursor
  58816. */
  58817. moveAhead(step?: number): PathCursor;
  58818. /**
  58819. * Moves the cursor behind by the step amount
  58820. * @param step The amount to move the cursor back
  58821. * @returns This path cursor
  58822. */
  58823. moveBack(step?: number): PathCursor;
  58824. /**
  58825. * Moves the cursor by the step amount
  58826. * If the step amount is greater than one, an exception is thrown
  58827. * @param step The amount to move the cursor
  58828. * @returns This path cursor
  58829. */
  58830. move(step: number): PathCursor;
  58831. /**
  58832. * Ensures that the value is limited between zero and one
  58833. * @returns This path cursor
  58834. */
  58835. private ensureLimits;
  58836. /**
  58837. * Runs onchange callbacks on change (used by the animation engine)
  58838. * @returns This path cursor
  58839. */
  58840. private raiseOnChange;
  58841. /**
  58842. * Executes a function on change
  58843. * @param f A path cursor onchange callback
  58844. * @returns This path cursor
  58845. */
  58846. onchange(f: (cursor: PathCursor) => void): PathCursor;
  58847. }
  58848. }
  58849. declare module "babylonjs/Legacy/legacy" {
  58850. import * as Babylon from "babylonjs/index";
  58851. export * from "babylonjs/index";
  58852. }
  58853. declare module "babylonjs/Shaders/blur.fragment" {
  58854. /** @hidden */
  58855. export var blurPixelShader: {
  58856. name: string;
  58857. shader: string;
  58858. };
  58859. }
  58860. declare module "babylonjs/Shaders/ShadersInclude/bones300Declaration" {
  58861. /** @hidden */
  58862. export var bones300Declaration: {
  58863. name: string;
  58864. shader: string;
  58865. };
  58866. }
  58867. declare module "babylonjs/Shaders/ShadersInclude/instances300Declaration" {
  58868. /** @hidden */
  58869. export var instances300Declaration: {
  58870. name: string;
  58871. shader: string;
  58872. };
  58873. }
  58874. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  58875. /** @hidden */
  58876. export var pointCloudVertexDeclaration: {
  58877. name: string;
  58878. shader: string;
  58879. };
  58880. }
  58881. // Mixins
  58882. interface Window {
  58883. mozIndexedDB: IDBFactory;
  58884. webkitIndexedDB: IDBFactory;
  58885. msIndexedDB: IDBFactory;
  58886. webkitURL: typeof URL;
  58887. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  58888. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  58889. WebGLRenderingContext: WebGLRenderingContext;
  58890. MSGesture: MSGesture;
  58891. CANNON: any;
  58892. AudioContext: AudioContext;
  58893. webkitAudioContext: AudioContext;
  58894. PointerEvent: any;
  58895. Math: Math;
  58896. Uint8Array: Uint8ArrayConstructor;
  58897. Float32Array: Float32ArrayConstructor;
  58898. mozURL: typeof URL;
  58899. msURL: typeof URL;
  58900. VRFrameData: any; // WebVR, from specs 1.1
  58901. DracoDecoderModule: any;
  58902. setImmediate(handler: (...args: any[]) => void): number;
  58903. }
  58904. interface HTMLCanvasElement {
  58905. requestPointerLock(): void;
  58906. msRequestPointerLock?(): void;
  58907. mozRequestPointerLock?(): void;
  58908. webkitRequestPointerLock?(): void;
  58909. /** Track wether a record is in progress */
  58910. isRecording: boolean;
  58911. /** Capture Stream method defined by some browsers */
  58912. captureStream(fps?: number): MediaStream;
  58913. }
  58914. interface CanvasRenderingContext2D {
  58915. msImageSmoothingEnabled: boolean;
  58916. }
  58917. interface MouseEvent {
  58918. mozMovementX: number;
  58919. mozMovementY: number;
  58920. webkitMovementX: number;
  58921. webkitMovementY: number;
  58922. msMovementX: number;
  58923. msMovementY: number;
  58924. }
  58925. interface Navigator {
  58926. mozGetVRDevices: (any: any) => any;
  58927. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  58928. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  58929. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  58930. webkitGetGamepads(): Gamepad[];
  58931. msGetGamepads(): Gamepad[];
  58932. webkitGamepads(): Gamepad[];
  58933. }
  58934. interface HTMLVideoElement {
  58935. mozSrcObject: any;
  58936. }
  58937. interface Math {
  58938. fround(x: number): number;
  58939. imul(a: number, b: number): number;
  58940. }
  58941. interface WebGLProgram {
  58942. context?: WebGLRenderingContext;
  58943. vertexShader?: WebGLShader;
  58944. fragmentShader?: WebGLShader;
  58945. isParallelCompiled: boolean;
  58946. onCompiled?: () => void;
  58947. }
  58948. interface WebGLRenderingContext {
  58949. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  58950. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  58951. vertexAttribDivisor(index: number, divisor: number): void;
  58952. createVertexArray(): any;
  58953. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  58954. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  58955. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  58956. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  58957. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  58958. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  58959. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  58960. // Queries
  58961. createQuery(): WebGLQuery;
  58962. deleteQuery(query: WebGLQuery): void;
  58963. beginQuery(target: number, query: WebGLQuery): void;
  58964. endQuery(target: number): void;
  58965. getQueryParameter(query: WebGLQuery, pname: number): any;
  58966. getQuery(target: number, pname: number): any;
  58967. MAX_SAMPLES: number;
  58968. RGBA8: number;
  58969. READ_FRAMEBUFFER: number;
  58970. DRAW_FRAMEBUFFER: number;
  58971. UNIFORM_BUFFER: number;
  58972. HALF_FLOAT_OES: number;
  58973. RGBA16F: number;
  58974. RGBA32F: number;
  58975. R32F: number;
  58976. RG32F: number;
  58977. RGB32F: number;
  58978. R16F: number;
  58979. RG16F: number;
  58980. RGB16F: number;
  58981. RED: number;
  58982. RG: number;
  58983. R8: number;
  58984. RG8: number;
  58985. UNSIGNED_INT_24_8: number;
  58986. DEPTH24_STENCIL8: number;
  58987. /* Multiple Render Targets */
  58988. drawBuffers(buffers: number[]): void;
  58989. readBuffer(src: number): void;
  58990. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  58991. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  58992. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  58993. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  58994. // Occlusion Query
  58995. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  58996. ANY_SAMPLES_PASSED: number;
  58997. QUERY_RESULT_AVAILABLE: number;
  58998. QUERY_RESULT: number;
  58999. }
  59000. interface WebGLBuffer {
  59001. references: number;
  59002. capacity: number;
  59003. is32Bits: boolean;
  59004. }
  59005. interface WebGLProgram {
  59006. transformFeedback?: WebGLTransformFeedback | null;
  59007. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  59008. }
  59009. interface EXT_disjoint_timer_query {
  59010. QUERY_COUNTER_BITS_EXT: number;
  59011. TIME_ELAPSED_EXT: number;
  59012. TIMESTAMP_EXT: number;
  59013. GPU_DISJOINT_EXT: number;
  59014. QUERY_RESULT_EXT: number;
  59015. QUERY_RESULT_AVAILABLE_EXT: number;
  59016. queryCounterEXT(query: WebGLQuery, target: number): void;
  59017. createQueryEXT(): WebGLQuery;
  59018. beginQueryEXT(target: number, query: WebGLQuery): void;
  59019. endQueryEXT(target: number): void;
  59020. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  59021. deleteQueryEXT(query: WebGLQuery): void;
  59022. }
  59023. interface WebGLUniformLocation {
  59024. _currentState: any;
  59025. }
  59026. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  59027. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  59028. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  59029. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  59030. interface WebGLRenderingContext {
  59031. readonly RASTERIZER_DISCARD: number;
  59032. readonly DEPTH_COMPONENT24: number;
  59033. readonly TEXTURE_3D: number;
  59034. readonly TEXTURE_2D_ARRAY: number;
  59035. readonly TEXTURE_COMPARE_FUNC: number;
  59036. readonly TEXTURE_COMPARE_MODE: number;
  59037. readonly COMPARE_REF_TO_TEXTURE: number;
  59038. readonly TEXTURE_WRAP_R: number;
  59039. readonly HALF_FLOAT: number;
  59040. readonly RGB8: number;
  59041. readonly RED_INTEGER: number;
  59042. readonly RG_INTEGER: number;
  59043. readonly RGB_INTEGER: number;
  59044. readonly RGBA_INTEGER: number;
  59045. readonly R8_SNORM: number;
  59046. readonly RG8_SNORM: number;
  59047. readonly RGB8_SNORM: number;
  59048. readonly RGBA8_SNORM: number;
  59049. readonly R8I: number;
  59050. readonly RG8I: number;
  59051. readonly RGB8I: number;
  59052. readonly RGBA8I: number;
  59053. readonly R8UI: number;
  59054. readonly RG8UI: number;
  59055. readonly RGB8UI: number;
  59056. readonly RGBA8UI: number;
  59057. readonly R16I: number;
  59058. readonly RG16I: number;
  59059. readonly RGB16I: number;
  59060. readonly RGBA16I: number;
  59061. readonly R16UI: number;
  59062. readonly RG16UI: number;
  59063. readonly RGB16UI: number;
  59064. readonly RGBA16UI: number;
  59065. readonly R32I: number;
  59066. readonly RG32I: number;
  59067. readonly RGB32I: number;
  59068. readonly RGBA32I: number;
  59069. readonly R32UI: number;
  59070. readonly RG32UI: number;
  59071. readonly RGB32UI: number;
  59072. readonly RGBA32UI: number;
  59073. readonly RGB10_A2UI: number;
  59074. readonly R11F_G11F_B10F: number;
  59075. readonly RGB9_E5: number;
  59076. readonly RGB10_A2: number;
  59077. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  59078. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  59079. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  59080. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  59081. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  59082. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  59083. 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;
  59084. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  59085. readonly TRANSFORM_FEEDBACK: number;
  59086. readonly INTERLEAVED_ATTRIBS: number;
  59087. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  59088. createTransformFeedback(): WebGLTransformFeedback;
  59089. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  59090. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  59091. beginTransformFeedback(primitiveMode: number): void;
  59092. endTransformFeedback(): void;
  59093. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  59094. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  59095. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  59096. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  59097. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  59098. }
  59099. interface ImageBitmap {
  59100. readonly width: number;
  59101. readonly height: number;
  59102. close(): void;
  59103. }
  59104. interface WebGLQuery extends WebGLObject {
  59105. }
  59106. declare var WebGLQuery: {
  59107. prototype: WebGLQuery;
  59108. new(): WebGLQuery;
  59109. };
  59110. interface WebGLSampler extends WebGLObject {
  59111. }
  59112. declare var WebGLSampler: {
  59113. prototype: WebGLSampler;
  59114. new(): WebGLSampler;
  59115. };
  59116. interface WebGLSync extends WebGLObject {
  59117. }
  59118. declare var WebGLSync: {
  59119. prototype: WebGLSync;
  59120. new(): WebGLSync;
  59121. };
  59122. interface WebGLTransformFeedback extends WebGLObject {
  59123. }
  59124. declare var WebGLTransformFeedback: {
  59125. prototype: WebGLTransformFeedback;
  59126. new(): WebGLTransformFeedback;
  59127. };
  59128. interface WebGLVertexArrayObject extends WebGLObject {
  59129. }
  59130. declare var WebGLVertexArrayObject: {
  59131. prototype: WebGLVertexArrayObject;
  59132. new(): WebGLVertexArrayObject;
  59133. };
  59134. // Type definitions for WebVR API
  59135. // Project: https://w3c.github.io/webvr/
  59136. // Definitions by: six a <https://github.com/lostfictions>
  59137. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  59138. interface VRDisplay extends EventTarget {
  59139. /**
  59140. * Dictionary of capabilities describing the VRDisplay.
  59141. */
  59142. readonly capabilities: VRDisplayCapabilities;
  59143. /**
  59144. * z-depth defining the far plane of the eye view frustum
  59145. * enables mapping of values in the render target depth
  59146. * attachment to scene coordinates. Initially set to 10000.0.
  59147. */
  59148. depthFar: number;
  59149. /**
  59150. * z-depth defining the near plane of the eye view frustum
  59151. * enables mapping of values in the render target depth
  59152. * attachment to scene coordinates. Initially set to 0.01.
  59153. */
  59154. depthNear: number;
  59155. /**
  59156. * An identifier for this distinct VRDisplay. Used as an
  59157. * association point in the Gamepad API.
  59158. */
  59159. readonly displayId: number;
  59160. /**
  59161. * A display name, a user-readable name identifying it.
  59162. */
  59163. readonly displayName: string;
  59164. readonly isConnected: boolean;
  59165. readonly isPresenting: boolean;
  59166. /**
  59167. * If this VRDisplay supports room-scale experiences, the optional
  59168. * stage attribute contains details on the room-scale parameters.
  59169. */
  59170. readonly stageParameters: VRStageParameters | null;
  59171. /**
  59172. * Passing the value returned by `requestAnimationFrame` to
  59173. * `cancelAnimationFrame` will unregister the callback.
  59174. * @param handle Define the hanle of the request to cancel
  59175. */
  59176. cancelAnimationFrame(handle: number): void;
  59177. /**
  59178. * Stops presenting to the VRDisplay.
  59179. * @returns a promise to know when it stopped
  59180. */
  59181. exitPresent(): Promise<void>;
  59182. /**
  59183. * Return the current VREyeParameters for the given eye.
  59184. * @param whichEye Define the eye we want the parameter for
  59185. * @returns the eye parameters
  59186. */
  59187. getEyeParameters(whichEye: string): VREyeParameters;
  59188. /**
  59189. * Populates the passed VRFrameData with the information required to render
  59190. * the current frame.
  59191. * @param frameData Define the data structure to populate
  59192. * @returns true if ok otherwise false
  59193. */
  59194. getFrameData(frameData: VRFrameData): boolean;
  59195. /**
  59196. * Get the layers currently being presented.
  59197. * @returns the list of VR layers
  59198. */
  59199. getLayers(): VRLayer[];
  59200. /**
  59201. * Return a VRPose containing the future predicted pose of the VRDisplay
  59202. * when the current frame will be presented. The value returned will not
  59203. * change until JavaScript has returned control to the browser.
  59204. *
  59205. * The VRPose will contain the position, orientation, velocity,
  59206. * and acceleration of each of these properties.
  59207. * @returns the pose object
  59208. */
  59209. getPose(): VRPose;
  59210. /**
  59211. * Return the current instantaneous pose of the VRDisplay, with no
  59212. * prediction applied.
  59213. * @returns the current instantaneous pose
  59214. */
  59215. getImmediatePose(): VRPose;
  59216. /**
  59217. * The callback passed to `requestAnimationFrame` will be called
  59218. * any time a new frame should be rendered. When the VRDisplay is
  59219. * presenting the callback will be called at the native refresh
  59220. * rate of the HMD. When not presenting this function acts
  59221. * identically to how window.requestAnimationFrame acts. Content should
  59222. * make no assumptions of frame rate or vsync behavior as the HMD runs
  59223. * asynchronously from other displays and at differing refresh rates.
  59224. * @param callback Define the eaction to run next frame
  59225. * @returns the request handle it
  59226. */
  59227. requestAnimationFrame(callback: FrameRequestCallback): number;
  59228. /**
  59229. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  59230. * Repeat calls while already presenting will update the VRLayers being displayed.
  59231. * @param layers Define the list of layer to present
  59232. * @returns a promise to know when the request has been fulfilled
  59233. */
  59234. requestPresent(layers: VRLayer[]): Promise<void>;
  59235. /**
  59236. * Reset the pose for this display, treating its current position and
  59237. * orientation as the "origin/zero" values. VRPose.position,
  59238. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  59239. * updated when calling resetPose(). This should be called in only
  59240. * sitting-space experiences.
  59241. */
  59242. resetPose(): void;
  59243. /**
  59244. * The VRLayer provided to the VRDisplay will be captured and presented
  59245. * in the HMD. Calling this function has the same effect on the source
  59246. * canvas as any other operation that uses its source image, and canvases
  59247. * created without preserveDrawingBuffer set to true will be cleared.
  59248. * @param pose Define the pose to submit
  59249. */
  59250. submitFrame(pose?: VRPose): void;
  59251. }
  59252. declare var VRDisplay: {
  59253. prototype: VRDisplay;
  59254. new(): VRDisplay;
  59255. };
  59256. interface VRLayer {
  59257. leftBounds?: number[] | Float32Array | null;
  59258. rightBounds?: number[] | Float32Array | null;
  59259. source?: HTMLCanvasElement | null;
  59260. }
  59261. interface VRDisplayCapabilities {
  59262. readonly canPresent: boolean;
  59263. readonly hasExternalDisplay: boolean;
  59264. readonly hasOrientation: boolean;
  59265. readonly hasPosition: boolean;
  59266. readonly maxLayers: number;
  59267. }
  59268. interface VREyeParameters {
  59269. /** @deprecated */
  59270. readonly fieldOfView: VRFieldOfView;
  59271. readonly offset: Float32Array;
  59272. readonly renderHeight: number;
  59273. readonly renderWidth: number;
  59274. }
  59275. interface VRFieldOfView {
  59276. readonly downDegrees: number;
  59277. readonly leftDegrees: number;
  59278. readonly rightDegrees: number;
  59279. readonly upDegrees: number;
  59280. }
  59281. interface VRFrameData {
  59282. readonly leftProjectionMatrix: Float32Array;
  59283. readonly leftViewMatrix: Float32Array;
  59284. readonly pose: VRPose;
  59285. readonly rightProjectionMatrix: Float32Array;
  59286. readonly rightViewMatrix: Float32Array;
  59287. readonly timestamp: number;
  59288. }
  59289. interface VRPose {
  59290. readonly angularAcceleration: Float32Array | null;
  59291. readonly angularVelocity: Float32Array | null;
  59292. readonly linearAcceleration: Float32Array | null;
  59293. readonly linearVelocity: Float32Array | null;
  59294. readonly orientation: Float32Array | null;
  59295. readonly position: Float32Array | null;
  59296. readonly timestamp: number;
  59297. }
  59298. interface VRStageParameters {
  59299. sittingToStandingTransform?: Float32Array;
  59300. sizeX?: number;
  59301. sizeY?: number;
  59302. }
  59303. interface Navigator {
  59304. getVRDisplays(): Promise<VRDisplay[]>;
  59305. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  59306. }
  59307. interface Window {
  59308. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  59309. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  59310. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  59311. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  59312. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  59313. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  59314. }
  59315. interface Gamepad {
  59316. readonly displayId: number;
  59317. }
  59318. interface XRDevice {
  59319. requestSession(options: XRSessionCreationOptions): Promise<XRSession>;
  59320. supportsSession(options: XRSessionCreationOptions): Promise<void>;
  59321. }
  59322. interface XRSession {
  59323. getInputSources(): Array<any>;
  59324. baseLayer: XRWebGLLayer;
  59325. requestFrameOfReference(type: string): Promise<void>;
  59326. requestHitTest(origin: Float32Array, direction: Float32Array, frameOfReference: any): any;
  59327. end(): Promise<void>;
  59328. requestAnimationFrame: Function;
  59329. addEventListener: Function;
  59330. }
  59331. interface XRSessionCreationOptions {
  59332. outputContext?: WebGLRenderingContext | null;
  59333. immersive?: boolean;
  59334. environmentIntegration?: boolean;
  59335. }
  59336. interface XRLayer {
  59337. getViewport: Function;
  59338. framebufferWidth: number;
  59339. framebufferHeight: number;
  59340. }
  59341. interface XRView {
  59342. projectionMatrix: Float32Array;
  59343. }
  59344. interface XRFrame {
  59345. getDevicePose: Function;
  59346. getInputPose: Function;
  59347. views: Array<XRView>;
  59348. baseLayer: XRLayer;
  59349. }
  59350. interface XRFrameOfReference {
  59351. }
  59352. interface XRWebGLLayer extends XRLayer {
  59353. framebuffer: WebGLFramebuffer;
  59354. }
  59355. declare var XRWebGLLayer: {
  59356. prototype: XRWebGLLayer;
  59357. new(session: XRSession, context?: WebGLRenderingContext): XRWebGLLayer;
  59358. };
  59359. declare module "babylonjs" {
  59360. export * from "babylonjs/Legacy/legacy";
  59361. }
  59362. declare module BABYLON {
  59363. /** Alias type for value that can be null */
  59364. export type Nullable<T> = T | null;
  59365. /**
  59366. * Alias type for number that are floats
  59367. * @ignorenaming
  59368. */
  59369. export type float = number;
  59370. /**
  59371. * Alias type for number that are doubles.
  59372. * @ignorenaming
  59373. */
  59374. export type double = number;
  59375. /**
  59376. * Alias type for number that are integer
  59377. * @ignorenaming
  59378. */
  59379. export type int = number;
  59380. /** Alias type for number array or Float32Array */
  59381. export type FloatArray = number[] | Float32Array;
  59382. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  59383. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  59384. /**
  59385. * Alias for types that can be used by a Buffer or VertexBuffer.
  59386. */
  59387. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  59388. /**
  59389. * Alias type for primitive types
  59390. * @ignorenaming
  59391. */
  59392. type Primitive = undefined | null | boolean | string | number | Function;
  59393. /**
  59394. * Type modifier to make all the properties of an object Readonly
  59395. */
  59396. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  59397. /**
  59398. * Type modifier to make all the properties of an object Readonly recursively
  59399. */
  59400. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  59401. /** @hidden */
  59402. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  59403. }
  59404. /** @hidden */
  59405. /** @hidden */
  59406. type DeepImmutableObject<T> = {
  59407. readonly [K in keyof T]: DeepImmutable<T[K]>;
  59408. };
  59409. }
  59410. declare module BABYLON {
  59411. /**
  59412. * Class containing a set of static utilities functions for arrays.
  59413. */
  59414. export class ArrayTools {
  59415. /**
  59416. * Returns an array of the given size filled with element built from the given constructor and the paramters
  59417. * @param size the number of element to construct and put in the array
  59418. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  59419. * @returns a new array filled with new objects
  59420. */
  59421. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  59422. }
  59423. }
  59424. declare module BABYLON {
  59425. /**
  59426. * Scalar computation library
  59427. */
  59428. export class Scalar {
  59429. /**
  59430. * Two pi constants convenient for computation.
  59431. */
  59432. static TwoPi: number;
  59433. /**
  59434. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  59435. * @param a number
  59436. * @param b number
  59437. * @param epsilon (default = 1.401298E-45)
  59438. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  59439. */
  59440. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  59441. /**
  59442. * Returns a string : the upper case translation of the number i to hexadecimal.
  59443. * @param i number
  59444. * @returns the upper case translation of the number i to hexadecimal.
  59445. */
  59446. static ToHex(i: number): string;
  59447. /**
  59448. * Returns -1 if value is negative and +1 is value is positive.
  59449. * @param value the value
  59450. * @returns the value itself if it's equal to zero.
  59451. */
  59452. static Sign(value: number): number;
  59453. /**
  59454. * Returns the value itself if it's between min and max.
  59455. * Returns min if the value is lower than min.
  59456. * Returns max if the value is greater than max.
  59457. * @param value the value to clmap
  59458. * @param min the min value to clamp to (default: 0)
  59459. * @param max the max value to clamp to (default: 1)
  59460. * @returns the clamped value
  59461. */
  59462. static Clamp(value: number, min?: number, max?: number): number;
  59463. /**
  59464. * the log2 of value.
  59465. * @param value the value to compute log2 of
  59466. * @returns the log2 of value.
  59467. */
  59468. static Log2(value: number): number;
  59469. /**
  59470. * Loops the value, so that it is never larger than length and never smaller than 0.
  59471. *
  59472. * This is similar to the modulo operator but it works with floating point numbers.
  59473. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  59474. * With t = 5 and length = 2.5, the result would be 0.0.
  59475. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  59476. * @param value the value
  59477. * @param length the length
  59478. * @returns the looped value
  59479. */
  59480. static Repeat(value: number, length: number): number;
  59481. /**
  59482. * Normalize the value between 0.0 and 1.0 using min and max values
  59483. * @param value value to normalize
  59484. * @param min max to normalize between
  59485. * @param max min to normalize between
  59486. * @returns the normalized value
  59487. */
  59488. static Normalize(value: number, min: number, max: number): number;
  59489. /**
  59490. * Denormalize the value from 0.0 and 1.0 using min and max values
  59491. * @param normalized value to denormalize
  59492. * @param min max to denormalize between
  59493. * @param max min to denormalize between
  59494. * @returns the denormalized value
  59495. */
  59496. static Denormalize(normalized: number, min: number, max: number): number;
  59497. /**
  59498. * Calculates the shortest difference between two given angles given in degrees.
  59499. * @param current current angle in degrees
  59500. * @param target target angle in degrees
  59501. * @returns the delta
  59502. */
  59503. static DeltaAngle(current: number, target: number): number;
  59504. /**
  59505. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  59506. * @param tx value
  59507. * @param length length
  59508. * @returns The returned value will move back and forth between 0 and length
  59509. */
  59510. static PingPong(tx: number, length: number): number;
  59511. /**
  59512. * Interpolates between min and max with smoothing at the limits.
  59513. *
  59514. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  59515. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  59516. * @param from from
  59517. * @param to to
  59518. * @param tx value
  59519. * @returns the smooth stepped value
  59520. */
  59521. static SmoothStep(from: number, to: number, tx: number): number;
  59522. /**
  59523. * Moves a value current towards target.
  59524. *
  59525. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  59526. * Negative values of maxDelta pushes the value away from target.
  59527. * @param current current value
  59528. * @param target target value
  59529. * @param maxDelta max distance to move
  59530. * @returns resulting value
  59531. */
  59532. static MoveTowards(current: number, target: number, maxDelta: number): number;
  59533. /**
  59534. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  59535. *
  59536. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  59537. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  59538. * @param current current value
  59539. * @param target target value
  59540. * @param maxDelta max distance to move
  59541. * @returns resulting angle
  59542. */
  59543. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  59544. /**
  59545. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  59546. * @param start start value
  59547. * @param end target value
  59548. * @param amount amount to lerp between
  59549. * @returns the lerped value
  59550. */
  59551. static Lerp(start: number, end: number, amount: number): number;
  59552. /**
  59553. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  59554. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  59555. * @param start start value
  59556. * @param end target value
  59557. * @param amount amount to lerp between
  59558. * @returns the lerped value
  59559. */
  59560. static LerpAngle(start: number, end: number, amount: number): number;
  59561. /**
  59562. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  59563. * @param a start value
  59564. * @param b target value
  59565. * @param value value between a and b
  59566. * @returns the inverseLerp value
  59567. */
  59568. static InverseLerp(a: number, b: number, value: number): number;
  59569. /**
  59570. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  59571. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  59572. * @param value1 spline value
  59573. * @param tangent1 spline value
  59574. * @param value2 spline value
  59575. * @param tangent2 spline value
  59576. * @param amount input value
  59577. * @returns hermite result
  59578. */
  59579. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  59580. /**
  59581. * Returns a random float number between and min and max values
  59582. * @param min min value of random
  59583. * @param max max value of random
  59584. * @returns random value
  59585. */
  59586. static RandomRange(min: number, max: number): number;
  59587. /**
  59588. * This function returns percentage of a number in a given range.
  59589. *
  59590. * RangeToPercent(40,20,60) will return 0.5 (50%)
  59591. * RangeToPercent(34,0,100) will return 0.34 (34%)
  59592. * @param number to convert to percentage
  59593. * @param min min range
  59594. * @param max max range
  59595. * @returns the percentage
  59596. */
  59597. static RangeToPercent(number: number, min: number, max: number): number;
  59598. /**
  59599. * This function returns number that corresponds to the percentage in a given range.
  59600. *
  59601. * PercentToRange(0.34,0,100) will return 34.
  59602. * @param percent to convert to number
  59603. * @param min min range
  59604. * @param max max range
  59605. * @returns the number
  59606. */
  59607. static PercentToRange(percent: number, min: number, max: number): number;
  59608. /**
  59609. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  59610. * @param angle The angle to normalize in radian.
  59611. * @return The converted angle.
  59612. */
  59613. static NormalizeRadians(angle: number): number;
  59614. }
  59615. }
  59616. declare module BABYLON {
  59617. /**
  59618. * Constant used to convert a value to gamma space
  59619. * @ignorenaming
  59620. */
  59621. export const ToGammaSpace: number;
  59622. /**
  59623. * Constant used to convert a value to linear space
  59624. * @ignorenaming
  59625. */
  59626. export const ToLinearSpace = 2.2;
  59627. /**
  59628. * Constant used to define the minimal number value in Babylon.js
  59629. * @ignorenaming
  59630. */
  59631. let Epsilon: number;
  59632. /**
  59633. * Class used to hold a RBG color
  59634. */
  59635. export class Color3 {
  59636. /**
  59637. * Defines the red component (between 0 and 1, default is 0)
  59638. */
  59639. r: number;
  59640. /**
  59641. * Defines the green component (between 0 and 1, default is 0)
  59642. */
  59643. g: number;
  59644. /**
  59645. * Defines the blue component (between 0 and 1, default is 0)
  59646. */
  59647. b: number;
  59648. /**
  59649. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  59650. * @param r defines the red component (between 0 and 1, default is 0)
  59651. * @param g defines the green component (between 0 and 1, default is 0)
  59652. * @param b defines the blue component (between 0 and 1, default is 0)
  59653. */
  59654. constructor(
  59655. /**
  59656. * Defines the red component (between 0 and 1, default is 0)
  59657. */
  59658. r?: number,
  59659. /**
  59660. * Defines the green component (between 0 and 1, default is 0)
  59661. */
  59662. g?: number,
  59663. /**
  59664. * Defines the blue component (between 0 and 1, default is 0)
  59665. */
  59666. b?: number);
  59667. /**
  59668. * Creates a string with the Color3 current values
  59669. * @returns the string representation of the Color3 object
  59670. */
  59671. toString(): string;
  59672. /**
  59673. * Returns the string "Color3"
  59674. * @returns "Color3"
  59675. */
  59676. getClassName(): string;
  59677. /**
  59678. * Compute the Color3 hash code
  59679. * @returns an unique number that can be used to hash Color3 objects
  59680. */
  59681. getHashCode(): number;
  59682. /**
  59683. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  59684. * @param array defines the array where to store the r,g,b components
  59685. * @param index defines an optional index in the target array to define where to start storing values
  59686. * @returns the current Color3 object
  59687. */
  59688. toArray(array: FloatArray, index?: number): Color3;
  59689. /**
  59690. * Returns a new Color4 object from the current Color3 and the given alpha
  59691. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  59692. * @returns a new Color4 object
  59693. */
  59694. toColor4(alpha?: number): Color4;
  59695. /**
  59696. * Returns a new array populated with 3 numeric elements : red, green and blue values
  59697. * @returns the new array
  59698. */
  59699. asArray(): number[];
  59700. /**
  59701. * Returns the luminance value
  59702. * @returns a float value
  59703. */
  59704. toLuminance(): number;
  59705. /**
  59706. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  59707. * @param otherColor defines the second operand
  59708. * @returns the new Color3 object
  59709. */
  59710. multiply(otherColor: DeepImmutable<Color3>): Color3;
  59711. /**
  59712. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  59713. * @param otherColor defines the second operand
  59714. * @param result defines the Color3 object where to store the result
  59715. * @returns the current Color3
  59716. */
  59717. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  59718. /**
  59719. * Determines equality between Color3 objects
  59720. * @param otherColor defines the second operand
  59721. * @returns true if the rgb values are equal to the given ones
  59722. */
  59723. equals(otherColor: DeepImmutable<Color3>): boolean;
  59724. /**
  59725. * Determines equality between the current Color3 object and a set of r,b,g values
  59726. * @param r defines the red component to check
  59727. * @param g defines the green component to check
  59728. * @param b defines the blue component to check
  59729. * @returns true if the rgb values are equal to the given ones
  59730. */
  59731. equalsFloats(r: number, g: number, b: number): boolean;
  59732. /**
  59733. * Multiplies in place each rgb value by scale
  59734. * @param scale defines the scaling factor
  59735. * @returns the updated Color3
  59736. */
  59737. scale(scale: number): Color3;
  59738. /**
  59739. * Multiplies the rgb values by scale and stores the result into "result"
  59740. * @param scale defines the scaling factor
  59741. * @param result defines the Color3 object where to store the result
  59742. * @returns the unmodified current Color3
  59743. */
  59744. scaleToRef(scale: number, result: Color3): Color3;
  59745. /**
  59746. * Scale the current Color3 values by a factor and add the result to a given Color3
  59747. * @param scale defines the scale factor
  59748. * @param result defines color to store the result into
  59749. * @returns the unmodified current Color3
  59750. */
  59751. scaleAndAddToRef(scale: number, result: Color3): Color3;
  59752. /**
  59753. * Clamps the rgb values by the min and max values and stores the result into "result"
  59754. * @param min defines minimum clamping value (default is 0)
  59755. * @param max defines maximum clamping value (default is 1)
  59756. * @param result defines color to store the result into
  59757. * @returns the original Color3
  59758. */
  59759. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  59760. /**
  59761. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  59762. * @param otherColor defines the second operand
  59763. * @returns the new Color3
  59764. */
  59765. add(otherColor: DeepImmutable<Color3>): Color3;
  59766. /**
  59767. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  59768. * @param otherColor defines the second operand
  59769. * @param result defines Color3 object to store the result into
  59770. * @returns the unmodified current Color3
  59771. */
  59772. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  59773. /**
  59774. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  59775. * @param otherColor defines the second operand
  59776. * @returns the new Color3
  59777. */
  59778. subtract(otherColor: DeepImmutable<Color3>): Color3;
  59779. /**
  59780. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  59781. * @param otherColor defines the second operand
  59782. * @param result defines Color3 object to store the result into
  59783. * @returns the unmodified current Color3
  59784. */
  59785. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  59786. /**
  59787. * Copy the current object
  59788. * @returns a new Color3 copied the current one
  59789. */
  59790. clone(): Color3;
  59791. /**
  59792. * Copies the rgb values from the source in the current Color3
  59793. * @param source defines the source Color3 object
  59794. * @returns the updated Color3 object
  59795. */
  59796. copyFrom(source: DeepImmutable<Color3>): Color3;
  59797. /**
  59798. * Updates the Color3 rgb values from the given floats
  59799. * @param r defines the red component to read from
  59800. * @param g defines the green component to read from
  59801. * @param b defines the blue component to read from
  59802. * @returns the current Color3 object
  59803. */
  59804. copyFromFloats(r: number, g: number, b: number): Color3;
  59805. /**
  59806. * Updates the Color3 rgb values from the given floats
  59807. * @param r defines the red component to read from
  59808. * @param g defines the green component to read from
  59809. * @param b defines the blue component to read from
  59810. * @returns the current Color3 object
  59811. */
  59812. set(r: number, g: number, b: number): Color3;
  59813. /**
  59814. * Compute the Color3 hexadecimal code as a string
  59815. * @returns a string containing the hexadecimal representation of the Color3 object
  59816. */
  59817. toHexString(): string;
  59818. /**
  59819. * Computes a new Color3 converted from the current one to linear space
  59820. * @returns a new Color3 object
  59821. */
  59822. toLinearSpace(): Color3;
  59823. /**
  59824. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  59825. * @param convertedColor defines the Color3 object where to store the linear space version
  59826. * @returns the unmodified Color3
  59827. */
  59828. toLinearSpaceToRef(convertedColor: Color3): Color3;
  59829. /**
  59830. * Computes a new Color3 converted from the current one to gamma space
  59831. * @returns a new Color3 object
  59832. */
  59833. toGammaSpace(): Color3;
  59834. /**
  59835. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  59836. * @param convertedColor defines the Color3 object where to store the gamma space version
  59837. * @returns the unmodified Color3
  59838. */
  59839. toGammaSpaceToRef(convertedColor: Color3): Color3;
  59840. private static _BlackReadOnly;
  59841. /**
  59842. * Creates a new Color3 from the string containing valid hexadecimal values
  59843. * @param hex defines a string containing valid hexadecimal values
  59844. * @returns a new Color3 object
  59845. */
  59846. static FromHexString(hex: string): Color3;
  59847. /**
  59848. * Creates a new Vector3 from the starting index of the given array
  59849. * @param array defines the source array
  59850. * @param offset defines an offset in the source array
  59851. * @returns a new Color3 object
  59852. */
  59853. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  59854. /**
  59855. * Creates a new Color3 from integer values (< 256)
  59856. * @param r defines the red component to read from (value between 0 and 255)
  59857. * @param g defines the green component to read from (value between 0 and 255)
  59858. * @param b defines the blue component to read from (value between 0 and 255)
  59859. * @returns a new Color3 object
  59860. */
  59861. static FromInts(r: number, g: number, b: number): Color3;
  59862. /**
  59863. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  59864. * @param start defines the start Color3 value
  59865. * @param end defines the end Color3 value
  59866. * @param amount defines the gradient value between start and end
  59867. * @returns a new Color3 object
  59868. */
  59869. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  59870. /**
  59871. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  59872. * @param left defines the start value
  59873. * @param right defines the end value
  59874. * @param amount defines the gradient factor
  59875. * @param result defines the Color3 object where to store the result
  59876. */
  59877. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  59878. /**
  59879. * Returns a Color3 value containing a red color
  59880. * @returns a new Color3 object
  59881. */
  59882. static Red(): Color3;
  59883. /**
  59884. * Returns a Color3 value containing a green color
  59885. * @returns a new Color3 object
  59886. */
  59887. static Green(): Color3;
  59888. /**
  59889. * Returns a Color3 value containing a blue color
  59890. * @returns a new Color3 object
  59891. */
  59892. static Blue(): Color3;
  59893. /**
  59894. * Returns a Color3 value containing a black color
  59895. * @returns a new Color3 object
  59896. */
  59897. static Black(): Color3;
  59898. /**
  59899. * Gets a Color3 value containing a black color that must not be updated
  59900. */
  59901. static readonly BlackReadOnly: DeepImmutable<Color3>;
  59902. /**
  59903. * Returns a Color3 value containing a white color
  59904. * @returns a new Color3 object
  59905. */
  59906. static White(): Color3;
  59907. /**
  59908. * Returns a Color3 value containing a purple color
  59909. * @returns a new Color3 object
  59910. */
  59911. static Purple(): Color3;
  59912. /**
  59913. * Returns a Color3 value containing a magenta color
  59914. * @returns a new Color3 object
  59915. */
  59916. static Magenta(): Color3;
  59917. /**
  59918. * Returns a Color3 value containing a yellow color
  59919. * @returns a new Color3 object
  59920. */
  59921. static Yellow(): Color3;
  59922. /**
  59923. * Returns a Color3 value containing a gray color
  59924. * @returns a new Color3 object
  59925. */
  59926. static Gray(): Color3;
  59927. /**
  59928. * Returns a Color3 value containing a teal color
  59929. * @returns a new Color3 object
  59930. */
  59931. static Teal(): Color3;
  59932. /**
  59933. * Returns a Color3 value containing a random color
  59934. * @returns a new Color3 object
  59935. */
  59936. static Random(): Color3;
  59937. }
  59938. /**
  59939. * Class used to hold a RBGA color
  59940. */
  59941. export class Color4 {
  59942. /**
  59943. * Defines the red component (between 0 and 1, default is 0)
  59944. */
  59945. r: number;
  59946. /**
  59947. * Defines the green component (between 0 and 1, default is 0)
  59948. */
  59949. g: number;
  59950. /**
  59951. * Defines the blue component (between 0 and 1, default is 0)
  59952. */
  59953. b: number;
  59954. /**
  59955. * Defines the alpha component (between 0 and 1, default is 1)
  59956. */
  59957. a: number;
  59958. /**
  59959. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  59960. * @param r defines the red component (between 0 and 1, default is 0)
  59961. * @param g defines the green component (between 0 and 1, default is 0)
  59962. * @param b defines the blue component (between 0 and 1, default is 0)
  59963. * @param a defines the alpha component (between 0 and 1, default is 1)
  59964. */
  59965. constructor(
  59966. /**
  59967. * Defines the red component (between 0 and 1, default is 0)
  59968. */
  59969. r?: number,
  59970. /**
  59971. * Defines the green component (between 0 and 1, default is 0)
  59972. */
  59973. g?: number,
  59974. /**
  59975. * Defines the blue component (between 0 and 1, default is 0)
  59976. */
  59977. b?: number,
  59978. /**
  59979. * Defines the alpha component (between 0 and 1, default is 1)
  59980. */
  59981. a?: number);
  59982. /**
  59983. * Adds in place the given Color4 values to the current Color4 object
  59984. * @param right defines the second operand
  59985. * @returns the current updated Color4 object
  59986. */
  59987. addInPlace(right: DeepImmutable<Color4>): Color4;
  59988. /**
  59989. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  59990. * @returns the new array
  59991. */
  59992. asArray(): number[];
  59993. /**
  59994. * Stores from the starting index in the given array the Color4 successive values
  59995. * @param array defines the array where to store the r,g,b components
  59996. * @param index defines an optional index in the target array to define where to start storing values
  59997. * @returns the current Color4 object
  59998. */
  59999. toArray(array: number[], index?: number): Color4;
  60000. /**
  60001. * Determines equality between Color4 objects
  60002. * @param otherColor defines the second operand
  60003. * @returns true if the rgba values are equal to the given ones
  60004. */
  60005. equals(otherColor: DeepImmutable<Color4>): boolean;
  60006. /**
  60007. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  60008. * @param right defines the second operand
  60009. * @returns a new Color4 object
  60010. */
  60011. add(right: DeepImmutable<Color4>): Color4;
  60012. /**
  60013. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  60014. * @param right defines the second operand
  60015. * @returns a new Color4 object
  60016. */
  60017. subtract(right: DeepImmutable<Color4>): Color4;
  60018. /**
  60019. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  60020. * @param right defines the second operand
  60021. * @param result defines the Color4 object where to store the result
  60022. * @returns the current Color4 object
  60023. */
  60024. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  60025. /**
  60026. * Creates a new Color4 with the current Color4 values multiplied by scale
  60027. * @param scale defines the scaling factor to apply
  60028. * @returns a new Color4 object
  60029. */
  60030. scale(scale: number): Color4;
  60031. /**
  60032. * Multiplies the current Color4 values by scale and stores the result in "result"
  60033. * @param scale defines the scaling factor to apply
  60034. * @param result defines the Color4 object where to store the result
  60035. * @returns the current unmodified Color4
  60036. */
  60037. scaleToRef(scale: number, result: Color4): Color4;
  60038. /**
  60039. * Scale the current Color4 values by a factor and add the result to a given Color4
  60040. * @param scale defines the scale factor
  60041. * @param result defines the Color4 object where to store the result
  60042. * @returns the unmodified current Color4
  60043. */
  60044. scaleAndAddToRef(scale: number, result: Color4): Color4;
  60045. /**
  60046. * Clamps the rgb values by the min and max values and stores the result into "result"
  60047. * @param min defines minimum clamping value (default is 0)
  60048. * @param max defines maximum clamping value (default is 1)
  60049. * @param result defines color to store the result into.
  60050. * @returns the cuurent Color4
  60051. */
  60052. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  60053. /**
  60054. * Multipy an Color4 value by another and return a new Color4 object
  60055. * @param color defines the Color4 value to multiply by
  60056. * @returns a new Color4 object
  60057. */
  60058. multiply(color: Color4): Color4;
  60059. /**
  60060. * Multipy a Color4 value by another and push the result in a reference value
  60061. * @param color defines the Color4 value to multiply by
  60062. * @param result defines the Color4 to fill the result in
  60063. * @returns the result Color4
  60064. */
  60065. multiplyToRef(color: Color4, result: Color4): Color4;
  60066. /**
  60067. * Creates a string with the Color4 current values
  60068. * @returns the string representation of the Color4 object
  60069. */
  60070. toString(): string;
  60071. /**
  60072. * Returns the string "Color4"
  60073. * @returns "Color4"
  60074. */
  60075. getClassName(): string;
  60076. /**
  60077. * Compute the Color4 hash code
  60078. * @returns an unique number that can be used to hash Color4 objects
  60079. */
  60080. getHashCode(): number;
  60081. /**
  60082. * Creates a new Color4 copied from the current one
  60083. * @returns a new Color4 object
  60084. */
  60085. clone(): Color4;
  60086. /**
  60087. * Copies the given Color4 values into the current one
  60088. * @param source defines the source Color4 object
  60089. * @returns the current updated Color4 object
  60090. */
  60091. copyFrom(source: Color4): Color4;
  60092. /**
  60093. * Copies the given float values into the current one
  60094. * @param r defines the red component to read from
  60095. * @param g defines the green component to read from
  60096. * @param b defines the blue component to read from
  60097. * @param a defines the alpha component to read from
  60098. * @returns the current updated Color4 object
  60099. */
  60100. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  60101. /**
  60102. * Copies the given float values into the current one
  60103. * @param r defines the red component to read from
  60104. * @param g defines the green component to read from
  60105. * @param b defines the blue component to read from
  60106. * @param a defines the alpha component to read from
  60107. * @returns the current updated Color4 object
  60108. */
  60109. set(r: number, g: number, b: number, a: number): Color4;
  60110. /**
  60111. * Compute the Color4 hexadecimal code as a string
  60112. * @returns a string containing the hexadecimal representation of the Color4 object
  60113. */
  60114. toHexString(): string;
  60115. /**
  60116. * Computes a new Color4 converted from the current one to linear space
  60117. * @returns a new Color4 object
  60118. */
  60119. toLinearSpace(): Color4;
  60120. /**
  60121. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  60122. * @param convertedColor defines the Color4 object where to store the linear space version
  60123. * @returns the unmodified Color4
  60124. */
  60125. toLinearSpaceToRef(convertedColor: Color4): Color4;
  60126. /**
  60127. * Computes a new Color4 converted from the current one to gamma space
  60128. * @returns a new Color4 object
  60129. */
  60130. toGammaSpace(): Color4;
  60131. /**
  60132. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  60133. * @param convertedColor defines the Color4 object where to store the gamma space version
  60134. * @returns the unmodified Color4
  60135. */
  60136. toGammaSpaceToRef(convertedColor: Color4): Color4;
  60137. /**
  60138. * Creates a new Color4 from the string containing valid hexadecimal values
  60139. * @param hex defines a string containing valid hexadecimal values
  60140. * @returns a new Color4 object
  60141. */
  60142. static FromHexString(hex: string): Color4;
  60143. /**
  60144. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  60145. * @param left defines the start value
  60146. * @param right defines the end value
  60147. * @param amount defines the gradient factor
  60148. * @returns a new Color4 object
  60149. */
  60150. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  60151. /**
  60152. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  60153. * @param left defines the start value
  60154. * @param right defines the end value
  60155. * @param amount defines the gradient factor
  60156. * @param result defines the Color4 object where to store data
  60157. */
  60158. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  60159. /**
  60160. * Creates a new Color4 from a Color3 and an alpha value
  60161. * @param color3 defines the source Color3 to read from
  60162. * @param alpha defines the alpha component (1.0 by default)
  60163. * @returns a new Color4 object
  60164. */
  60165. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  60166. /**
  60167. * Creates a new Color4 from the starting index element of the given array
  60168. * @param array defines the source array to read from
  60169. * @param offset defines the offset in the source array
  60170. * @returns a new Color4 object
  60171. */
  60172. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  60173. /**
  60174. * Creates a new Color3 from integer values (< 256)
  60175. * @param r defines the red component to read from (value between 0 and 255)
  60176. * @param g defines the green component to read from (value between 0 and 255)
  60177. * @param b defines the blue component to read from (value between 0 and 255)
  60178. * @param a defines the alpha component to read from (value between 0 and 255)
  60179. * @returns a new Color3 object
  60180. */
  60181. static FromInts(r: number, g: number, b: number, a: number): Color4;
  60182. /**
  60183. * Check the content of a given array and convert it to an array containing RGBA data
  60184. * If the original array was already containing count * 4 values then it is returned directly
  60185. * @param colors defines the array to check
  60186. * @param count defines the number of RGBA data to expect
  60187. * @returns an array containing count * 4 values (RGBA)
  60188. */
  60189. static CheckColors4(colors: number[], count: number): number[];
  60190. }
  60191. /**
  60192. * Class representing a vector containing 2 coordinates
  60193. */
  60194. export class Vector2 {
  60195. /** defines the first coordinate */
  60196. x: number;
  60197. /** defines the second coordinate */
  60198. y: number;
  60199. /**
  60200. * Creates a new Vector2 from the given x and y coordinates
  60201. * @param x defines the first coordinate
  60202. * @param y defines the second coordinate
  60203. */
  60204. constructor(
  60205. /** defines the first coordinate */
  60206. x?: number,
  60207. /** defines the second coordinate */
  60208. y?: number);
  60209. /**
  60210. * Gets a string with the Vector2 coordinates
  60211. * @returns a string with the Vector2 coordinates
  60212. */
  60213. toString(): string;
  60214. /**
  60215. * Gets class name
  60216. * @returns the string "Vector2"
  60217. */
  60218. getClassName(): string;
  60219. /**
  60220. * Gets current vector hash code
  60221. * @returns the Vector2 hash code as a number
  60222. */
  60223. getHashCode(): number;
  60224. /**
  60225. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  60226. * @param array defines the source array
  60227. * @param index defines the offset in source array
  60228. * @returns the current Vector2
  60229. */
  60230. toArray(array: FloatArray, index?: number): Vector2;
  60231. /**
  60232. * Copy the current vector to an array
  60233. * @returns a new array with 2 elements: the Vector2 coordinates.
  60234. */
  60235. asArray(): number[];
  60236. /**
  60237. * Sets the Vector2 coordinates with the given Vector2 coordinates
  60238. * @param source defines the source Vector2
  60239. * @returns the current updated Vector2
  60240. */
  60241. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  60242. /**
  60243. * Sets the Vector2 coordinates with the given floats
  60244. * @param x defines the first coordinate
  60245. * @param y defines the second coordinate
  60246. * @returns the current updated Vector2
  60247. */
  60248. copyFromFloats(x: number, y: number): Vector2;
  60249. /**
  60250. * Sets the Vector2 coordinates with the given floats
  60251. * @param x defines the first coordinate
  60252. * @param y defines the second coordinate
  60253. * @returns the current updated Vector2
  60254. */
  60255. set(x: number, y: number): Vector2;
  60256. /**
  60257. * Add another vector with the current one
  60258. * @param otherVector defines the other vector
  60259. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  60260. */
  60261. add(otherVector: DeepImmutable<Vector2>): Vector2;
  60262. /**
  60263. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  60264. * @param otherVector defines the other vector
  60265. * @param result defines the target vector
  60266. * @returns the unmodified current Vector2
  60267. */
  60268. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  60269. /**
  60270. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  60271. * @param otherVector defines the other vector
  60272. * @returns the current updated Vector2
  60273. */
  60274. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  60275. /**
  60276. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  60277. * @param otherVector defines the other vector
  60278. * @returns a new Vector2
  60279. */
  60280. addVector3(otherVector: Vector3): Vector2;
  60281. /**
  60282. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  60283. * @param otherVector defines the other vector
  60284. * @returns a new Vector2
  60285. */
  60286. subtract(otherVector: Vector2): Vector2;
  60287. /**
  60288. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  60289. * @param otherVector defines the other vector
  60290. * @param result defines the target vector
  60291. * @returns the unmodified current Vector2
  60292. */
  60293. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  60294. /**
  60295. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  60296. * @param otherVector defines the other vector
  60297. * @returns the current updated Vector2
  60298. */
  60299. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  60300. /**
  60301. * Multiplies in place the current Vector2 coordinates by the given ones
  60302. * @param otherVector defines the other vector
  60303. * @returns the current updated Vector2
  60304. */
  60305. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  60306. /**
  60307. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  60308. * @param otherVector defines the other vector
  60309. * @returns a new Vector2
  60310. */
  60311. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  60312. /**
  60313. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  60314. * @param otherVector defines the other vector
  60315. * @param result defines the target vector
  60316. * @returns the unmodified current Vector2
  60317. */
  60318. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  60319. /**
  60320. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  60321. * @param x defines the first coordinate
  60322. * @param y defines the second coordinate
  60323. * @returns a new Vector2
  60324. */
  60325. multiplyByFloats(x: number, y: number): Vector2;
  60326. /**
  60327. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  60328. * @param otherVector defines the other vector
  60329. * @returns a new Vector2
  60330. */
  60331. divide(otherVector: Vector2): Vector2;
  60332. /**
  60333. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  60334. * @param otherVector defines the other vector
  60335. * @param result defines the target vector
  60336. * @returns the unmodified current Vector2
  60337. */
  60338. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  60339. /**
  60340. * Divides the current Vector2 coordinates by the given ones
  60341. * @param otherVector defines the other vector
  60342. * @returns the current updated Vector2
  60343. */
  60344. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  60345. /**
  60346. * Gets a new Vector2 with current Vector2 negated coordinates
  60347. * @returns a new Vector2
  60348. */
  60349. negate(): Vector2;
  60350. /**
  60351. * Multiply the Vector2 coordinates by scale
  60352. * @param scale defines the scaling factor
  60353. * @returns the current updated Vector2
  60354. */
  60355. scaleInPlace(scale: number): Vector2;
  60356. /**
  60357. * Returns a new Vector2 scaled by "scale" from the current Vector2
  60358. * @param scale defines the scaling factor
  60359. * @returns a new Vector2
  60360. */
  60361. scale(scale: number): Vector2;
  60362. /**
  60363. * Scale the current Vector2 values by a factor to a given Vector2
  60364. * @param scale defines the scale factor
  60365. * @param result defines the Vector2 object where to store the result
  60366. * @returns the unmodified current Vector2
  60367. */
  60368. scaleToRef(scale: number, result: Vector2): Vector2;
  60369. /**
  60370. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  60371. * @param scale defines the scale factor
  60372. * @param result defines the Vector2 object where to store the result
  60373. * @returns the unmodified current Vector2
  60374. */
  60375. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  60376. /**
  60377. * Gets a boolean if two vectors are equals
  60378. * @param otherVector defines the other vector
  60379. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  60380. */
  60381. equals(otherVector: DeepImmutable<Vector2>): boolean;
  60382. /**
  60383. * Gets a boolean if two vectors are equals (using an epsilon value)
  60384. * @param otherVector defines the other vector
  60385. * @param epsilon defines the minimal distance to consider equality
  60386. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  60387. */
  60388. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  60389. /**
  60390. * Gets a new Vector2 from current Vector2 floored values
  60391. * @returns a new Vector2
  60392. */
  60393. floor(): Vector2;
  60394. /**
  60395. * Gets a new Vector2 from current Vector2 floored values
  60396. * @returns a new Vector2
  60397. */
  60398. fract(): Vector2;
  60399. /**
  60400. * Gets the length of the vector
  60401. * @returns the vector length (float)
  60402. */
  60403. length(): number;
  60404. /**
  60405. * Gets the vector squared length
  60406. * @returns the vector squared length (float)
  60407. */
  60408. lengthSquared(): number;
  60409. /**
  60410. * Normalize the vector
  60411. * @returns the current updated Vector2
  60412. */
  60413. normalize(): Vector2;
  60414. /**
  60415. * Gets a new Vector2 copied from the Vector2
  60416. * @returns a new Vector2
  60417. */
  60418. clone(): Vector2;
  60419. /**
  60420. * Gets a new Vector2(0, 0)
  60421. * @returns a new Vector2
  60422. */
  60423. static Zero(): Vector2;
  60424. /**
  60425. * Gets a new Vector2(1, 1)
  60426. * @returns a new Vector2
  60427. */
  60428. static One(): Vector2;
  60429. /**
  60430. * Gets a new Vector2 set from the given index element of the given array
  60431. * @param array defines the data source
  60432. * @param offset defines the offset in the data source
  60433. * @returns a new Vector2
  60434. */
  60435. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  60436. /**
  60437. * Sets "result" from the given index element of the given array
  60438. * @param array defines the data source
  60439. * @param offset defines the offset in the data source
  60440. * @param result defines the target vector
  60441. */
  60442. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  60443. /**
  60444. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  60445. * @param value1 defines 1st point of control
  60446. * @param value2 defines 2nd point of control
  60447. * @param value3 defines 3rd point of control
  60448. * @param value4 defines 4th point of control
  60449. * @param amount defines the interpolation factor
  60450. * @returns a new Vector2
  60451. */
  60452. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  60453. /**
  60454. * 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".
  60455. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  60456. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  60457. * @param value defines the value to clamp
  60458. * @param min defines the lower limit
  60459. * @param max defines the upper limit
  60460. * @returns a new Vector2
  60461. */
  60462. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  60463. /**
  60464. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  60465. * @param value1 defines the 1st control point
  60466. * @param tangent1 defines the outgoing tangent
  60467. * @param value2 defines the 2nd control point
  60468. * @param tangent2 defines the incoming tangent
  60469. * @param amount defines the interpolation factor
  60470. * @returns a new Vector2
  60471. */
  60472. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  60473. /**
  60474. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  60475. * @param start defines the start vector
  60476. * @param end defines the end vector
  60477. * @param amount defines the interpolation factor
  60478. * @returns a new Vector2
  60479. */
  60480. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  60481. /**
  60482. * Gets the dot product of the vector "left" and the vector "right"
  60483. * @param left defines first vector
  60484. * @param right defines second vector
  60485. * @returns the dot product (float)
  60486. */
  60487. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  60488. /**
  60489. * Returns a new Vector2 equal to the normalized given vector
  60490. * @param vector defines the vector to normalize
  60491. * @returns a new Vector2
  60492. */
  60493. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  60494. /**
  60495. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  60496. * @param left defines 1st vector
  60497. * @param right defines 2nd vector
  60498. * @returns a new Vector2
  60499. */
  60500. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  60501. /**
  60502. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  60503. * @param left defines 1st vector
  60504. * @param right defines 2nd vector
  60505. * @returns a new Vector2
  60506. */
  60507. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  60508. /**
  60509. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  60510. * @param vector defines the vector to transform
  60511. * @param transformation defines the matrix to apply
  60512. * @returns a new Vector2
  60513. */
  60514. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  60515. /**
  60516. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  60517. * @param vector defines the vector to transform
  60518. * @param transformation defines the matrix to apply
  60519. * @param result defines the target vector
  60520. */
  60521. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  60522. /**
  60523. * Determines if a given vector is included in a triangle
  60524. * @param p defines the vector to test
  60525. * @param p0 defines 1st triangle point
  60526. * @param p1 defines 2nd triangle point
  60527. * @param p2 defines 3rd triangle point
  60528. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  60529. */
  60530. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  60531. /**
  60532. * Gets the distance between the vectors "value1" and "value2"
  60533. * @param value1 defines first vector
  60534. * @param value2 defines second vector
  60535. * @returns the distance between vectors
  60536. */
  60537. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  60538. /**
  60539. * Returns the squared distance between the vectors "value1" and "value2"
  60540. * @param value1 defines first vector
  60541. * @param value2 defines second vector
  60542. * @returns the squared distance between vectors
  60543. */
  60544. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  60545. /**
  60546. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  60547. * @param value1 defines first vector
  60548. * @param value2 defines second vector
  60549. * @returns a new Vector2
  60550. */
  60551. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  60552. /**
  60553. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  60554. * @param p defines the middle point
  60555. * @param segA defines one point of the segment
  60556. * @param segB defines the other point of the segment
  60557. * @returns the shortest distance
  60558. */
  60559. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  60560. }
  60561. /**
  60562. * Classed used to store (x,y,z) vector representation
  60563. * A Vector3 is the main object used in 3D geometry
  60564. * It can represent etiher the coordinates of a point the space, either a direction
  60565. * Reminder: js uses a left handed forward facing system
  60566. */
  60567. export class Vector3 {
  60568. /**
  60569. * Defines the first coordinates (on X axis)
  60570. */
  60571. x: number;
  60572. /**
  60573. * Defines the second coordinates (on Y axis)
  60574. */
  60575. y: number;
  60576. /**
  60577. * Defines the third coordinates (on Z axis)
  60578. */
  60579. z: number;
  60580. private static _UpReadOnly;
  60581. /**
  60582. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  60583. * @param x defines the first coordinates (on X axis)
  60584. * @param y defines the second coordinates (on Y axis)
  60585. * @param z defines the third coordinates (on Z axis)
  60586. */
  60587. constructor(
  60588. /**
  60589. * Defines the first coordinates (on X axis)
  60590. */
  60591. x?: number,
  60592. /**
  60593. * Defines the second coordinates (on Y axis)
  60594. */
  60595. y?: number,
  60596. /**
  60597. * Defines the third coordinates (on Z axis)
  60598. */
  60599. z?: number);
  60600. /**
  60601. * Creates a string representation of the Vector3
  60602. * @returns a string with the Vector3 coordinates.
  60603. */
  60604. toString(): string;
  60605. /**
  60606. * Gets the class name
  60607. * @returns the string "Vector3"
  60608. */
  60609. getClassName(): string;
  60610. /**
  60611. * Creates the Vector3 hash code
  60612. * @returns a number which tends to be unique between Vector3 instances
  60613. */
  60614. getHashCode(): number;
  60615. /**
  60616. * Creates an array containing three elements : the coordinates of the Vector3
  60617. * @returns a new array of numbers
  60618. */
  60619. asArray(): number[];
  60620. /**
  60621. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  60622. * @param array defines the destination array
  60623. * @param index defines the offset in the destination array
  60624. * @returns the current Vector3
  60625. */
  60626. toArray(array: FloatArray, index?: number): Vector3;
  60627. /**
  60628. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  60629. * @returns a new Quaternion object, computed from the Vector3 coordinates
  60630. */
  60631. toQuaternion(): Quaternion;
  60632. /**
  60633. * Adds the given vector to the current Vector3
  60634. * @param otherVector defines the second operand
  60635. * @returns the current updated Vector3
  60636. */
  60637. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  60638. /**
  60639. * Adds the given coordinates to the current Vector3
  60640. * @param x defines the x coordinate of the operand
  60641. * @param y defines the y coordinate of the operand
  60642. * @param z defines the z coordinate of the operand
  60643. * @returns the current updated Vector3
  60644. */
  60645. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  60646. /**
  60647. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  60648. * @param otherVector defines the second operand
  60649. * @returns the resulting Vector3
  60650. */
  60651. add(otherVector: DeepImmutable<Vector3>): Vector3;
  60652. /**
  60653. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  60654. * @param otherVector defines the second operand
  60655. * @param result defines the Vector3 object where to store the result
  60656. * @returns the current Vector3
  60657. */
  60658. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  60659. /**
  60660. * Subtract the given vector from the current Vector3
  60661. * @param otherVector defines the second operand
  60662. * @returns the current updated Vector3
  60663. */
  60664. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  60665. /**
  60666. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  60667. * @param otherVector defines the second operand
  60668. * @returns the resulting Vector3
  60669. */
  60670. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  60671. /**
  60672. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  60673. * @param otherVector defines the second operand
  60674. * @param result defines the Vector3 object where to store the result
  60675. * @returns the current Vector3
  60676. */
  60677. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  60678. /**
  60679. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  60680. * @param x defines the x coordinate of the operand
  60681. * @param y defines the y coordinate of the operand
  60682. * @param z defines the z coordinate of the operand
  60683. * @returns the resulting Vector3
  60684. */
  60685. subtractFromFloats(x: number, y: number, z: number): Vector3;
  60686. /**
  60687. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  60688. * @param x defines the x coordinate of the operand
  60689. * @param y defines the y coordinate of the operand
  60690. * @param z defines the z coordinate of the operand
  60691. * @param result defines the Vector3 object where to store the result
  60692. * @returns the current Vector3
  60693. */
  60694. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  60695. /**
  60696. * Gets a new Vector3 set with the current Vector3 negated coordinates
  60697. * @returns a new Vector3
  60698. */
  60699. negate(): Vector3;
  60700. /**
  60701. * Multiplies the Vector3 coordinates by the float "scale"
  60702. * @param scale defines the multiplier factor
  60703. * @returns the current updated Vector3
  60704. */
  60705. scaleInPlace(scale: number): Vector3;
  60706. /**
  60707. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  60708. * @param scale defines the multiplier factor
  60709. * @returns a new Vector3
  60710. */
  60711. scale(scale: number): Vector3;
  60712. /**
  60713. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  60714. * @param scale defines the multiplier factor
  60715. * @param result defines the Vector3 object where to store the result
  60716. * @returns the current Vector3
  60717. */
  60718. scaleToRef(scale: number, result: Vector3): Vector3;
  60719. /**
  60720. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  60721. * @param scale defines the scale factor
  60722. * @param result defines the Vector3 object where to store the result
  60723. * @returns the unmodified current Vector3
  60724. */
  60725. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  60726. /**
  60727. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  60728. * @param otherVector defines the second operand
  60729. * @returns true if both vectors are equals
  60730. */
  60731. equals(otherVector: DeepImmutable<Vector3>): boolean;
  60732. /**
  60733. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  60734. * @param otherVector defines the second operand
  60735. * @param epsilon defines the minimal distance to define values as equals
  60736. * @returns true if both vectors are distant less than epsilon
  60737. */
  60738. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  60739. /**
  60740. * Returns true if the current Vector3 coordinates equals the given floats
  60741. * @param x defines the x coordinate of the operand
  60742. * @param y defines the y coordinate of the operand
  60743. * @param z defines the z coordinate of the operand
  60744. * @returns true if both vectors are equals
  60745. */
  60746. equalsToFloats(x: number, y: number, z: number): boolean;
  60747. /**
  60748. * Multiplies the current Vector3 coordinates by the given ones
  60749. * @param otherVector defines the second operand
  60750. * @returns the current updated Vector3
  60751. */
  60752. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  60753. /**
  60754. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  60755. * @param otherVector defines the second operand
  60756. * @returns the new Vector3
  60757. */
  60758. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  60759. /**
  60760. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  60761. * @param otherVector defines the second operand
  60762. * @param result defines the Vector3 object where to store the result
  60763. * @returns the current Vector3
  60764. */
  60765. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  60766. /**
  60767. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  60768. * @param x defines the x coordinate of the operand
  60769. * @param y defines the y coordinate of the operand
  60770. * @param z defines the z coordinate of the operand
  60771. * @returns the new Vector3
  60772. */
  60773. multiplyByFloats(x: number, y: number, z: number): Vector3;
  60774. /**
  60775. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  60776. * @param otherVector defines the second operand
  60777. * @returns the new Vector3
  60778. */
  60779. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  60780. /**
  60781. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  60782. * @param otherVector defines the second operand
  60783. * @param result defines the Vector3 object where to store the result
  60784. * @returns the current Vector3
  60785. */
  60786. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  60787. /**
  60788. * Divides the current Vector3 coordinates by the given ones.
  60789. * @param otherVector defines the second operand
  60790. * @returns the current updated Vector3
  60791. */
  60792. divideInPlace(otherVector: Vector3): Vector3;
  60793. /**
  60794. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  60795. * @param other defines the second operand
  60796. * @returns the current updated Vector3
  60797. */
  60798. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  60799. /**
  60800. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  60801. * @param other defines the second operand
  60802. * @returns the current updated Vector3
  60803. */
  60804. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  60805. /**
  60806. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  60807. * @param x defines the x coordinate of the operand
  60808. * @param y defines the y coordinate of the operand
  60809. * @param z defines the z coordinate of the operand
  60810. * @returns the current updated Vector3
  60811. */
  60812. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  60813. /**
  60814. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  60815. * @param x defines the x coordinate of the operand
  60816. * @param y defines the y coordinate of the operand
  60817. * @param z defines the z coordinate of the operand
  60818. * @returns the current updated Vector3
  60819. */
  60820. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  60821. /**
  60822. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  60823. * Check if is non uniform within a certain amount of decimal places to account for this
  60824. * @param epsilon the amount the values can differ
  60825. * @returns if the the vector is non uniform to a certain number of decimal places
  60826. */
  60827. isNonUniformWithinEpsilon(epsilon: number): boolean;
  60828. /**
  60829. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  60830. */
  60831. readonly isNonUniform: boolean;
  60832. /**
  60833. * Gets a new Vector3 from current Vector3 floored values
  60834. * @returns a new Vector3
  60835. */
  60836. floor(): Vector3;
  60837. /**
  60838. * Gets a new Vector3 from current Vector3 floored values
  60839. * @returns a new Vector3
  60840. */
  60841. fract(): Vector3;
  60842. /**
  60843. * Gets the length of the Vector3
  60844. * @returns the length of the Vecto3
  60845. */
  60846. length(): number;
  60847. /**
  60848. * Gets the squared length of the Vector3
  60849. * @returns squared length of the Vector3
  60850. */
  60851. lengthSquared(): number;
  60852. /**
  60853. * Normalize the current Vector3.
  60854. * Please note that this is an in place operation.
  60855. * @returns the current updated Vector3
  60856. */
  60857. normalize(): Vector3;
  60858. /**
  60859. * Reorders the x y z properties of the vector in place
  60860. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  60861. * @returns the current updated vector
  60862. */
  60863. reorderInPlace(order: string): this;
  60864. /**
  60865. * Rotates the vector around 0,0,0 by a quaternion
  60866. * @param quaternion the rotation quaternion
  60867. * @param result vector to store the result
  60868. * @returns the resulting vector
  60869. */
  60870. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  60871. /**
  60872. * Rotates a vector around a given point
  60873. * @param quaternion the rotation quaternion
  60874. * @param point the point to rotate around
  60875. * @param result vector to store the result
  60876. * @returns the resulting vector
  60877. */
  60878. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  60879. /**
  60880. * Normalize the current Vector3 with the given input length.
  60881. * Please note that this is an in place operation.
  60882. * @param len the length of the vector
  60883. * @returns the current updated Vector3
  60884. */
  60885. normalizeFromLength(len: number): Vector3;
  60886. /**
  60887. * Normalize the current Vector3 to a new vector
  60888. * @returns the new Vector3
  60889. */
  60890. normalizeToNew(): Vector3;
  60891. /**
  60892. * Normalize the current Vector3 to the reference
  60893. * @param reference define the Vector3 to update
  60894. * @returns the updated Vector3
  60895. */
  60896. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  60897. /**
  60898. * Creates a new Vector3 copied from the current Vector3
  60899. * @returns the new Vector3
  60900. */
  60901. clone(): Vector3;
  60902. /**
  60903. * Copies the given vector coordinates to the current Vector3 ones
  60904. * @param source defines the source Vector3
  60905. * @returns the current updated Vector3
  60906. */
  60907. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  60908. /**
  60909. * Copies the given floats to the current Vector3 coordinates
  60910. * @param x defines the x coordinate of the operand
  60911. * @param y defines the y coordinate of the operand
  60912. * @param z defines the z coordinate of the operand
  60913. * @returns the current updated Vector3
  60914. */
  60915. copyFromFloats(x: number, y: number, z: number): Vector3;
  60916. /**
  60917. * Copies the given floats to the current Vector3 coordinates
  60918. * @param x defines the x coordinate of the operand
  60919. * @param y defines the y coordinate of the operand
  60920. * @param z defines the z coordinate of the operand
  60921. * @returns the current updated Vector3
  60922. */
  60923. set(x: number, y: number, z: number): Vector3;
  60924. /**
  60925. * Copies the given float to the current Vector3 coordinates
  60926. * @param v defines the x, y and z coordinates of the operand
  60927. * @returns the current updated Vector3
  60928. */
  60929. setAll(v: number): Vector3;
  60930. /**
  60931. * Get the clip factor between two vectors
  60932. * @param vector0 defines the first operand
  60933. * @param vector1 defines the second operand
  60934. * @param axis defines the axis to use
  60935. * @param size defines the size along the axis
  60936. * @returns the clip factor
  60937. */
  60938. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  60939. /**
  60940. * Get angle between two vectors
  60941. * @param vector0 angle between vector0 and vector1
  60942. * @param vector1 angle between vector0 and vector1
  60943. * @param normal direction of the normal
  60944. * @return the angle between vector0 and vector1
  60945. */
  60946. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  60947. /**
  60948. * Returns a new Vector3 set from the index "offset" of the given array
  60949. * @param array defines the source array
  60950. * @param offset defines the offset in the source array
  60951. * @returns the new Vector3
  60952. */
  60953. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  60954. /**
  60955. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  60956. * This function is deprecated. Use FromArray instead
  60957. * @param array defines the source array
  60958. * @param offset defines the offset in the source array
  60959. * @returns the new Vector3
  60960. */
  60961. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  60962. /**
  60963. * Sets the given vector "result" with the element values from the index "offset" of the given array
  60964. * @param array defines the source array
  60965. * @param offset defines the offset in the source array
  60966. * @param result defines the Vector3 where to store the result
  60967. */
  60968. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  60969. /**
  60970. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  60971. * This function is deprecated. Use FromArrayToRef instead.
  60972. * @param array defines the source array
  60973. * @param offset defines the offset in the source array
  60974. * @param result defines the Vector3 where to store the result
  60975. */
  60976. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  60977. /**
  60978. * Sets the given vector "result" with the given floats.
  60979. * @param x defines the x coordinate of the source
  60980. * @param y defines the y coordinate of the source
  60981. * @param z defines the z coordinate of the source
  60982. * @param result defines the Vector3 where to store the result
  60983. */
  60984. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  60985. /**
  60986. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  60987. * @returns a new empty Vector3
  60988. */
  60989. static Zero(): Vector3;
  60990. /**
  60991. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  60992. * @returns a new unit Vector3
  60993. */
  60994. static One(): Vector3;
  60995. /**
  60996. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  60997. * @returns a new up Vector3
  60998. */
  60999. static Up(): Vector3;
  61000. /**
  61001. * Gets a up Vector3 that must not be updated
  61002. */
  61003. static readonly UpReadOnly: DeepImmutable<Vector3>;
  61004. /**
  61005. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  61006. * @returns a new down Vector3
  61007. */
  61008. static Down(): Vector3;
  61009. /**
  61010. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  61011. * @returns a new forward Vector3
  61012. */
  61013. static Forward(): Vector3;
  61014. /**
  61015. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  61016. * @returns a new forward Vector3
  61017. */
  61018. static Backward(): Vector3;
  61019. /**
  61020. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  61021. * @returns a new right Vector3
  61022. */
  61023. static Right(): Vector3;
  61024. /**
  61025. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  61026. * @returns a new left Vector3
  61027. */
  61028. static Left(): Vector3;
  61029. /**
  61030. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  61031. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  61032. * @param vector defines the Vector3 to transform
  61033. * @param transformation defines the transformation matrix
  61034. * @returns the transformed Vector3
  61035. */
  61036. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  61037. /**
  61038. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  61039. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  61040. * @param vector defines the Vector3 to transform
  61041. * @param transformation defines the transformation matrix
  61042. * @param result defines the Vector3 where to store the result
  61043. */
  61044. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  61045. /**
  61046. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  61047. * This method computes tranformed coordinates only, not transformed direction vectors
  61048. * @param x define the x coordinate of the source vector
  61049. * @param y define the y coordinate of the source vector
  61050. * @param z define the z coordinate of the source vector
  61051. * @param transformation defines the transformation matrix
  61052. * @param result defines the Vector3 where to store the result
  61053. */
  61054. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  61055. /**
  61056. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  61057. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  61058. * @param vector defines the Vector3 to transform
  61059. * @param transformation defines the transformation matrix
  61060. * @returns the new Vector3
  61061. */
  61062. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  61063. /**
  61064. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  61065. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  61066. * @param vector defines the Vector3 to transform
  61067. * @param transformation defines the transformation matrix
  61068. * @param result defines the Vector3 where to store the result
  61069. */
  61070. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  61071. /**
  61072. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  61073. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  61074. * @param x define the x coordinate of the source vector
  61075. * @param y define the y coordinate of the source vector
  61076. * @param z define the z coordinate of the source vector
  61077. * @param transformation defines the transformation matrix
  61078. * @param result defines the Vector3 where to store the result
  61079. */
  61080. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  61081. /**
  61082. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  61083. * @param value1 defines the first control point
  61084. * @param value2 defines the second control point
  61085. * @param value3 defines the third control point
  61086. * @param value4 defines the fourth control point
  61087. * @param amount defines the amount on the spline to use
  61088. * @returns the new Vector3
  61089. */
  61090. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  61091. /**
  61092. * 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"
  61093. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  61094. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  61095. * @param value defines the current value
  61096. * @param min defines the lower range value
  61097. * @param max defines the upper range value
  61098. * @returns the new Vector3
  61099. */
  61100. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  61101. /**
  61102. * 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"
  61103. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  61104. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  61105. * @param value defines the current value
  61106. * @param min defines the lower range value
  61107. * @param max defines the upper range value
  61108. * @param result defines the Vector3 where to store the result
  61109. */
  61110. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  61111. /**
  61112. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  61113. * @param value1 defines the first control point
  61114. * @param tangent1 defines the first tangent vector
  61115. * @param value2 defines the second control point
  61116. * @param tangent2 defines the second tangent vector
  61117. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  61118. * @returns the new Vector3
  61119. */
  61120. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  61121. /**
  61122. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  61123. * @param start defines the start value
  61124. * @param end defines the end value
  61125. * @param amount max defines amount between both (between 0 and 1)
  61126. * @returns the new Vector3
  61127. */
  61128. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  61129. /**
  61130. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  61131. * @param start defines the start value
  61132. * @param end defines the end value
  61133. * @param amount max defines amount between both (between 0 and 1)
  61134. * @param result defines the Vector3 where to store the result
  61135. */
  61136. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  61137. /**
  61138. * Returns the dot product (float) between the vectors "left" and "right"
  61139. * @param left defines the left operand
  61140. * @param right defines the right operand
  61141. * @returns the dot product
  61142. */
  61143. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  61144. /**
  61145. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  61146. * The cross product is then orthogonal to both "left" and "right"
  61147. * @param left defines the left operand
  61148. * @param right defines the right operand
  61149. * @returns the cross product
  61150. */
  61151. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  61152. /**
  61153. * Sets the given vector "result" with the cross product of "left" and "right"
  61154. * The cross product is then orthogonal to both "left" and "right"
  61155. * @param left defines the left operand
  61156. * @param right defines the right operand
  61157. * @param result defines the Vector3 where to store the result
  61158. */
  61159. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  61160. /**
  61161. * Returns a new Vector3 as the normalization of the given vector
  61162. * @param vector defines the Vector3 to normalize
  61163. * @returns the new Vector3
  61164. */
  61165. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  61166. /**
  61167. * Sets the given vector "result" with the normalization of the given first vector
  61168. * @param vector defines the Vector3 to normalize
  61169. * @param result defines the Vector3 where to store the result
  61170. */
  61171. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  61172. /**
  61173. * Project a Vector3 onto screen space
  61174. * @param vector defines the Vector3 to project
  61175. * @param world defines the world matrix to use
  61176. * @param transform defines the transform (view x projection) matrix to use
  61177. * @param viewport defines the screen viewport to use
  61178. * @returns the new Vector3
  61179. */
  61180. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  61181. /** @hidden */
  61182. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  61183. /**
  61184. * Unproject from screen space to object space
  61185. * @param source defines the screen space Vector3 to use
  61186. * @param viewportWidth defines the current width of the viewport
  61187. * @param viewportHeight defines the current height of the viewport
  61188. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  61189. * @param transform defines the transform (view x projection) matrix to use
  61190. * @returns the new Vector3
  61191. */
  61192. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  61193. /**
  61194. * Unproject from screen space to object space
  61195. * @param source defines the screen space Vector3 to use
  61196. * @param viewportWidth defines the current width of the viewport
  61197. * @param viewportHeight defines the current height of the viewport
  61198. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  61199. * @param view defines the view matrix to use
  61200. * @param projection defines the projection matrix to use
  61201. * @returns the new Vector3
  61202. */
  61203. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  61204. /**
  61205. * Unproject from screen space to object space
  61206. * @param source defines the screen space Vector3 to use
  61207. * @param viewportWidth defines the current width of the viewport
  61208. * @param viewportHeight defines the current height of the viewport
  61209. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  61210. * @param view defines the view matrix to use
  61211. * @param projection defines the projection matrix to use
  61212. * @param result defines the Vector3 where to store the result
  61213. */
  61214. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  61215. /**
  61216. * Unproject from screen space to object space
  61217. * @param sourceX defines the screen space x coordinate to use
  61218. * @param sourceY defines the screen space y coordinate to use
  61219. * @param sourceZ defines the screen space z coordinate to use
  61220. * @param viewportWidth defines the current width of the viewport
  61221. * @param viewportHeight defines the current height of the viewport
  61222. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  61223. * @param view defines the view matrix to use
  61224. * @param projection defines the projection matrix to use
  61225. * @param result defines the Vector3 where to store the result
  61226. */
  61227. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  61228. /**
  61229. * Gets the minimal coordinate values between two Vector3
  61230. * @param left defines the first operand
  61231. * @param right defines the second operand
  61232. * @returns the new Vector3
  61233. */
  61234. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  61235. /**
  61236. * Gets the maximal coordinate values between two Vector3
  61237. * @param left defines the first operand
  61238. * @param right defines the second operand
  61239. * @returns the new Vector3
  61240. */
  61241. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  61242. /**
  61243. * Returns the distance between the vectors "value1" and "value2"
  61244. * @param value1 defines the first operand
  61245. * @param value2 defines the second operand
  61246. * @returns the distance
  61247. */
  61248. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  61249. /**
  61250. * Returns the squared distance between the vectors "value1" and "value2"
  61251. * @param value1 defines the first operand
  61252. * @param value2 defines the second operand
  61253. * @returns the squared distance
  61254. */
  61255. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  61256. /**
  61257. * Returns a new Vector3 located at the center between "value1" and "value2"
  61258. * @param value1 defines the first operand
  61259. * @param value2 defines the second operand
  61260. * @returns the new Vector3
  61261. */
  61262. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  61263. /**
  61264. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  61265. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  61266. * to something in order to rotate it from its local system to the given target system
  61267. * Note: axis1, axis2 and axis3 are normalized during this operation
  61268. * @param axis1 defines the first axis
  61269. * @param axis2 defines the second axis
  61270. * @param axis3 defines the third axis
  61271. * @returns a new Vector3
  61272. */
  61273. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  61274. /**
  61275. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  61276. * @param axis1 defines the first axis
  61277. * @param axis2 defines the second axis
  61278. * @param axis3 defines the third axis
  61279. * @param ref defines the Vector3 where to store the result
  61280. */
  61281. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  61282. }
  61283. /**
  61284. * Vector4 class created for EulerAngle class conversion to Quaternion
  61285. */
  61286. export class Vector4 {
  61287. /** x value of the vector */
  61288. x: number;
  61289. /** y value of the vector */
  61290. y: number;
  61291. /** z value of the vector */
  61292. z: number;
  61293. /** w value of the vector */
  61294. w: number;
  61295. /**
  61296. * Creates a Vector4 object from the given floats.
  61297. * @param x x value of the vector
  61298. * @param y y value of the vector
  61299. * @param z z value of the vector
  61300. * @param w w value of the vector
  61301. */
  61302. constructor(
  61303. /** x value of the vector */
  61304. x: number,
  61305. /** y value of the vector */
  61306. y: number,
  61307. /** z value of the vector */
  61308. z: number,
  61309. /** w value of the vector */
  61310. w: number);
  61311. /**
  61312. * Returns the string with the Vector4 coordinates.
  61313. * @returns a string containing all the vector values
  61314. */
  61315. toString(): string;
  61316. /**
  61317. * Returns the string "Vector4".
  61318. * @returns "Vector4"
  61319. */
  61320. getClassName(): string;
  61321. /**
  61322. * Returns the Vector4 hash code.
  61323. * @returns a unique hash code
  61324. */
  61325. getHashCode(): number;
  61326. /**
  61327. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  61328. * @returns the resulting array
  61329. */
  61330. asArray(): number[];
  61331. /**
  61332. * Populates the given array from the given index with the Vector4 coordinates.
  61333. * @param array array to populate
  61334. * @param index index of the array to start at (default: 0)
  61335. * @returns the Vector4.
  61336. */
  61337. toArray(array: FloatArray, index?: number): Vector4;
  61338. /**
  61339. * Adds the given vector to the current Vector4.
  61340. * @param otherVector the vector to add
  61341. * @returns the updated Vector4.
  61342. */
  61343. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  61344. /**
  61345. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  61346. * @param otherVector the vector to add
  61347. * @returns the resulting vector
  61348. */
  61349. add(otherVector: DeepImmutable<Vector4>): Vector4;
  61350. /**
  61351. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  61352. * @param otherVector the vector to add
  61353. * @param result the vector to store the result
  61354. * @returns the current Vector4.
  61355. */
  61356. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  61357. /**
  61358. * Subtract in place the given vector from the current Vector4.
  61359. * @param otherVector the vector to subtract
  61360. * @returns the updated Vector4.
  61361. */
  61362. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  61363. /**
  61364. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  61365. * @param otherVector the vector to add
  61366. * @returns the new vector with the result
  61367. */
  61368. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  61369. /**
  61370. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  61371. * @param otherVector the vector to subtract
  61372. * @param result the vector to store the result
  61373. * @returns the current Vector4.
  61374. */
  61375. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  61376. /**
  61377. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  61378. */
  61379. /**
  61380. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  61381. * @param x value to subtract
  61382. * @param y value to subtract
  61383. * @param z value to subtract
  61384. * @param w value to subtract
  61385. * @returns new vector containing the result
  61386. */
  61387. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  61388. /**
  61389. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  61390. * @param x value to subtract
  61391. * @param y value to subtract
  61392. * @param z value to subtract
  61393. * @param w value to subtract
  61394. * @param result the vector to store the result in
  61395. * @returns the current Vector4.
  61396. */
  61397. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  61398. /**
  61399. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  61400. * @returns a new vector with the negated values
  61401. */
  61402. negate(): Vector4;
  61403. /**
  61404. * Multiplies the current Vector4 coordinates by scale (float).
  61405. * @param scale the number to scale with
  61406. * @returns the updated Vector4.
  61407. */
  61408. scaleInPlace(scale: number): Vector4;
  61409. /**
  61410. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  61411. * @param scale the number to scale with
  61412. * @returns a new vector with the result
  61413. */
  61414. scale(scale: number): Vector4;
  61415. /**
  61416. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  61417. * @param scale the number to scale with
  61418. * @param result a vector to store the result in
  61419. * @returns the current Vector4.
  61420. */
  61421. scaleToRef(scale: number, result: Vector4): Vector4;
  61422. /**
  61423. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  61424. * @param scale defines the scale factor
  61425. * @param result defines the Vector4 object where to store the result
  61426. * @returns the unmodified current Vector4
  61427. */
  61428. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  61429. /**
  61430. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  61431. * @param otherVector the vector to compare against
  61432. * @returns true if they are equal
  61433. */
  61434. equals(otherVector: DeepImmutable<Vector4>): boolean;
  61435. /**
  61436. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  61437. * @param otherVector vector to compare against
  61438. * @param epsilon (Default: very small number)
  61439. * @returns true if they are equal
  61440. */
  61441. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  61442. /**
  61443. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  61444. * @param x x value to compare against
  61445. * @param y y value to compare against
  61446. * @param z z value to compare against
  61447. * @param w w value to compare against
  61448. * @returns true if equal
  61449. */
  61450. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  61451. /**
  61452. * Multiplies in place the current Vector4 by the given one.
  61453. * @param otherVector vector to multiple with
  61454. * @returns the updated Vector4.
  61455. */
  61456. multiplyInPlace(otherVector: Vector4): Vector4;
  61457. /**
  61458. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  61459. * @param otherVector vector to multiple with
  61460. * @returns resulting new vector
  61461. */
  61462. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  61463. /**
  61464. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  61465. * @param otherVector vector to multiple with
  61466. * @param result vector to store the result
  61467. * @returns the current Vector4.
  61468. */
  61469. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  61470. /**
  61471. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  61472. * @param x x value multiply with
  61473. * @param y y value multiply with
  61474. * @param z z value multiply with
  61475. * @param w w value multiply with
  61476. * @returns resulting new vector
  61477. */
  61478. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  61479. /**
  61480. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  61481. * @param otherVector vector to devide with
  61482. * @returns resulting new vector
  61483. */
  61484. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  61485. /**
  61486. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  61487. * @param otherVector vector to devide with
  61488. * @param result vector to store the result
  61489. * @returns the current Vector4.
  61490. */
  61491. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  61492. /**
  61493. * Divides the current Vector3 coordinates by the given ones.
  61494. * @param otherVector vector to devide with
  61495. * @returns the updated Vector3.
  61496. */
  61497. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  61498. /**
  61499. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  61500. * @param other defines the second operand
  61501. * @returns the current updated Vector4
  61502. */
  61503. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  61504. /**
  61505. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  61506. * @param other defines the second operand
  61507. * @returns the current updated Vector4
  61508. */
  61509. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  61510. /**
  61511. * Gets a new Vector4 from current Vector4 floored values
  61512. * @returns a new Vector4
  61513. */
  61514. floor(): Vector4;
  61515. /**
  61516. * Gets a new Vector4 from current Vector3 floored values
  61517. * @returns a new Vector4
  61518. */
  61519. fract(): Vector4;
  61520. /**
  61521. * Returns the Vector4 length (float).
  61522. * @returns the length
  61523. */
  61524. length(): number;
  61525. /**
  61526. * Returns the Vector4 squared length (float).
  61527. * @returns the length squared
  61528. */
  61529. lengthSquared(): number;
  61530. /**
  61531. * Normalizes in place the Vector4.
  61532. * @returns the updated Vector4.
  61533. */
  61534. normalize(): Vector4;
  61535. /**
  61536. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  61537. * @returns this converted to a new vector3
  61538. */
  61539. toVector3(): Vector3;
  61540. /**
  61541. * Returns a new Vector4 copied from the current one.
  61542. * @returns the new cloned vector
  61543. */
  61544. clone(): Vector4;
  61545. /**
  61546. * Updates the current Vector4 with the given one coordinates.
  61547. * @param source the source vector to copy from
  61548. * @returns the updated Vector4.
  61549. */
  61550. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  61551. /**
  61552. * Updates the current Vector4 coordinates with the given floats.
  61553. * @param x float to copy from
  61554. * @param y float to copy from
  61555. * @param z float to copy from
  61556. * @param w float to copy from
  61557. * @returns the updated Vector4.
  61558. */
  61559. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  61560. /**
  61561. * Updates the current Vector4 coordinates with the given floats.
  61562. * @param x float to set from
  61563. * @param y float to set from
  61564. * @param z float to set from
  61565. * @param w float to set from
  61566. * @returns the updated Vector4.
  61567. */
  61568. set(x: number, y: number, z: number, w: number): Vector4;
  61569. /**
  61570. * Copies the given float to the current Vector3 coordinates
  61571. * @param v defines the x, y, z and w coordinates of the operand
  61572. * @returns the current updated Vector3
  61573. */
  61574. setAll(v: number): Vector4;
  61575. /**
  61576. * Returns a new Vector4 set from the starting index of the given array.
  61577. * @param array the array to pull values from
  61578. * @param offset the offset into the array to start at
  61579. * @returns the new vector
  61580. */
  61581. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  61582. /**
  61583. * Updates the given vector "result" from the starting index of the given array.
  61584. * @param array the array to pull values from
  61585. * @param offset the offset into the array to start at
  61586. * @param result the vector to store the result in
  61587. */
  61588. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  61589. /**
  61590. * Updates the given vector "result" from the starting index of the given Float32Array.
  61591. * @param array the array to pull values from
  61592. * @param offset the offset into the array to start at
  61593. * @param result the vector to store the result in
  61594. */
  61595. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  61596. /**
  61597. * Updates the given vector "result" coordinates from the given floats.
  61598. * @param x float to set from
  61599. * @param y float to set from
  61600. * @param z float to set from
  61601. * @param w float to set from
  61602. * @param result the vector to the floats in
  61603. */
  61604. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  61605. /**
  61606. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  61607. * @returns the new vector
  61608. */
  61609. static Zero(): Vector4;
  61610. /**
  61611. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  61612. * @returns the new vector
  61613. */
  61614. static One(): Vector4;
  61615. /**
  61616. * Returns a new normalized Vector4 from the given one.
  61617. * @param vector the vector to normalize
  61618. * @returns the vector
  61619. */
  61620. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  61621. /**
  61622. * Updates the given vector "result" from the normalization of the given one.
  61623. * @param vector the vector to normalize
  61624. * @param result the vector to store the result in
  61625. */
  61626. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  61627. /**
  61628. * Returns a vector with the minimum values from the left and right vectors
  61629. * @param left left vector to minimize
  61630. * @param right right vector to minimize
  61631. * @returns a new vector with the minimum of the left and right vector values
  61632. */
  61633. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  61634. /**
  61635. * Returns a vector with the maximum values from the left and right vectors
  61636. * @param left left vector to maximize
  61637. * @param right right vector to maximize
  61638. * @returns a new vector with the maximum of the left and right vector values
  61639. */
  61640. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  61641. /**
  61642. * Returns the distance (float) between the vectors "value1" and "value2".
  61643. * @param value1 value to calulate the distance between
  61644. * @param value2 value to calulate the distance between
  61645. * @return the distance between the two vectors
  61646. */
  61647. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  61648. /**
  61649. * Returns the squared distance (float) between the vectors "value1" and "value2".
  61650. * @param value1 value to calulate the distance between
  61651. * @param value2 value to calulate the distance between
  61652. * @return the distance between the two vectors squared
  61653. */
  61654. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  61655. /**
  61656. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  61657. * @param value1 value to calulate the center between
  61658. * @param value2 value to calulate the center between
  61659. * @return the center between the two vectors
  61660. */
  61661. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  61662. /**
  61663. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  61664. * This methods computes transformed normalized direction vectors only.
  61665. * @param vector the vector to transform
  61666. * @param transformation the transformation matrix to apply
  61667. * @returns the new vector
  61668. */
  61669. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  61670. /**
  61671. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  61672. * This methods computes transformed normalized direction vectors only.
  61673. * @param vector the vector to transform
  61674. * @param transformation the transformation matrix to apply
  61675. * @param result the vector to store the result in
  61676. */
  61677. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  61678. /**
  61679. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  61680. * This methods computes transformed normalized direction vectors only.
  61681. * @param x value to transform
  61682. * @param y value to transform
  61683. * @param z value to transform
  61684. * @param w value to transform
  61685. * @param transformation the transformation matrix to apply
  61686. * @param result the vector to store the results in
  61687. */
  61688. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  61689. /**
  61690. * Creates a new Vector4 from a Vector3
  61691. * @param source defines the source data
  61692. * @param w defines the 4th component (default is 0)
  61693. * @returns a new Vector4
  61694. */
  61695. static FromVector3(source: Vector3, w?: number): Vector4;
  61696. }
  61697. /**
  61698. * Interface for the size containing width and height
  61699. */
  61700. export interface ISize {
  61701. /**
  61702. * Width
  61703. */
  61704. width: number;
  61705. /**
  61706. * Heighht
  61707. */
  61708. height: number;
  61709. }
  61710. /**
  61711. * Size containing widht and height
  61712. */
  61713. export class Size implements ISize {
  61714. /**
  61715. * Width
  61716. */
  61717. width: number;
  61718. /**
  61719. * Height
  61720. */
  61721. height: number;
  61722. /**
  61723. * Creates a Size object from the given width and height (floats).
  61724. * @param width width of the new size
  61725. * @param height height of the new size
  61726. */
  61727. constructor(width: number, height: number);
  61728. /**
  61729. * Returns a string with the Size width and height
  61730. * @returns a string with the Size width and height
  61731. */
  61732. toString(): string;
  61733. /**
  61734. * "Size"
  61735. * @returns the string "Size"
  61736. */
  61737. getClassName(): string;
  61738. /**
  61739. * Returns the Size hash code.
  61740. * @returns a hash code for a unique width and height
  61741. */
  61742. getHashCode(): number;
  61743. /**
  61744. * Updates the current size from the given one.
  61745. * @param src the given size
  61746. */
  61747. copyFrom(src: Size): void;
  61748. /**
  61749. * Updates in place the current Size from the given floats.
  61750. * @param width width of the new size
  61751. * @param height height of the new size
  61752. * @returns the updated Size.
  61753. */
  61754. copyFromFloats(width: number, height: number): Size;
  61755. /**
  61756. * Updates in place the current Size from the given floats.
  61757. * @param width width to set
  61758. * @param height height to set
  61759. * @returns the updated Size.
  61760. */
  61761. set(width: number, height: number): Size;
  61762. /**
  61763. * Multiplies the width and height by numbers
  61764. * @param w factor to multiple the width by
  61765. * @param h factor to multiple the height by
  61766. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  61767. */
  61768. multiplyByFloats(w: number, h: number): Size;
  61769. /**
  61770. * Clones the size
  61771. * @returns a new Size copied from the given one.
  61772. */
  61773. clone(): Size;
  61774. /**
  61775. * True if the current Size and the given one width and height are strictly equal.
  61776. * @param other the other size to compare against
  61777. * @returns True if the current Size and the given one width and height are strictly equal.
  61778. */
  61779. equals(other: Size): boolean;
  61780. /**
  61781. * The surface of the Size : width * height (float).
  61782. */
  61783. readonly surface: number;
  61784. /**
  61785. * Create a new size of zero
  61786. * @returns a new Size set to (0.0, 0.0)
  61787. */
  61788. static Zero(): Size;
  61789. /**
  61790. * Sums the width and height of two sizes
  61791. * @param otherSize size to add to this size
  61792. * @returns a new Size set as the addition result of the current Size and the given one.
  61793. */
  61794. add(otherSize: Size): Size;
  61795. /**
  61796. * Subtracts the width and height of two
  61797. * @param otherSize size to subtract to this size
  61798. * @returns a new Size set as the subtraction result of the given one from the current Size.
  61799. */
  61800. subtract(otherSize: Size): Size;
  61801. /**
  61802. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  61803. * @param start starting size to lerp between
  61804. * @param end end size to lerp between
  61805. * @param amount amount to lerp between the start and end values
  61806. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  61807. */
  61808. static Lerp(start: Size, end: Size, amount: number): Size;
  61809. }
  61810. /**
  61811. * Class used to store quaternion data
  61812. * @see https://en.wikipedia.org/wiki/Quaternion
  61813. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  61814. */
  61815. export class Quaternion {
  61816. /** defines the first component (0 by default) */
  61817. x: number;
  61818. /** defines the second component (0 by default) */
  61819. y: number;
  61820. /** defines the third component (0 by default) */
  61821. z: number;
  61822. /** defines the fourth component (1.0 by default) */
  61823. w: number;
  61824. /**
  61825. * Creates a new Quaternion from the given floats
  61826. * @param x defines the first component (0 by default)
  61827. * @param y defines the second component (0 by default)
  61828. * @param z defines the third component (0 by default)
  61829. * @param w defines the fourth component (1.0 by default)
  61830. */
  61831. constructor(
  61832. /** defines the first component (0 by default) */
  61833. x?: number,
  61834. /** defines the second component (0 by default) */
  61835. y?: number,
  61836. /** defines the third component (0 by default) */
  61837. z?: number,
  61838. /** defines the fourth component (1.0 by default) */
  61839. w?: number);
  61840. /**
  61841. * Gets a string representation for the current quaternion
  61842. * @returns a string with the Quaternion coordinates
  61843. */
  61844. toString(): string;
  61845. /**
  61846. * Gets the class name of the quaternion
  61847. * @returns the string "Quaternion"
  61848. */
  61849. getClassName(): string;
  61850. /**
  61851. * Gets a hash code for this quaternion
  61852. * @returns the quaternion hash code
  61853. */
  61854. getHashCode(): number;
  61855. /**
  61856. * Copy the quaternion to an array
  61857. * @returns a new array populated with 4 elements from the quaternion coordinates
  61858. */
  61859. asArray(): number[];
  61860. /**
  61861. * Check if two quaternions are equals
  61862. * @param otherQuaternion defines the second operand
  61863. * @return true if the current quaternion and the given one coordinates are strictly equals
  61864. */
  61865. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  61866. /**
  61867. * Clone the current quaternion
  61868. * @returns a new quaternion copied from the current one
  61869. */
  61870. clone(): Quaternion;
  61871. /**
  61872. * Copy a quaternion to the current one
  61873. * @param other defines the other quaternion
  61874. * @returns the updated current quaternion
  61875. */
  61876. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  61877. /**
  61878. * Updates the current quaternion with the given float coordinates
  61879. * @param x defines the x coordinate
  61880. * @param y defines the y coordinate
  61881. * @param z defines the z coordinate
  61882. * @param w defines the w coordinate
  61883. * @returns the updated current quaternion
  61884. */
  61885. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  61886. /**
  61887. * Updates the current quaternion from the given float coordinates
  61888. * @param x defines the x coordinate
  61889. * @param y defines the y coordinate
  61890. * @param z defines the z coordinate
  61891. * @param w defines the w coordinate
  61892. * @returns the updated current quaternion
  61893. */
  61894. set(x: number, y: number, z: number, w: number): Quaternion;
  61895. /**
  61896. * Adds two quaternions
  61897. * @param other defines the second operand
  61898. * @returns a new quaternion as the addition result of the given one and the current quaternion
  61899. */
  61900. add(other: DeepImmutable<Quaternion>): Quaternion;
  61901. /**
  61902. * Add a quaternion to the current one
  61903. * @param other defines the quaternion to add
  61904. * @returns the current quaternion
  61905. */
  61906. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  61907. /**
  61908. * Subtract two quaternions
  61909. * @param other defines the second operand
  61910. * @returns a new quaternion as the subtraction result of the given one from the current one
  61911. */
  61912. subtract(other: Quaternion): Quaternion;
  61913. /**
  61914. * Multiplies the current quaternion by a scale factor
  61915. * @param value defines the scale factor
  61916. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  61917. */
  61918. scale(value: number): Quaternion;
  61919. /**
  61920. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  61921. * @param scale defines the scale factor
  61922. * @param result defines the Quaternion object where to store the result
  61923. * @returns the unmodified current quaternion
  61924. */
  61925. scaleToRef(scale: number, result: Quaternion): Quaternion;
  61926. /**
  61927. * Multiplies in place the current quaternion by a scale factor
  61928. * @param value defines the scale factor
  61929. * @returns the current modified quaternion
  61930. */
  61931. scaleInPlace(value: number): Quaternion;
  61932. /**
  61933. * Scale the current quaternion values by a factor and add the result to a given quaternion
  61934. * @param scale defines the scale factor
  61935. * @param result defines the Quaternion object where to store the result
  61936. * @returns the unmodified current quaternion
  61937. */
  61938. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  61939. /**
  61940. * Multiplies two quaternions
  61941. * @param q1 defines the second operand
  61942. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  61943. */
  61944. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  61945. /**
  61946. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  61947. * @param q1 defines the second operand
  61948. * @param result defines the target quaternion
  61949. * @returns the current quaternion
  61950. */
  61951. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  61952. /**
  61953. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  61954. * @param q1 defines the second operand
  61955. * @returns the currentupdated quaternion
  61956. */
  61957. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  61958. /**
  61959. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  61960. * @param ref defines the target quaternion
  61961. * @returns the current quaternion
  61962. */
  61963. conjugateToRef(ref: Quaternion): Quaternion;
  61964. /**
  61965. * Conjugates in place (1-q) the current quaternion
  61966. * @returns the current updated quaternion
  61967. */
  61968. conjugateInPlace(): Quaternion;
  61969. /**
  61970. * Conjugates in place (1-q) the current quaternion
  61971. * @returns a new quaternion
  61972. */
  61973. conjugate(): Quaternion;
  61974. /**
  61975. * Gets length of current quaternion
  61976. * @returns the quaternion length (float)
  61977. */
  61978. length(): number;
  61979. /**
  61980. * Normalize in place the current quaternion
  61981. * @returns the current updated quaternion
  61982. */
  61983. normalize(): Quaternion;
  61984. /**
  61985. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  61986. * @param order is a reserved parameter and is ignore for now
  61987. * @returns a new Vector3 containing the Euler angles
  61988. */
  61989. toEulerAngles(order?: string): Vector3;
  61990. /**
  61991. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  61992. * @param result defines the vector which will be filled with the Euler angles
  61993. * @param order is a reserved parameter and is ignore for now
  61994. * @returns the current unchanged quaternion
  61995. */
  61996. toEulerAnglesToRef(result: Vector3): Quaternion;
  61997. /**
  61998. * Updates the given rotation matrix with the current quaternion values
  61999. * @param result defines the target matrix
  62000. * @returns the current unchanged quaternion
  62001. */
  62002. toRotationMatrix(result: Matrix): Quaternion;
  62003. /**
  62004. * Updates the current quaternion from the given rotation matrix values
  62005. * @param matrix defines the source matrix
  62006. * @returns the current updated quaternion
  62007. */
  62008. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  62009. /**
  62010. * Creates a new quaternion from a rotation matrix
  62011. * @param matrix defines the source matrix
  62012. * @returns a new quaternion created from the given rotation matrix values
  62013. */
  62014. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  62015. /**
  62016. * Updates the given quaternion with the given rotation matrix values
  62017. * @param matrix defines the source matrix
  62018. * @param result defines the target quaternion
  62019. */
  62020. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  62021. /**
  62022. * Returns the dot product (float) between the quaternions "left" and "right"
  62023. * @param left defines the left operand
  62024. * @param right defines the right operand
  62025. * @returns the dot product
  62026. */
  62027. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  62028. /**
  62029. * Checks if the two quaternions are close to each other
  62030. * @param quat0 defines the first quaternion to check
  62031. * @param quat1 defines the second quaternion to check
  62032. * @returns true if the two quaternions are close to each other
  62033. */
  62034. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  62035. /**
  62036. * Creates an empty quaternion
  62037. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  62038. */
  62039. static Zero(): Quaternion;
  62040. /**
  62041. * Inverse a given quaternion
  62042. * @param q defines the source quaternion
  62043. * @returns a new quaternion as the inverted current quaternion
  62044. */
  62045. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  62046. /**
  62047. * Inverse a given quaternion
  62048. * @param q defines the source quaternion
  62049. * @param result the quaternion the result will be stored in
  62050. * @returns the result quaternion
  62051. */
  62052. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  62053. /**
  62054. * Creates an identity quaternion
  62055. * @returns the identity quaternion
  62056. */
  62057. static Identity(): Quaternion;
  62058. /**
  62059. * Gets a boolean indicating if the given quaternion is identity
  62060. * @param quaternion defines the quaternion to check
  62061. * @returns true if the quaternion is identity
  62062. */
  62063. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  62064. /**
  62065. * Creates a quaternion from a rotation around an axis
  62066. * @param axis defines the axis to use
  62067. * @param angle defines the angle to use
  62068. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  62069. */
  62070. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  62071. /**
  62072. * Creates a rotation around an axis and stores it into the given quaternion
  62073. * @param axis defines the axis to use
  62074. * @param angle defines the angle to use
  62075. * @param result defines the target quaternion
  62076. * @returns the target quaternion
  62077. */
  62078. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  62079. /**
  62080. * Creates a new quaternion from data stored into an array
  62081. * @param array defines the data source
  62082. * @param offset defines the offset in the source array where the data starts
  62083. * @returns a new quaternion
  62084. */
  62085. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  62086. /**
  62087. * Create a quaternion from Euler rotation angles
  62088. * @param x Pitch
  62089. * @param y Yaw
  62090. * @param z Roll
  62091. * @returns the new Quaternion
  62092. */
  62093. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  62094. /**
  62095. * Updates a quaternion from Euler rotation angles
  62096. * @param x Pitch
  62097. * @param y Yaw
  62098. * @param z Roll
  62099. * @param result the quaternion to store the result
  62100. * @returns the updated quaternion
  62101. */
  62102. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  62103. /**
  62104. * Create a quaternion from Euler rotation vector
  62105. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  62106. * @returns the new Quaternion
  62107. */
  62108. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  62109. /**
  62110. * Updates a quaternion from Euler rotation vector
  62111. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  62112. * @param result the quaternion to store the result
  62113. * @returns the updated quaternion
  62114. */
  62115. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  62116. /**
  62117. * Creates a new quaternion from the given Euler float angles (y, x, z)
  62118. * @param yaw defines the rotation around Y axis
  62119. * @param pitch defines the rotation around X axis
  62120. * @param roll defines the rotation around Z axis
  62121. * @returns the new quaternion
  62122. */
  62123. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  62124. /**
  62125. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  62126. * @param yaw defines the rotation around Y axis
  62127. * @param pitch defines the rotation around X axis
  62128. * @param roll defines the rotation around Z axis
  62129. * @param result defines the target quaternion
  62130. */
  62131. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  62132. /**
  62133. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  62134. * @param alpha defines the rotation around first axis
  62135. * @param beta defines the rotation around second axis
  62136. * @param gamma defines the rotation around third axis
  62137. * @returns the new quaternion
  62138. */
  62139. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  62140. /**
  62141. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  62142. * @param alpha defines the rotation around first axis
  62143. * @param beta defines the rotation around second axis
  62144. * @param gamma defines the rotation around third axis
  62145. * @param result defines the target quaternion
  62146. */
  62147. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  62148. /**
  62149. * 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)
  62150. * @param axis1 defines the first axis
  62151. * @param axis2 defines the second axis
  62152. * @param axis3 defines the third axis
  62153. * @returns the new quaternion
  62154. */
  62155. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  62156. /**
  62157. * 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
  62158. * @param axis1 defines the first axis
  62159. * @param axis2 defines the second axis
  62160. * @param axis3 defines the third axis
  62161. * @param ref defines the target quaternion
  62162. */
  62163. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  62164. /**
  62165. * Interpolates between two quaternions
  62166. * @param left defines first quaternion
  62167. * @param right defines second quaternion
  62168. * @param amount defines the gradient to use
  62169. * @returns the new interpolated quaternion
  62170. */
  62171. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  62172. /**
  62173. * Interpolates between two quaternions and stores it into a target quaternion
  62174. * @param left defines first quaternion
  62175. * @param right defines second quaternion
  62176. * @param amount defines the gradient to use
  62177. * @param result defines the target quaternion
  62178. */
  62179. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  62180. /**
  62181. * Interpolate between two quaternions using Hermite interpolation
  62182. * @param value1 defines first quaternion
  62183. * @param tangent1 defines the incoming tangent
  62184. * @param value2 defines second quaternion
  62185. * @param tangent2 defines the outgoing tangent
  62186. * @param amount defines the target quaternion
  62187. * @returns the new interpolated quaternion
  62188. */
  62189. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  62190. }
  62191. /**
  62192. * Class used to store matrix data (4x4)
  62193. */
  62194. export class Matrix {
  62195. private static _updateFlagSeed;
  62196. private static _identityReadOnly;
  62197. private _isIdentity;
  62198. private _isIdentityDirty;
  62199. private _isIdentity3x2;
  62200. private _isIdentity3x2Dirty;
  62201. /**
  62202. * Gets the update flag of the matrix which is an unique number for the matrix.
  62203. * It will be incremented every time the matrix data change.
  62204. * You can use it to speed the comparison between two versions of the same matrix.
  62205. */
  62206. updateFlag: number;
  62207. private readonly _m;
  62208. /**
  62209. * Gets the internal data of the matrix
  62210. */
  62211. readonly m: DeepImmutable<Float32Array>;
  62212. /** @hidden */
  62213. _markAsUpdated(): void;
  62214. /** @hidden */
  62215. private _updateIdentityStatus;
  62216. /**
  62217. * Creates an empty matrix (filled with zeros)
  62218. */
  62219. constructor();
  62220. /**
  62221. * Check if the current matrix is identity
  62222. * @returns true is the matrix is the identity matrix
  62223. */
  62224. isIdentity(): boolean;
  62225. /**
  62226. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  62227. * @returns true is the matrix is the identity matrix
  62228. */
  62229. isIdentityAs3x2(): boolean;
  62230. /**
  62231. * Gets the determinant of the matrix
  62232. * @returns the matrix determinant
  62233. */
  62234. determinant(): number;
  62235. /**
  62236. * Returns the matrix as a Float32Array
  62237. * @returns the matrix underlying array
  62238. */
  62239. toArray(): DeepImmutable<Float32Array>;
  62240. /**
  62241. * Returns the matrix as a Float32Array
  62242. * @returns the matrix underlying array.
  62243. */
  62244. asArray(): DeepImmutable<Float32Array>;
  62245. /**
  62246. * Inverts the current matrix in place
  62247. * @returns the current inverted matrix
  62248. */
  62249. invert(): Matrix;
  62250. /**
  62251. * Sets all the matrix elements to zero
  62252. * @returns the current matrix
  62253. */
  62254. reset(): Matrix;
  62255. /**
  62256. * Adds the current matrix with a second one
  62257. * @param other defines the matrix to add
  62258. * @returns a new matrix as the addition of the current matrix and the given one
  62259. */
  62260. add(other: DeepImmutable<Matrix>): Matrix;
  62261. /**
  62262. * Sets the given matrix "result" to the addition of the current matrix and the given one
  62263. * @param other defines the matrix to add
  62264. * @param result defines the target matrix
  62265. * @returns the current matrix
  62266. */
  62267. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  62268. /**
  62269. * Adds in place the given matrix to the current matrix
  62270. * @param other defines the second operand
  62271. * @returns the current updated matrix
  62272. */
  62273. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  62274. /**
  62275. * Sets the given matrix to the current inverted Matrix
  62276. * @param other defines the target matrix
  62277. * @returns the unmodified current matrix
  62278. */
  62279. invertToRef(other: Matrix): Matrix;
  62280. /**
  62281. * add a value at the specified position in the current Matrix
  62282. * @param index the index of the value within the matrix. between 0 and 15.
  62283. * @param value the value to be added
  62284. * @returns the current updated matrix
  62285. */
  62286. addAtIndex(index: number, value: number): Matrix;
  62287. /**
  62288. * mutiply the specified position in the current Matrix by a value
  62289. * @param index the index of the value within the matrix. between 0 and 15.
  62290. * @param value the value to be added
  62291. * @returns the current updated matrix
  62292. */
  62293. multiplyAtIndex(index: number, value: number): Matrix;
  62294. /**
  62295. * Inserts the translation vector (using 3 floats) in the current matrix
  62296. * @param x defines the 1st component of the translation
  62297. * @param y defines the 2nd component of the translation
  62298. * @param z defines the 3rd component of the translation
  62299. * @returns the current updated matrix
  62300. */
  62301. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  62302. /**
  62303. * Adds the translation vector (using 3 floats) in the current matrix
  62304. * @param x defines the 1st component of the translation
  62305. * @param y defines the 2nd component of the translation
  62306. * @param z defines the 3rd component of the translation
  62307. * @returns the current updated matrix
  62308. */
  62309. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  62310. /**
  62311. * Inserts the translation vector in the current matrix
  62312. * @param vector3 defines the translation to insert
  62313. * @returns the current updated matrix
  62314. */
  62315. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  62316. /**
  62317. * Gets the translation value of the current matrix
  62318. * @returns a new Vector3 as the extracted translation from the matrix
  62319. */
  62320. getTranslation(): Vector3;
  62321. /**
  62322. * Fill a Vector3 with the extracted translation from the matrix
  62323. * @param result defines the Vector3 where to store the translation
  62324. * @returns the current matrix
  62325. */
  62326. getTranslationToRef(result: Vector3): Matrix;
  62327. /**
  62328. * Remove rotation and scaling part from the matrix
  62329. * @returns the updated matrix
  62330. */
  62331. removeRotationAndScaling(): Matrix;
  62332. /**
  62333. * Multiply two matrices
  62334. * @param other defines the second operand
  62335. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  62336. */
  62337. multiply(other: DeepImmutable<Matrix>): Matrix;
  62338. /**
  62339. * Copy the current matrix from the given one
  62340. * @param other defines the source matrix
  62341. * @returns the current updated matrix
  62342. */
  62343. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  62344. /**
  62345. * Populates the given array from the starting index with the current matrix values
  62346. * @param array defines the target array
  62347. * @param offset defines the offset in the target array where to start storing values
  62348. * @returns the current matrix
  62349. */
  62350. copyToArray(array: Float32Array, offset?: number): Matrix;
  62351. /**
  62352. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  62353. * @param other defines the second operand
  62354. * @param result defines the matrix where to store the multiplication
  62355. * @returns the current matrix
  62356. */
  62357. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  62358. /**
  62359. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  62360. * @param other defines the second operand
  62361. * @param result defines the array where to store the multiplication
  62362. * @param offset defines the offset in the target array where to start storing values
  62363. * @returns the current matrix
  62364. */
  62365. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  62366. /**
  62367. * Check equality between this matrix and a second one
  62368. * @param value defines the second matrix to compare
  62369. * @returns true is the current matrix and the given one values are strictly equal
  62370. */
  62371. equals(value: DeepImmutable<Matrix>): boolean;
  62372. /**
  62373. * Clone the current matrix
  62374. * @returns a new matrix from the current matrix
  62375. */
  62376. clone(): Matrix;
  62377. /**
  62378. * Returns the name of the current matrix class
  62379. * @returns the string "Matrix"
  62380. */
  62381. getClassName(): string;
  62382. /**
  62383. * Gets the hash code of the current matrix
  62384. * @returns the hash code
  62385. */
  62386. getHashCode(): number;
  62387. /**
  62388. * Decomposes the current Matrix into a translation, rotation and scaling components
  62389. * @param scale defines the scale vector3 given as a reference to update
  62390. * @param rotation defines the rotation quaternion given as a reference to update
  62391. * @param translation defines the translation vector3 given as a reference to update
  62392. * @returns true if operation was successful
  62393. */
  62394. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  62395. /**
  62396. * Gets specific row of the matrix
  62397. * @param index defines the number of the row to get
  62398. * @returns the index-th row of the current matrix as a new Vector4
  62399. */
  62400. getRow(index: number): Nullable<Vector4>;
  62401. /**
  62402. * Sets the index-th row of the current matrix to the vector4 values
  62403. * @param index defines the number of the row to set
  62404. * @param row defines the target vector4
  62405. * @returns the updated current matrix
  62406. */
  62407. setRow(index: number, row: Vector4): Matrix;
  62408. /**
  62409. * Compute the transpose of the matrix
  62410. * @returns the new transposed matrix
  62411. */
  62412. transpose(): Matrix;
  62413. /**
  62414. * Compute the transpose of the matrix and store it in a given matrix
  62415. * @param result defines the target matrix
  62416. * @returns the current matrix
  62417. */
  62418. transposeToRef(result: Matrix): Matrix;
  62419. /**
  62420. * Sets the index-th row of the current matrix with the given 4 x float values
  62421. * @param index defines the row index
  62422. * @param x defines the x component to set
  62423. * @param y defines the y component to set
  62424. * @param z defines the z component to set
  62425. * @param w defines the w component to set
  62426. * @returns the updated current matrix
  62427. */
  62428. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  62429. /**
  62430. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  62431. * @param scale defines the scale factor
  62432. * @returns a new matrix
  62433. */
  62434. scale(scale: number): Matrix;
  62435. /**
  62436. * Scale the current matrix values by a factor to a given result matrix
  62437. * @param scale defines the scale factor
  62438. * @param result defines the matrix to store the result
  62439. * @returns the current matrix
  62440. */
  62441. scaleToRef(scale: number, result: Matrix): Matrix;
  62442. /**
  62443. * Scale the current matrix values by a factor and add the result to a given matrix
  62444. * @param scale defines the scale factor
  62445. * @param result defines the Matrix to store the result
  62446. * @returns the current matrix
  62447. */
  62448. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  62449. /**
  62450. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  62451. * @param ref matrix to store the result
  62452. */
  62453. toNormalMatrix(ref: Matrix): void;
  62454. /**
  62455. * Gets only rotation part of the current matrix
  62456. * @returns a new matrix sets to the extracted rotation matrix from the current one
  62457. */
  62458. getRotationMatrix(): Matrix;
  62459. /**
  62460. * Extracts the rotation matrix from the current one and sets it as the given "result"
  62461. * @param result defines the target matrix to store data to
  62462. * @returns the current matrix
  62463. */
  62464. getRotationMatrixToRef(result: Matrix): Matrix;
  62465. /**
  62466. * Toggles model matrix from being right handed to left handed in place and vice versa
  62467. */
  62468. toggleModelMatrixHandInPlace(): void;
  62469. /**
  62470. * Toggles projection matrix from being right handed to left handed in place and vice versa
  62471. */
  62472. toggleProjectionMatrixHandInPlace(): void;
  62473. /**
  62474. * Creates a matrix from an array
  62475. * @param array defines the source array
  62476. * @param offset defines an offset in the source array
  62477. * @returns a new Matrix set from the starting index of the given array
  62478. */
  62479. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  62480. /**
  62481. * Copy the content of an array into a given matrix
  62482. * @param array defines the source array
  62483. * @param offset defines an offset in the source array
  62484. * @param result defines the target matrix
  62485. */
  62486. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  62487. /**
  62488. * Stores an array into a matrix after having multiplied each component by a given factor
  62489. * @param array defines the source array
  62490. * @param offset defines the offset in the source array
  62491. * @param scale defines the scaling factor
  62492. * @param result defines the target matrix
  62493. */
  62494. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  62495. /**
  62496. * Gets an identity matrix that must not be updated
  62497. */
  62498. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  62499. /**
  62500. * Stores a list of values (16) inside a given matrix
  62501. * @param initialM11 defines 1st value of 1st row
  62502. * @param initialM12 defines 2nd value of 1st row
  62503. * @param initialM13 defines 3rd value of 1st row
  62504. * @param initialM14 defines 4th value of 1st row
  62505. * @param initialM21 defines 1st value of 2nd row
  62506. * @param initialM22 defines 2nd value of 2nd row
  62507. * @param initialM23 defines 3rd value of 2nd row
  62508. * @param initialM24 defines 4th value of 2nd row
  62509. * @param initialM31 defines 1st value of 3rd row
  62510. * @param initialM32 defines 2nd value of 3rd row
  62511. * @param initialM33 defines 3rd value of 3rd row
  62512. * @param initialM34 defines 4th value of 3rd row
  62513. * @param initialM41 defines 1st value of 4th row
  62514. * @param initialM42 defines 2nd value of 4th row
  62515. * @param initialM43 defines 3rd value of 4th row
  62516. * @param initialM44 defines 4th value of 4th row
  62517. * @param result defines the target matrix
  62518. */
  62519. 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;
  62520. /**
  62521. * Creates new matrix from a list of values (16)
  62522. * @param initialM11 defines 1st value of 1st row
  62523. * @param initialM12 defines 2nd value of 1st row
  62524. * @param initialM13 defines 3rd value of 1st row
  62525. * @param initialM14 defines 4th value of 1st row
  62526. * @param initialM21 defines 1st value of 2nd row
  62527. * @param initialM22 defines 2nd value of 2nd row
  62528. * @param initialM23 defines 3rd value of 2nd row
  62529. * @param initialM24 defines 4th value of 2nd row
  62530. * @param initialM31 defines 1st value of 3rd row
  62531. * @param initialM32 defines 2nd value of 3rd row
  62532. * @param initialM33 defines 3rd value of 3rd row
  62533. * @param initialM34 defines 4th value of 3rd row
  62534. * @param initialM41 defines 1st value of 4th row
  62535. * @param initialM42 defines 2nd value of 4th row
  62536. * @param initialM43 defines 3rd value of 4th row
  62537. * @param initialM44 defines 4th value of 4th row
  62538. * @returns the new matrix
  62539. */
  62540. 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;
  62541. /**
  62542. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  62543. * @param scale defines the scale vector3
  62544. * @param rotation defines the rotation quaternion
  62545. * @param translation defines the translation vector3
  62546. * @returns a new matrix
  62547. */
  62548. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  62549. /**
  62550. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  62551. * @param scale defines the scale vector3
  62552. * @param rotation defines the rotation quaternion
  62553. * @param translation defines the translation vector3
  62554. * @param result defines the target matrix
  62555. */
  62556. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  62557. /**
  62558. * Creates a new identity matrix
  62559. * @returns a new identity matrix
  62560. */
  62561. static Identity(): Matrix;
  62562. /**
  62563. * Creates a new identity matrix and stores the result in a given matrix
  62564. * @param result defines the target matrix
  62565. */
  62566. static IdentityToRef(result: Matrix): void;
  62567. /**
  62568. * Creates a new zero matrix
  62569. * @returns a new zero matrix
  62570. */
  62571. static Zero(): Matrix;
  62572. /**
  62573. * Creates a new rotation matrix for "angle" radians around the X axis
  62574. * @param angle defines the angle (in radians) to use
  62575. * @return the new matrix
  62576. */
  62577. static RotationX(angle: number): Matrix;
  62578. /**
  62579. * Creates a new matrix as the invert of a given matrix
  62580. * @param source defines the source matrix
  62581. * @returns the new matrix
  62582. */
  62583. static Invert(source: DeepImmutable<Matrix>): Matrix;
  62584. /**
  62585. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  62586. * @param angle defines the angle (in radians) to use
  62587. * @param result defines the target matrix
  62588. */
  62589. static RotationXToRef(angle: number, result: Matrix): void;
  62590. /**
  62591. * Creates a new rotation matrix for "angle" radians around the Y axis
  62592. * @param angle defines the angle (in radians) to use
  62593. * @return the new matrix
  62594. */
  62595. static RotationY(angle: number): Matrix;
  62596. /**
  62597. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  62598. * @param angle defines the angle (in radians) to use
  62599. * @param result defines the target matrix
  62600. */
  62601. static RotationYToRef(angle: number, result: Matrix): void;
  62602. /**
  62603. * Creates a new rotation matrix for "angle" radians around the Z axis
  62604. * @param angle defines the angle (in radians) to use
  62605. * @return the new matrix
  62606. */
  62607. static RotationZ(angle: number): Matrix;
  62608. /**
  62609. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  62610. * @param angle defines the angle (in radians) to use
  62611. * @param result defines the target matrix
  62612. */
  62613. static RotationZToRef(angle: number, result: Matrix): void;
  62614. /**
  62615. * Creates a new rotation matrix for "angle" radians around the given axis
  62616. * @param axis defines the axis to use
  62617. * @param angle defines the angle (in radians) to use
  62618. * @return the new matrix
  62619. */
  62620. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  62621. /**
  62622. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  62623. * @param axis defines the axis to use
  62624. * @param angle defines the angle (in radians) to use
  62625. * @param result defines the target matrix
  62626. */
  62627. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  62628. /**
  62629. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  62630. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  62631. * @param from defines the vector to align
  62632. * @param to defines the vector to align to
  62633. * @param result defines the target matrix
  62634. */
  62635. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  62636. /**
  62637. * Creates a rotation matrix
  62638. * @param yaw defines the yaw angle in radians (Y axis)
  62639. * @param pitch defines the pitch angle in radians (X axis)
  62640. * @param roll defines the roll angle in radians (X axis)
  62641. * @returns the new rotation matrix
  62642. */
  62643. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  62644. /**
  62645. * Creates a rotation matrix and stores it in a given matrix
  62646. * @param yaw defines the yaw angle in radians (Y axis)
  62647. * @param pitch defines the pitch angle in radians (X axis)
  62648. * @param roll defines the roll angle in radians (X axis)
  62649. * @param result defines the target matrix
  62650. */
  62651. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  62652. /**
  62653. * Creates a scaling matrix
  62654. * @param x defines the scale factor on X axis
  62655. * @param y defines the scale factor on Y axis
  62656. * @param z defines the scale factor on Z axis
  62657. * @returns the new matrix
  62658. */
  62659. static Scaling(x: number, y: number, z: number): Matrix;
  62660. /**
  62661. * Creates a scaling matrix and stores it in a given matrix
  62662. * @param x defines the scale factor on X axis
  62663. * @param y defines the scale factor on Y axis
  62664. * @param z defines the scale factor on Z axis
  62665. * @param result defines the target matrix
  62666. */
  62667. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  62668. /**
  62669. * Creates a translation matrix
  62670. * @param x defines the translation on X axis
  62671. * @param y defines the translation on Y axis
  62672. * @param z defines the translationon Z axis
  62673. * @returns the new matrix
  62674. */
  62675. static Translation(x: number, y: number, z: number): Matrix;
  62676. /**
  62677. * Creates a translation matrix and stores it in a given matrix
  62678. * @param x defines the translation on X axis
  62679. * @param y defines the translation on Y axis
  62680. * @param z defines the translationon Z axis
  62681. * @param result defines the target matrix
  62682. */
  62683. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  62684. /**
  62685. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  62686. * @param startValue defines the start value
  62687. * @param endValue defines the end value
  62688. * @param gradient defines the gradient factor
  62689. * @returns the new matrix
  62690. */
  62691. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  62692. /**
  62693. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  62694. * @param startValue defines the start value
  62695. * @param endValue defines the end value
  62696. * @param gradient defines the gradient factor
  62697. * @param result defines the Matrix object where to store data
  62698. */
  62699. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  62700. /**
  62701. * Builds a new matrix whose values are computed by:
  62702. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  62703. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  62704. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  62705. * @param startValue defines the first matrix
  62706. * @param endValue defines the second matrix
  62707. * @param gradient defines the gradient between the two matrices
  62708. * @returns the new matrix
  62709. */
  62710. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  62711. /**
  62712. * Update a matrix to values which are computed by:
  62713. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  62714. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  62715. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  62716. * @param startValue defines the first matrix
  62717. * @param endValue defines the second matrix
  62718. * @param gradient defines the gradient between the two matrices
  62719. * @param result defines the target matrix
  62720. */
  62721. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  62722. /**
  62723. * 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"
  62724. * This function works in left handed mode
  62725. * @param eye defines the final position of the entity
  62726. * @param target defines where the entity should look at
  62727. * @param up defines the up vector for the entity
  62728. * @returns the new matrix
  62729. */
  62730. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  62731. /**
  62732. * 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".
  62733. * This function works in left handed mode
  62734. * @param eye defines the final position of the entity
  62735. * @param target defines where the entity should look at
  62736. * @param up defines the up vector for the entity
  62737. * @param result defines the target matrix
  62738. */
  62739. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  62740. /**
  62741. * 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"
  62742. * This function works in right handed mode
  62743. * @param eye defines the final position of the entity
  62744. * @param target defines where the entity should look at
  62745. * @param up defines the up vector for the entity
  62746. * @returns the new matrix
  62747. */
  62748. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  62749. /**
  62750. * 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".
  62751. * This function works in right handed mode
  62752. * @param eye defines the final position of the entity
  62753. * @param target defines where the entity should look at
  62754. * @param up defines the up vector for the entity
  62755. * @param result defines the target matrix
  62756. */
  62757. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  62758. /**
  62759. * Create a left-handed orthographic projection matrix
  62760. * @param width defines the viewport width
  62761. * @param height defines the viewport height
  62762. * @param znear defines the near clip plane
  62763. * @param zfar defines the far clip plane
  62764. * @returns a new matrix as a left-handed orthographic projection matrix
  62765. */
  62766. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  62767. /**
  62768. * Store a left-handed orthographic projection to a given matrix
  62769. * @param width defines the viewport width
  62770. * @param height defines the viewport height
  62771. * @param znear defines the near clip plane
  62772. * @param zfar defines the far clip plane
  62773. * @param result defines the target matrix
  62774. */
  62775. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  62776. /**
  62777. * Create a left-handed orthographic projection matrix
  62778. * @param left defines the viewport left coordinate
  62779. * @param right defines the viewport right coordinate
  62780. * @param bottom defines the viewport bottom coordinate
  62781. * @param top defines the viewport top coordinate
  62782. * @param znear defines the near clip plane
  62783. * @param zfar defines the far clip plane
  62784. * @returns a new matrix as a left-handed orthographic projection matrix
  62785. */
  62786. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  62787. /**
  62788. * Stores a left-handed orthographic projection into a given matrix
  62789. * @param left defines the viewport left coordinate
  62790. * @param right defines the viewport right coordinate
  62791. * @param bottom defines the viewport bottom coordinate
  62792. * @param top defines the viewport top coordinate
  62793. * @param znear defines the near clip plane
  62794. * @param zfar defines the far clip plane
  62795. * @param result defines the target matrix
  62796. */
  62797. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  62798. /**
  62799. * Creates a right-handed orthographic projection matrix
  62800. * @param left defines the viewport left coordinate
  62801. * @param right defines the viewport right coordinate
  62802. * @param bottom defines the viewport bottom coordinate
  62803. * @param top defines the viewport top coordinate
  62804. * @param znear defines the near clip plane
  62805. * @param zfar defines the far clip plane
  62806. * @returns a new matrix as a right-handed orthographic projection matrix
  62807. */
  62808. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  62809. /**
  62810. * Stores a right-handed orthographic projection into a given matrix
  62811. * @param left defines the viewport left coordinate
  62812. * @param right defines the viewport right coordinate
  62813. * @param bottom defines the viewport bottom coordinate
  62814. * @param top defines the viewport top coordinate
  62815. * @param znear defines the near clip plane
  62816. * @param zfar defines the far clip plane
  62817. * @param result defines the target matrix
  62818. */
  62819. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  62820. /**
  62821. * Creates a left-handed perspective projection matrix
  62822. * @param width defines the viewport width
  62823. * @param height defines the viewport height
  62824. * @param znear defines the near clip plane
  62825. * @param zfar defines the far clip plane
  62826. * @returns a new matrix as a left-handed perspective projection matrix
  62827. */
  62828. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  62829. /**
  62830. * Creates a left-handed perspective projection matrix
  62831. * @param fov defines the horizontal field of view
  62832. * @param aspect defines the aspect ratio
  62833. * @param znear defines the near clip plane
  62834. * @param zfar defines the far clip plane
  62835. * @returns a new matrix as a left-handed perspective projection matrix
  62836. */
  62837. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  62838. /**
  62839. * Stores a left-handed perspective projection into a given matrix
  62840. * @param fov defines the horizontal field of view
  62841. * @param aspect defines the aspect ratio
  62842. * @param znear defines the near clip plane
  62843. * @param zfar defines the far clip plane
  62844. * @param result defines the target matrix
  62845. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  62846. */
  62847. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  62848. /**
  62849. * Creates a right-handed perspective projection matrix
  62850. * @param fov defines the horizontal field of view
  62851. * @param aspect defines the aspect ratio
  62852. * @param znear defines the near clip plane
  62853. * @param zfar defines the far clip plane
  62854. * @returns a new matrix as a right-handed perspective projection matrix
  62855. */
  62856. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  62857. /**
  62858. * Stores a right-handed perspective projection into a given matrix
  62859. * @param fov defines the horizontal field of view
  62860. * @param aspect defines the aspect ratio
  62861. * @param znear defines the near clip plane
  62862. * @param zfar defines the far clip plane
  62863. * @param result defines the target matrix
  62864. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  62865. */
  62866. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  62867. /**
  62868. * Stores a perspective projection for WebVR info a given matrix
  62869. * @param fov defines the field of view
  62870. * @param znear defines the near clip plane
  62871. * @param zfar defines the far clip plane
  62872. * @param result defines the target matrix
  62873. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  62874. */
  62875. static PerspectiveFovWebVRToRef(fov: {
  62876. upDegrees: number;
  62877. downDegrees: number;
  62878. leftDegrees: number;
  62879. rightDegrees: number;
  62880. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  62881. /**
  62882. * Computes a complete transformation matrix
  62883. * @param viewport defines the viewport to use
  62884. * @param world defines the world matrix
  62885. * @param view defines the view matrix
  62886. * @param projection defines the projection matrix
  62887. * @param zmin defines the near clip plane
  62888. * @param zmax defines the far clip plane
  62889. * @returns the transformation matrix
  62890. */
  62891. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  62892. /**
  62893. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  62894. * @param matrix defines the matrix to use
  62895. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  62896. */
  62897. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  62898. /**
  62899. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  62900. * @param matrix defines the matrix to use
  62901. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  62902. */
  62903. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  62904. /**
  62905. * Compute the transpose of a given matrix
  62906. * @param matrix defines the matrix to transpose
  62907. * @returns the new matrix
  62908. */
  62909. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  62910. /**
  62911. * Compute the transpose of a matrix and store it in a target matrix
  62912. * @param matrix defines the matrix to transpose
  62913. * @param result defines the target matrix
  62914. */
  62915. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  62916. /**
  62917. * Computes a reflection matrix from a plane
  62918. * @param plane defines the reflection plane
  62919. * @returns a new matrix
  62920. */
  62921. static Reflection(plane: DeepImmutable<Plane>): Matrix;
  62922. /**
  62923. * Computes a reflection matrix from a plane
  62924. * @param plane defines the reflection plane
  62925. * @param result defines the target matrix
  62926. */
  62927. static ReflectionToRef(plane: DeepImmutable<Plane>, result: Matrix): void;
  62928. /**
  62929. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  62930. * @param xaxis defines the value of the 1st axis
  62931. * @param yaxis defines the value of the 2nd axis
  62932. * @param zaxis defines the value of the 3rd axis
  62933. * @param result defines the target matrix
  62934. */
  62935. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  62936. /**
  62937. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  62938. * @param quat defines the quaternion to use
  62939. * @param result defines the target matrix
  62940. */
  62941. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  62942. }
  62943. /**
  62944. * Represens a plane by the equation ax + by + cz + d = 0
  62945. */
  62946. export class Plane {
  62947. /**
  62948. * Normal of the plane (a,b,c)
  62949. */
  62950. normal: Vector3;
  62951. /**
  62952. * d component of the plane
  62953. */
  62954. d: number;
  62955. /**
  62956. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  62957. * @param a a component of the plane
  62958. * @param b b component of the plane
  62959. * @param c c component of the plane
  62960. * @param d d component of the plane
  62961. */
  62962. constructor(a: number, b: number, c: number, d: number);
  62963. /**
  62964. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  62965. */
  62966. asArray(): number[];
  62967. /**
  62968. * @returns a new plane copied from the current Plane.
  62969. */
  62970. clone(): Plane;
  62971. /**
  62972. * @returns the string "Plane".
  62973. */
  62974. getClassName(): string;
  62975. /**
  62976. * @returns the Plane hash code.
  62977. */
  62978. getHashCode(): number;
  62979. /**
  62980. * Normalize the current Plane in place.
  62981. * @returns the updated Plane.
  62982. */
  62983. normalize(): Plane;
  62984. /**
  62985. * Applies a transformation the plane and returns the result
  62986. * @param transformation the transformation matrix to be applied to the plane
  62987. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  62988. */
  62989. transform(transformation: DeepImmutable<Matrix>): Plane;
  62990. /**
  62991. * Calcualtte the dot product between the point and the plane normal
  62992. * @param point point to calculate the dot product with
  62993. * @returns the dot product (float) of the point coordinates and the plane normal.
  62994. */
  62995. dotCoordinate(point: DeepImmutable<Vector3>): number;
  62996. /**
  62997. * Updates the current Plane from the plane defined by the three given points.
  62998. * @param point1 one of the points used to contruct the plane
  62999. * @param point2 one of the points used to contruct the plane
  63000. * @param point3 one of the points used to contruct the plane
  63001. * @returns the updated Plane.
  63002. */
  63003. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  63004. /**
  63005. * Checks if the plane is facing a given direction
  63006. * @param direction the direction to check if the plane is facing
  63007. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  63008. * @returns True is the vector "direction" is the same side than the plane normal.
  63009. */
  63010. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  63011. /**
  63012. * Calculates the distance to a point
  63013. * @param point point to calculate distance to
  63014. * @returns the signed distance (float) from the given point to the Plane.
  63015. */
  63016. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  63017. /**
  63018. * Creates a plane from an array
  63019. * @param array the array to create a plane from
  63020. * @returns a new Plane from the given array.
  63021. */
  63022. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  63023. /**
  63024. * Creates a plane from three points
  63025. * @param point1 point used to create the plane
  63026. * @param point2 point used to create the plane
  63027. * @param point3 point used to create the plane
  63028. * @returns a new Plane defined by the three given points.
  63029. */
  63030. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  63031. /**
  63032. * Creates a plane from an origin point and a normal
  63033. * @param origin origin of the plane to be constructed
  63034. * @param normal normal of the plane to be constructed
  63035. * @returns a new Plane the normal vector to this plane at the given origin point.
  63036. * Note : the vector "normal" is updated because normalized.
  63037. */
  63038. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  63039. /**
  63040. * Calculates the distance from a plane and a point
  63041. * @param origin origin of the plane to be constructed
  63042. * @param normal normal of the plane to be constructed
  63043. * @param point point to calculate distance to
  63044. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  63045. */
  63046. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  63047. }
  63048. /**
  63049. * Class used to represent a viewport on screen
  63050. */
  63051. export class Viewport {
  63052. /** viewport left coordinate */
  63053. x: number;
  63054. /** viewport top coordinate */
  63055. y: number;
  63056. /**viewport width */
  63057. width: number;
  63058. /** viewport height */
  63059. height: number;
  63060. /**
  63061. * Creates a Viewport object located at (x, y) and sized (width, height)
  63062. * @param x defines viewport left coordinate
  63063. * @param y defines viewport top coordinate
  63064. * @param width defines the viewport width
  63065. * @param height defines the viewport height
  63066. */
  63067. constructor(
  63068. /** viewport left coordinate */
  63069. x: number,
  63070. /** viewport top coordinate */
  63071. y: number,
  63072. /**viewport width */
  63073. width: number,
  63074. /** viewport height */
  63075. height: number);
  63076. /**
  63077. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  63078. * @param renderWidth defines the rendering width
  63079. * @param renderHeight defines the rendering height
  63080. * @returns a new Viewport
  63081. */
  63082. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  63083. /**
  63084. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  63085. * @param renderWidth defines the rendering width
  63086. * @param renderHeight defines the rendering height
  63087. * @param ref defines the target viewport
  63088. * @returns the current viewport
  63089. */
  63090. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  63091. /**
  63092. * Returns a new Viewport copied from the current one
  63093. * @returns a new Viewport
  63094. */
  63095. clone(): Viewport;
  63096. }
  63097. /**
  63098. * Reprasents a camera frustum
  63099. */
  63100. export class Frustum {
  63101. /**
  63102. * Gets the planes representing the frustum
  63103. * @param transform matrix to be applied to the returned planes
  63104. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  63105. */
  63106. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  63107. /**
  63108. * Gets the near frustum plane transformed by the transform matrix
  63109. * @param transform transformation matrix to be applied to the resulting frustum plane
  63110. * @param frustumPlane the resuling frustum plane
  63111. */
  63112. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  63113. /**
  63114. * Gets the far frustum plane transformed by the transform matrix
  63115. * @param transform transformation matrix to be applied to the resulting frustum plane
  63116. * @param frustumPlane the resuling frustum plane
  63117. */
  63118. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  63119. /**
  63120. * Gets the left frustum plane transformed by the transform matrix
  63121. * @param transform transformation matrix to be applied to the resulting frustum plane
  63122. * @param frustumPlane the resuling frustum plane
  63123. */
  63124. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  63125. /**
  63126. * Gets the right frustum plane transformed by the transform matrix
  63127. * @param transform transformation matrix to be applied to the resulting frustum plane
  63128. * @param frustumPlane the resuling frustum plane
  63129. */
  63130. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  63131. /**
  63132. * Gets the top frustum plane transformed by the transform matrix
  63133. * @param transform transformation matrix to be applied to the resulting frustum plane
  63134. * @param frustumPlane the resuling frustum plane
  63135. */
  63136. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  63137. /**
  63138. * Gets the bottom frustum plane transformed by the transform matrix
  63139. * @param transform transformation matrix to be applied to the resulting frustum plane
  63140. * @param frustumPlane the resuling frustum plane
  63141. */
  63142. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  63143. /**
  63144. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  63145. * @param transform transformation matrix to be applied to the resulting frustum planes
  63146. * @param frustumPlanes the resuling frustum planes
  63147. */
  63148. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  63149. }
  63150. /** Defines supported spaces */
  63151. export enum Space {
  63152. /** Local (object) space */
  63153. LOCAL = 0,
  63154. /** World space */
  63155. WORLD = 1,
  63156. /** Bone space */
  63157. BONE = 2
  63158. }
  63159. /** Defines the 3 main axes */
  63160. export class Axis {
  63161. /** X axis */
  63162. static X: Vector3;
  63163. /** Y axis */
  63164. static Y: Vector3;
  63165. /** Z axis */
  63166. static Z: Vector3;
  63167. }
  63168. /** Class used to represent a Bezier curve */
  63169. export class BezierCurve {
  63170. /**
  63171. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  63172. * @param t defines the time
  63173. * @param x1 defines the left coordinate on X axis
  63174. * @param y1 defines the left coordinate on Y axis
  63175. * @param x2 defines the right coordinate on X axis
  63176. * @param y2 defines the right coordinate on Y axis
  63177. * @returns the interpolated value
  63178. */
  63179. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  63180. }
  63181. /**
  63182. * Defines potential orientation for back face culling
  63183. */
  63184. export enum Orientation {
  63185. /**
  63186. * Clockwise
  63187. */
  63188. CW = 0,
  63189. /** Counter clockwise */
  63190. CCW = 1
  63191. }
  63192. /**
  63193. * Defines angle representation
  63194. */
  63195. export class Angle {
  63196. private _radians;
  63197. /**
  63198. * Creates an Angle object of "radians" radians (float).
  63199. * @param radians the angle in radians
  63200. */
  63201. constructor(radians: number);
  63202. /**
  63203. * Get value in degrees
  63204. * @returns the Angle value in degrees (float)
  63205. */
  63206. degrees(): number;
  63207. /**
  63208. * Get value in radians
  63209. * @returns the Angle value in radians (float)
  63210. */
  63211. radians(): number;
  63212. /**
  63213. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  63214. * @param a defines first vector
  63215. * @param b defines second vector
  63216. * @returns a new Angle
  63217. */
  63218. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  63219. /**
  63220. * Gets a new Angle object from the given float in radians
  63221. * @param radians defines the angle value in radians
  63222. * @returns a new Angle
  63223. */
  63224. static FromRadians(radians: number): Angle;
  63225. /**
  63226. * Gets a new Angle object from the given float in degrees
  63227. * @param degrees defines the angle value in degrees
  63228. * @returns a new Angle
  63229. */
  63230. static FromDegrees(degrees: number): Angle;
  63231. }
  63232. /**
  63233. * This represents an arc in a 2d space.
  63234. */
  63235. export class Arc2 {
  63236. /** Defines the start point of the arc */
  63237. startPoint: Vector2;
  63238. /** Defines the mid point of the arc */
  63239. midPoint: Vector2;
  63240. /** Defines the end point of the arc */
  63241. endPoint: Vector2;
  63242. /**
  63243. * Defines the center point of the arc.
  63244. */
  63245. centerPoint: Vector2;
  63246. /**
  63247. * Defines the radius of the arc.
  63248. */
  63249. radius: number;
  63250. /**
  63251. * Defines the angle of the arc (from mid point to end point).
  63252. */
  63253. angle: Angle;
  63254. /**
  63255. * Defines the start angle of the arc (from start point to middle point).
  63256. */
  63257. startAngle: Angle;
  63258. /**
  63259. * Defines the orientation of the arc (clock wise/counter clock wise).
  63260. */
  63261. orientation: Orientation;
  63262. /**
  63263. * Creates an Arc object from the three given points : start, middle and end.
  63264. * @param startPoint Defines the start point of the arc
  63265. * @param midPoint Defines the midlle point of the arc
  63266. * @param endPoint Defines the end point of the arc
  63267. */
  63268. constructor(
  63269. /** Defines the start point of the arc */
  63270. startPoint: Vector2,
  63271. /** Defines the mid point of the arc */
  63272. midPoint: Vector2,
  63273. /** Defines the end point of the arc */
  63274. endPoint: Vector2);
  63275. }
  63276. /**
  63277. * Represents a 2D path made up of multiple 2D points
  63278. */
  63279. export class Path2 {
  63280. private _points;
  63281. private _length;
  63282. /**
  63283. * If the path start and end point are the same
  63284. */
  63285. closed: boolean;
  63286. /**
  63287. * Creates a Path2 object from the starting 2D coordinates x and y.
  63288. * @param x the starting points x value
  63289. * @param y the starting points y value
  63290. */
  63291. constructor(x: number, y: number);
  63292. /**
  63293. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  63294. * @param x the added points x value
  63295. * @param y the added points y value
  63296. * @returns the updated Path2.
  63297. */
  63298. addLineTo(x: number, y: number): Path2;
  63299. /**
  63300. * 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.
  63301. * @param midX middle point x value
  63302. * @param midY middle point y value
  63303. * @param endX end point x value
  63304. * @param endY end point y value
  63305. * @param numberOfSegments (default: 36)
  63306. * @returns the updated Path2.
  63307. */
  63308. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  63309. /**
  63310. * Closes the Path2.
  63311. * @returns the Path2.
  63312. */
  63313. close(): Path2;
  63314. /**
  63315. * Gets the sum of the distance between each sequential point in the path
  63316. * @returns the Path2 total length (float).
  63317. */
  63318. length(): number;
  63319. /**
  63320. * Gets the points which construct the path
  63321. * @returns the Path2 internal array of points.
  63322. */
  63323. getPoints(): Vector2[];
  63324. /**
  63325. * Retreives the point at the distance aways from the starting point
  63326. * @param normalizedLengthPosition the length along the path to retreive the point from
  63327. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  63328. */
  63329. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  63330. /**
  63331. * Creates a new path starting from an x and y position
  63332. * @param x starting x value
  63333. * @param y starting y value
  63334. * @returns a new Path2 starting at the coordinates (x, y).
  63335. */
  63336. static StartingAt(x: number, y: number): Path2;
  63337. }
  63338. /**
  63339. * Represents a 3D path made up of multiple 3D points
  63340. */
  63341. export class Path3D {
  63342. /**
  63343. * an array of Vector3, the curve axis of the Path3D
  63344. */
  63345. path: Vector3[];
  63346. private _curve;
  63347. private _distances;
  63348. private _tangents;
  63349. private _normals;
  63350. private _binormals;
  63351. private _raw;
  63352. /**
  63353. * new Path3D(path, normal, raw)
  63354. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  63355. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  63356. * @param path an array of Vector3, the curve axis of the Path3D
  63357. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  63358. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  63359. */
  63360. constructor(
  63361. /**
  63362. * an array of Vector3, the curve axis of the Path3D
  63363. */
  63364. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  63365. /**
  63366. * Returns the Path3D array of successive Vector3 designing its curve.
  63367. * @returns the Path3D array of successive Vector3 designing its curve.
  63368. */
  63369. getCurve(): Vector3[];
  63370. /**
  63371. * Returns an array populated with tangent vectors on each Path3D curve point.
  63372. * @returns an array populated with tangent vectors on each Path3D curve point.
  63373. */
  63374. getTangents(): Vector3[];
  63375. /**
  63376. * Returns an array populated with normal vectors on each Path3D curve point.
  63377. * @returns an array populated with normal vectors on each Path3D curve point.
  63378. */
  63379. getNormals(): Vector3[];
  63380. /**
  63381. * Returns an array populated with binormal vectors on each Path3D curve point.
  63382. * @returns an array populated with binormal vectors on each Path3D curve point.
  63383. */
  63384. getBinormals(): Vector3[];
  63385. /**
  63386. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  63387. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  63388. */
  63389. getDistances(): number[];
  63390. /**
  63391. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  63392. * @param path path which all values are copied into the curves points
  63393. * @param firstNormal which should be projected onto the curve
  63394. * @returns the same object updated.
  63395. */
  63396. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  63397. private _compute;
  63398. private _getFirstNonNullVector;
  63399. private _getLastNonNullVector;
  63400. private _normalVector;
  63401. }
  63402. /**
  63403. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  63404. * A Curve3 is designed from a series of successive Vector3.
  63405. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  63406. */
  63407. export class Curve3 {
  63408. private _points;
  63409. private _length;
  63410. /**
  63411. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  63412. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  63413. * @param v1 (Vector3) the control point
  63414. * @param v2 (Vector3) the end point of the Quadratic Bezier
  63415. * @param nbPoints (integer) the wanted number of points in the curve
  63416. * @returns the created Curve3
  63417. */
  63418. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  63419. /**
  63420. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  63421. * @param v0 (Vector3) the origin point of the Cubic Bezier
  63422. * @param v1 (Vector3) the first control point
  63423. * @param v2 (Vector3) the second control point
  63424. * @param v3 (Vector3) the end point of the Cubic Bezier
  63425. * @param nbPoints (integer) the wanted number of points in the curve
  63426. * @returns the created Curve3
  63427. */
  63428. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  63429. /**
  63430. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  63431. * @param p1 (Vector3) the origin point of the Hermite Spline
  63432. * @param t1 (Vector3) the tangent vector at the origin point
  63433. * @param p2 (Vector3) the end point of the Hermite Spline
  63434. * @param t2 (Vector3) the tangent vector at the end point
  63435. * @param nbPoints (integer) the wanted number of points in the curve
  63436. * @returns the created Curve3
  63437. */
  63438. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  63439. /**
  63440. * Returns a Curve3 object along a CatmullRom Spline curve :
  63441. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  63442. * @param nbPoints (integer) the wanted number of points between each curve control points
  63443. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  63444. * @returns the created Curve3
  63445. */
  63446. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  63447. /**
  63448. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  63449. * A Curve3 is designed from a series of successive Vector3.
  63450. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  63451. * @param points points which make up the curve
  63452. */
  63453. constructor(points: Vector3[]);
  63454. /**
  63455. * @returns the Curve3 stored array of successive Vector3
  63456. */
  63457. getPoints(): Vector3[];
  63458. /**
  63459. * @returns the computed length (float) of the curve.
  63460. */
  63461. length(): number;
  63462. /**
  63463. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  63464. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  63465. * curveA and curveB keep unchanged.
  63466. * @param curve the curve to continue from this curve
  63467. * @returns the newly constructed curve
  63468. */
  63469. continue(curve: DeepImmutable<Curve3>): Curve3;
  63470. private _computeLength;
  63471. }
  63472. /**
  63473. * Contains position and normal vectors for a vertex
  63474. */
  63475. export class PositionNormalVertex {
  63476. /** the position of the vertex (defaut: 0,0,0) */
  63477. position: Vector3;
  63478. /** the normal of the vertex (defaut: 0,1,0) */
  63479. normal: Vector3;
  63480. /**
  63481. * Creates a PositionNormalVertex
  63482. * @param position the position of the vertex (defaut: 0,0,0)
  63483. * @param normal the normal of the vertex (defaut: 0,1,0)
  63484. */
  63485. constructor(
  63486. /** the position of the vertex (defaut: 0,0,0) */
  63487. position?: Vector3,
  63488. /** the normal of the vertex (defaut: 0,1,0) */
  63489. normal?: Vector3);
  63490. /**
  63491. * Clones the PositionNormalVertex
  63492. * @returns the cloned PositionNormalVertex
  63493. */
  63494. clone(): PositionNormalVertex;
  63495. }
  63496. /**
  63497. * Contains position, normal and uv vectors for a vertex
  63498. */
  63499. export class PositionNormalTextureVertex {
  63500. /** the position of the vertex (defaut: 0,0,0) */
  63501. position: Vector3;
  63502. /** the normal of the vertex (defaut: 0,1,0) */
  63503. normal: Vector3;
  63504. /** the uv of the vertex (default: 0,0) */
  63505. uv: Vector2;
  63506. /**
  63507. * Creates a PositionNormalTextureVertex
  63508. * @param position the position of the vertex (defaut: 0,0,0)
  63509. * @param normal the normal of the vertex (defaut: 0,1,0)
  63510. * @param uv the uv of the vertex (default: 0,0)
  63511. */
  63512. constructor(
  63513. /** the position of the vertex (defaut: 0,0,0) */
  63514. position?: Vector3,
  63515. /** the normal of the vertex (defaut: 0,1,0) */
  63516. normal?: Vector3,
  63517. /** the uv of the vertex (default: 0,0) */
  63518. uv?: Vector2);
  63519. /**
  63520. * Clones the PositionNormalTextureVertex
  63521. * @returns the cloned PositionNormalTextureVertex
  63522. */
  63523. clone(): PositionNormalTextureVertex;
  63524. }
  63525. /**
  63526. * @hidden
  63527. */
  63528. export class Tmp {
  63529. static Color3: Color3[];
  63530. static Color4: Color4[];
  63531. static Vector2: Vector2[];
  63532. static Vector3: Vector3[];
  63533. static Vector4: Vector4[];
  63534. static Quaternion: Quaternion[];
  63535. static Matrix: Matrix[];
  63536. }
  63537. }
  63538. declare module BABYLON {
  63539. /**
  63540. * Class used to enable access to offline support
  63541. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  63542. */
  63543. export interface IOfflineProvider {
  63544. /**
  63545. * Gets a boolean indicating if scene must be saved in the database
  63546. */
  63547. enableSceneOffline: boolean;
  63548. /**
  63549. * Gets a boolean indicating if textures must be saved in the database
  63550. */
  63551. enableTexturesOffline: boolean;
  63552. /**
  63553. * Open the offline support and make it available
  63554. * @param successCallback defines the callback to call on success
  63555. * @param errorCallback defines the callback to call on error
  63556. */
  63557. open(successCallback: () => void, errorCallback: () => void): void;
  63558. /**
  63559. * Loads an image from the offline support
  63560. * @param url defines the url to load from
  63561. * @param image defines the target DOM image
  63562. */
  63563. loadImage(url: string, image: HTMLImageElement): void;
  63564. /**
  63565. * Loads a file from offline support
  63566. * @param url defines the URL to load from
  63567. * @param sceneLoaded defines a callback to call on success
  63568. * @param progressCallBack defines a callback to call when progress changed
  63569. * @param errorCallback defines a callback to call on error
  63570. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  63571. */
  63572. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  63573. }
  63574. }
  63575. declare module BABYLON {
  63576. /**
  63577. * A class serves as a medium between the observable and its observers
  63578. */
  63579. export class EventState {
  63580. /**
  63581. * Create a new EventState
  63582. * @param mask defines the mask associated with this state
  63583. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  63584. * @param target defines the original target of the state
  63585. * @param currentTarget defines the current target of the state
  63586. */
  63587. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  63588. /**
  63589. * Initialize the current event state
  63590. * @param mask defines the mask associated with this state
  63591. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  63592. * @param target defines the original target of the state
  63593. * @param currentTarget defines the current target of the state
  63594. * @returns the current event state
  63595. */
  63596. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  63597. /**
  63598. * An Observer can set this property to true to prevent subsequent observers of being notified
  63599. */
  63600. skipNextObservers: boolean;
  63601. /**
  63602. * Get the mask value that were used to trigger the event corresponding to this EventState object
  63603. */
  63604. mask: number;
  63605. /**
  63606. * The object that originally notified the event
  63607. */
  63608. target?: any;
  63609. /**
  63610. * The current object in the bubbling phase
  63611. */
  63612. currentTarget?: any;
  63613. /**
  63614. * This will be populated with the return value of the last function that was executed.
  63615. * If it is the first function in the callback chain it will be the event data.
  63616. */
  63617. lastReturnValue?: any;
  63618. }
  63619. /**
  63620. * Represent an Observer registered to a given Observable object.
  63621. */
  63622. export class Observer<T> {
  63623. /**
  63624. * Defines the callback to call when the observer is notified
  63625. */
  63626. callback: (eventData: T, eventState: EventState) => void;
  63627. /**
  63628. * Defines the mask of the observer (used to filter notifications)
  63629. */
  63630. mask: number;
  63631. /**
  63632. * Defines the current scope used to restore the JS context
  63633. */
  63634. scope: any;
  63635. /** @hidden */
  63636. _willBeUnregistered: boolean;
  63637. /**
  63638. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  63639. */
  63640. unregisterOnNextCall: boolean;
  63641. /**
  63642. * Creates a new observer
  63643. * @param callback defines the callback to call when the observer is notified
  63644. * @param mask defines the mask of the observer (used to filter notifications)
  63645. * @param scope defines the current scope used to restore the JS context
  63646. */
  63647. constructor(
  63648. /**
  63649. * Defines the callback to call when the observer is notified
  63650. */
  63651. callback: (eventData: T, eventState: EventState) => void,
  63652. /**
  63653. * Defines the mask of the observer (used to filter notifications)
  63654. */
  63655. mask: number,
  63656. /**
  63657. * Defines the current scope used to restore the JS context
  63658. */
  63659. scope?: any);
  63660. }
  63661. /**
  63662. * Represent a list of observers registered to multiple Observables object.
  63663. */
  63664. export class MultiObserver<T> {
  63665. private _observers;
  63666. private _observables;
  63667. /**
  63668. * Release associated resources
  63669. */
  63670. dispose(): void;
  63671. /**
  63672. * Raise a callback when one of the observable will notify
  63673. * @param observables defines a list of observables to watch
  63674. * @param callback defines the callback to call on notification
  63675. * @param mask defines the mask used to filter notifications
  63676. * @param scope defines the current scope used to restore the JS context
  63677. * @returns the new MultiObserver
  63678. */
  63679. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  63680. }
  63681. /**
  63682. * The Observable class is a simple implementation of the Observable pattern.
  63683. *
  63684. * 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.
  63685. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  63686. * 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).
  63687. * 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.
  63688. */
  63689. export class Observable<T> {
  63690. private _observers;
  63691. private _eventState;
  63692. private _onObserverAdded;
  63693. /**
  63694. * Creates a new observable
  63695. * @param onObserverAdded defines a callback to call when a new observer is added
  63696. */
  63697. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  63698. /**
  63699. * Create a new Observer with the specified callback
  63700. * @param callback the callback that will be executed for that Observer
  63701. * @param mask the mask used to filter observers
  63702. * @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.
  63703. * @param scope optional scope for the callback to be called from
  63704. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  63705. * @returns the new observer created for the callback
  63706. */
  63707. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  63708. /**
  63709. * Create a new Observer with the specified callback and unregisters after the next notification
  63710. * @param callback the callback that will be executed for that Observer
  63711. * @returns the new observer created for the callback
  63712. */
  63713. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  63714. /**
  63715. * Remove an Observer from the Observable object
  63716. * @param observer the instance of the Observer to remove
  63717. * @returns false if it doesn't belong to this Observable
  63718. */
  63719. remove(observer: Nullable<Observer<T>>): boolean;
  63720. /**
  63721. * Remove a callback from the Observable object
  63722. * @param callback the callback to remove
  63723. * @param scope optional scope. If used only the callbacks with this scope will be removed
  63724. * @returns false if it doesn't belong to this Observable
  63725. */
  63726. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  63727. private _deferUnregister;
  63728. private _remove;
  63729. /**
  63730. * Moves the observable to the top of the observer list making it get called first when notified
  63731. * @param observer the observer to move
  63732. */
  63733. makeObserverTopPriority(observer: Observer<T>): void;
  63734. /**
  63735. * Moves the observable to the bottom of the observer list making it get called last when notified
  63736. * @param observer the observer to move
  63737. */
  63738. makeObserverBottomPriority(observer: Observer<T>): void;
  63739. /**
  63740. * Notify all Observers by calling their respective callback with the given data
  63741. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  63742. * @param eventData defines the data to send to all observers
  63743. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  63744. * @param target defines the original target of the state
  63745. * @param currentTarget defines the current target of the state
  63746. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  63747. */
  63748. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  63749. /**
  63750. * Calling this will execute each callback, expecting it to be a promise or return a value.
  63751. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  63752. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  63753. * and it is crucial that all callbacks will be executed.
  63754. * The order of the callbacks is kept, callbacks are not executed parallel.
  63755. *
  63756. * @param eventData The data to be sent to each callback
  63757. * @param mask is used to filter observers defaults to -1
  63758. * @param target defines the callback target (see EventState)
  63759. * @param currentTarget defines he current object in the bubbling phase
  63760. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  63761. */
  63762. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  63763. /**
  63764. * Notify a specific observer
  63765. * @param observer defines the observer to notify
  63766. * @param eventData defines the data to be sent to each callback
  63767. * @param mask is used to filter observers defaults to -1
  63768. */
  63769. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  63770. /**
  63771. * Gets a boolean indicating if the observable has at least one observer
  63772. * @returns true is the Observable has at least one Observer registered
  63773. */
  63774. hasObservers(): boolean;
  63775. /**
  63776. * Clear the list of observers
  63777. */
  63778. clear(): void;
  63779. /**
  63780. * Clone the current observable
  63781. * @returns a new observable
  63782. */
  63783. clone(): Observable<T>;
  63784. /**
  63785. * Does this observable handles observer registered with a given mask
  63786. * @param mask defines the mask to be tested
  63787. * @return whether or not one observer registered with the given mask is handeled
  63788. **/
  63789. hasSpecificMask(mask?: number): boolean;
  63790. }
  63791. }
  63792. declare module BABYLON {
  63793. /**
  63794. * Class used to help managing file picking and drag'n'drop
  63795. * File Storage
  63796. */
  63797. export class FilesInputStore {
  63798. /**
  63799. * List of files ready to be loaded
  63800. */
  63801. static FilesToLoad: {
  63802. [key: string]: File;
  63803. };
  63804. }
  63805. }
  63806. declare module BABYLON {
  63807. /** Defines the cross module used constants to avoid circular dependncies */
  63808. export class Constants {
  63809. /** Defines that alpha blending is disabled */
  63810. static readonly ALPHA_DISABLE: number;
  63811. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  63812. static readonly ALPHA_ADD: number;
  63813. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  63814. static readonly ALPHA_COMBINE: number;
  63815. /** Defines that alpha blending to DEST - SRC * DEST */
  63816. static readonly ALPHA_SUBTRACT: number;
  63817. /** Defines that alpha blending to SRC * DEST */
  63818. static readonly ALPHA_MULTIPLY: number;
  63819. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  63820. static readonly ALPHA_MAXIMIZED: number;
  63821. /** Defines that alpha blending to SRC + DEST */
  63822. static readonly ALPHA_ONEONE: number;
  63823. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  63824. static readonly ALPHA_PREMULTIPLIED: number;
  63825. /**
  63826. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  63827. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  63828. */
  63829. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  63830. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  63831. static readonly ALPHA_INTERPOLATE: number;
  63832. /**
  63833. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  63834. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  63835. */
  63836. static readonly ALPHA_SCREENMODE: number;
  63837. /** Defines that the ressource is not delayed*/
  63838. static readonly DELAYLOADSTATE_NONE: number;
  63839. /** Defines that the ressource was successfully delay loaded */
  63840. static readonly DELAYLOADSTATE_LOADED: number;
  63841. /** Defines that the ressource is currently delay loading */
  63842. static readonly DELAYLOADSTATE_LOADING: number;
  63843. /** Defines that the ressource is delayed and has not started loading */
  63844. static readonly DELAYLOADSTATE_NOTLOADED: number;
  63845. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  63846. static readonly NEVER: number;
  63847. /** 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 */
  63848. static readonly ALWAYS: number;
  63849. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  63850. static readonly LESS: number;
  63851. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  63852. static readonly EQUAL: number;
  63853. /** 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 */
  63854. static readonly LEQUAL: number;
  63855. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  63856. static readonly GREATER: number;
  63857. /** 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 */
  63858. static readonly GEQUAL: number;
  63859. /** 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 */
  63860. static readonly NOTEQUAL: number;
  63861. /** Passed to stencilOperation to specify that stencil value must be kept */
  63862. static readonly KEEP: number;
  63863. /** Passed to stencilOperation to specify that stencil value must be replaced */
  63864. static readonly REPLACE: number;
  63865. /** Passed to stencilOperation to specify that stencil value must be incremented */
  63866. static readonly INCR: number;
  63867. /** Passed to stencilOperation to specify that stencil value must be decremented */
  63868. static readonly DECR: number;
  63869. /** Passed to stencilOperation to specify that stencil value must be inverted */
  63870. static readonly INVERT: number;
  63871. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  63872. static readonly INCR_WRAP: number;
  63873. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  63874. static readonly DECR_WRAP: number;
  63875. /** Texture is not repeating outside of 0..1 UVs */
  63876. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  63877. /** Texture is repeating outside of 0..1 UVs */
  63878. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  63879. /** Texture is repeating and mirrored */
  63880. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  63881. /** ALPHA */
  63882. static readonly TEXTUREFORMAT_ALPHA: number;
  63883. /** LUMINANCE */
  63884. static readonly TEXTUREFORMAT_LUMINANCE: number;
  63885. /** LUMINANCE_ALPHA */
  63886. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  63887. /** RGB */
  63888. static readonly TEXTUREFORMAT_RGB: number;
  63889. /** RGBA */
  63890. static readonly TEXTUREFORMAT_RGBA: number;
  63891. /** RED */
  63892. static readonly TEXTUREFORMAT_RED: number;
  63893. /** RED (2nd reference) */
  63894. static readonly TEXTUREFORMAT_R: number;
  63895. /** RG */
  63896. static readonly TEXTUREFORMAT_RG: number;
  63897. /** RED_INTEGER */
  63898. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  63899. /** RED_INTEGER (2nd reference) */
  63900. static readonly TEXTUREFORMAT_R_INTEGER: number;
  63901. /** RG_INTEGER */
  63902. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  63903. /** RGB_INTEGER */
  63904. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  63905. /** RGBA_INTEGER */
  63906. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  63907. /** UNSIGNED_BYTE */
  63908. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  63909. /** UNSIGNED_BYTE (2nd reference) */
  63910. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  63911. /** FLOAT */
  63912. static readonly TEXTURETYPE_FLOAT: number;
  63913. /** HALF_FLOAT */
  63914. static readonly TEXTURETYPE_HALF_FLOAT: number;
  63915. /** BYTE */
  63916. static readonly TEXTURETYPE_BYTE: number;
  63917. /** SHORT */
  63918. static readonly TEXTURETYPE_SHORT: number;
  63919. /** UNSIGNED_SHORT */
  63920. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  63921. /** INT */
  63922. static readonly TEXTURETYPE_INT: number;
  63923. /** UNSIGNED_INT */
  63924. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  63925. /** UNSIGNED_SHORT_4_4_4_4 */
  63926. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  63927. /** UNSIGNED_SHORT_5_5_5_1 */
  63928. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  63929. /** UNSIGNED_SHORT_5_6_5 */
  63930. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  63931. /** UNSIGNED_INT_2_10_10_10_REV */
  63932. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  63933. /** UNSIGNED_INT_24_8 */
  63934. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  63935. /** UNSIGNED_INT_10F_11F_11F_REV */
  63936. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  63937. /** UNSIGNED_INT_5_9_9_9_REV */
  63938. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  63939. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  63940. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  63941. /** nearest is mag = nearest and min = nearest and mip = linear */
  63942. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  63943. /** Bilinear is mag = linear and min = linear and mip = nearest */
  63944. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  63945. /** Trilinear is mag = linear and min = linear and mip = linear */
  63946. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  63947. /** nearest is mag = nearest and min = nearest and mip = linear */
  63948. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  63949. /** Bilinear is mag = linear and min = linear and mip = nearest */
  63950. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  63951. /** Trilinear is mag = linear and min = linear and mip = linear */
  63952. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  63953. /** mag = nearest and min = nearest and mip = nearest */
  63954. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  63955. /** mag = nearest and min = linear and mip = nearest */
  63956. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  63957. /** mag = nearest and min = linear and mip = linear */
  63958. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  63959. /** mag = nearest and min = linear and mip = none */
  63960. static readonly TEXTURE_NEAREST_LINEAR: number;
  63961. /** mag = nearest and min = nearest and mip = none */
  63962. static readonly TEXTURE_NEAREST_NEAREST: number;
  63963. /** mag = linear and min = nearest and mip = nearest */
  63964. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  63965. /** mag = linear and min = nearest and mip = linear */
  63966. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  63967. /** mag = linear and min = linear and mip = none */
  63968. static readonly TEXTURE_LINEAR_LINEAR: number;
  63969. /** mag = linear and min = nearest and mip = none */
  63970. static readonly TEXTURE_LINEAR_NEAREST: number;
  63971. /** Explicit coordinates mode */
  63972. static readonly TEXTURE_EXPLICIT_MODE: number;
  63973. /** Spherical coordinates mode */
  63974. static readonly TEXTURE_SPHERICAL_MODE: number;
  63975. /** Planar coordinates mode */
  63976. static readonly TEXTURE_PLANAR_MODE: number;
  63977. /** Cubic coordinates mode */
  63978. static readonly TEXTURE_CUBIC_MODE: number;
  63979. /** Projection coordinates mode */
  63980. static readonly TEXTURE_PROJECTION_MODE: number;
  63981. /** Skybox coordinates mode */
  63982. static readonly TEXTURE_SKYBOX_MODE: number;
  63983. /** Inverse Cubic coordinates mode */
  63984. static readonly TEXTURE_INVCUBIC_MODE: number;
  63985. /** Equirectangular coordinates mode */
  63986. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  63987. /** Equirectangular Fixed coordinates mode */
  63988. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  63989. /** Equirectangular Fixed Mirrored coordinates mode */
  63990. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  63991. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  63992. static readonly SCALEMODE_FLOOR: number;
  63993. /** Defines that texture rescaling will look for the nearest power of 2 size */
  63994. static readonly SCALEMODE_NEAREST: number;
  63995. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  63996. static readonly SCALEMODE_CEILING: number;
  63997. /**
  63998. * The dirty texture flag value
  63999. */
  64000. static readonly MATERIAL_TextureDirtyFlag: number;
  64001. /**
  64002. * The dirty light flag value
  64003. */
  64004. static readonly MATERIAL_LightDirtyFlag: number;
  64005. /**
  64006. * The dirty fresnel flag value
  64007. */
  64008. static readonly MATERIAL_FresnelDirtyFlag: number;
  64009. /**
  64010. * The dirty attribute flag value
  64011. */
  64012. static readonly MATERIAL_AttributesDirtyFlag: number;
  64013. /**
  64014. * The dirty misc flag value
  64015. */
  64016. static readonly MATERIAL_MiscDirtyFlag: number;
  64017. /**
  64018. * The all dirty flag value
  64019. */
  64020. static readonly MATERIAL_AllDirtyFlag: number;
  64021. /**
  64022. * Returns the triangle fill mode
  64023. */
  64024. static readonly MATERIAL_TriangleFillMode: number;
  64025. /**
  64026. * Returns the wireframe mode
  64027. */
  64028. static readonly MATERIAL_WireFrameFillMode: number;
  64029. /**
  64030. * Returns the point fill mode
  64031. */
  64032. static readonly MATERIAL_PointFillMode: number;
  64033. /**
  64034. * Returns the point list draw mode
  64035. */
  64036. static readonly MATERIAL_PointListDrawMode: number;
  64037. /**
  64038. * Returns the line list draw mode
  64039. */
  64040. static readonly MATERIAL_LineListDrawMode: number;
  64041. /**
  64042. * Returns the line loop draw mode
  64043. */
  64044. static readonly MATERIAL_LineLoopDrawMode: number;
  64045. /**
  64046. * Returns the line strip draw mode
  64047. */
  64048. static readonly MATERIAL_LineStripDrawMode: number;
  64049. /**
  64050. * Returns the triangle strip draw mode
  64051. */
  64052. static readonly MATERIAL_TriangleStripDrawMode: number;
  64053. /**
  64054. * Returns the triangle fan draw mode
  64055. */
  64056. static readonly MATERIAL_TriangleFanDrawMode: number;
  64057. /**
  64058. * Stores the clock-wise side orientation
  64059. */
  64060. static readonly MATERIAL_ClockWiseSideOrientation: number;
  64061. /**
  64062. * Stores the counter clock-wise side orientation
  64063. */
  64064. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  64065. /**
  64066. * Nothing
  64067. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64068. */
  64069. static readonly ACTION_NothingTrigger: number;
  64070. /**
  64071. * On pick
  64072. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64073. */
  64074. static readonly ACTION_OnPickTrigger: number;
  64075. /**
  64076. * On left pick
  64077. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64078. */
  64079. static readonly ACTION_OnLeftPickTrigger: number;
  64080. /**
  64081. * On right pick
  64082. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64083. */
  64084. static readonly ACTION_OnRightPickTrigger: number;
  64085. /**
  64086. * On center pick
  64087. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64088. */
  64089. static readonly ACTION_OnCenterPickTrigger: number;
  64090. /**
  64091. * On pick down
  64092. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64093. */
  64094. static readonly ACTION_OnPickDownTrigger: number;
  64095. /**
  64096. * On double pick
  64097. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64098. */
  64099. static readonly ACTION_OnDoublePickTrigger: number;
  64100. /**
  64101. * On pick up
  64102. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64103. */
  64104. static readonly ACTION_OnPickUpTrigger: number;
  64105. /**
  64106. * On pick out.
  64107. * This trigger will only be raised if you also declared a OnPickDown
  64108. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64109. */
  64110. static readonly ACTION_OnPickOutTrigger: number;
  64111. /**
  64112. * On long press
  64113. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64114. */
  64115. static readonly ACTION_OnLongPressTrigger: number;
  64116. /**
  64117. * On pointer over
  64118. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64119. */
  64120. static readonly ACTION_OnPointerOverTrigger: number;
  64121. /**
  64122. * On pointer out
  64123. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64124. */
  64125. static readonly ACTION_OnPointerOutTrigger: number;
  64126. /**
  64127. * On every frame
  64128. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64129. */
  64130. static readonly ACTION_OnEveryFrameTrigger: number;
  64131. /**
  64132. * On intersection enter
  64133. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64134. */
  64135. static readonly ACTION_OnIntersectionEnterTrigger: number;
  64136. /**
  64137. * On intersection exit
  64138. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64139. */
  64140. static readonly ACTION_OnIntersectionExitTrigger: number;
  64141. /**
  64142. * On key down
  64143. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64144. */
  64145. static readonly ACTION_OnKeyDownTrigger: number;
  64146. /**
  64147. * On key up
  64148. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64149. */
  64150. static readonly ACTION_OnKeyUpTrigger: number;
  64151. /**
  64152. * Billboard mode will only apply to Y axis
  64153. */
  64154. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  64155. /**
  64156. * Billboard mode will apply to all axes
  64157. */
  64158. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  64159. /**
  64160. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  64161. */
  64162. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  64163. /**
  64164. * Gets or sets base Assets URL
  64165. */
  64166. static readonly PARTICLES_BaseAssetsUrl: string;
  64167. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  64168. * Test order :
  64169. * Is the bounding sphere outside the frustum ?
  64170. * If not, are the bounding box vertices outside the frustum ?
  64171. * It not, then the cullable object is in the frustum.
  64172. */
  64173. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  64174. /** Culling strategy : Bounding Sphere Only.
  64175. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  64176. * It's also less accurate than the standard because some not visible objects can still be selected.
  64177. * Test : is the bounding sphere outside the frustum ?
  64178. * If not, then the cullable object is in the frustum.
  64179. */
  64180. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  64181. /** Culling strategy : Optimistic Inclusion.
  64182. * This in an inclusion test first, then the standard exclusion test.
  64183. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  64184. * 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.
  64185. * Anyway, it's as accurate as the standard strategy.
  64186. * Test :
  64187. * Is the cullable object bounding sphere center in the frustum ?
  64188. * If not, apply the default culling strategy.
  64189. */
  64190. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  64191. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  64192. * This in an inclusion test first, then the bounding sphere only exclusion test.
  64193. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  64194. * 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.
  64195. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  64196. * Test :
  64197. * Is the cullable object bounding sphere center in the frustum ?
  64198. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  64199. */
  64200. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  64201. /**
  64202. * No logging while loading
  64203. */
  64204. static readonly SCENELOADER_NO_LOGGING: number;
  64205. /**
  64206. * Minimal logging while loading
  64207. */
  64208. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  64209. /**
  64210. * Summary logging while loading
  64211. */
  64212. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  64213. /**
  64214. * Detailled logging while loading
  64215. */
  64216. static readonly SCENELOADER_DETAILED_LOGGING: number;
  64217. }
  64218. }
  64219. declare module BABYLON {
  64220. /**
  64221. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  64222. * Babylon.js
  64223. */
  64224. export class DomManagement {
  64225. /**
  64226. * Checks if the window object exists
  64227. * @returns true if the window object exists
  64228. */
  64229. static IsWindowObjectExist(): boolean;
  64230. /**
  64231. * Extracts text content from a DOM element hierarchy
  64232. * @param element defines the root element
  64233. * @returns a string
  64234. */
  64235. static GetDOMTextContent(element: HTMLElement): string;
  64236. }
  64237. }
  64238. declare module BABYLON {
  64239. /**
  64240. * Logger used througouht the application to allow configuration of
  64241. * the log level required for the messages.
  64242. */
  64243. export class Logger {
  64244. /**
  64245. * No log
  64246. */
  64247. static readonly NoneLogLevel: number;
  64248. /**
  64249. * Only message logs
  64250. */
  64251. static readonly MessageLogLevel: number;
  64252. /**
  64253. * Only warning logs
  64254. */
  64255. static readonly WarningLogLevel: number;
  64256. /**
  64257. * Only error logs
  64258. */
  64259. static readonly ErrorLogLevel: number;
  64260. /**
  64261. * All logs
  64262. */
  64263. static readonly AllLogLevel: number;
  64264. private static _LogCache;
  64265. /**
  64266. * Gets a value indicating the number of loading errors
  64267. * @ignorenaming
  64268. */
  64269. static errorsCount: number;
  64270. /**
  64271. * Callback called when a new log is added
  64272. */
  64273. static OnNewCacheEntry: (entry: string) => void;
  64274. private static _AddLogEntry;
  64275. private static _FormatMessage;
  64276. private static _LogDisabled;
  64277. private static _LogEnabled;
  64278. private static _WarnDisabled;
  64279. private static _WarnEnabled;
  64280. private static _ErrorDisabled;
  64281. private static _ErrorEnabled;
  64282. /**
  64283. * Log a message to the console
  64284. */
  64285. static Log: (message: string) => void;
  64286. /**
  64287. * Write a warning message to the console
  64288. */
  64289. static Warn: (message: string) => void;
  64290. /**
  64291. * Write an error message to the console
  64292. */
  64293. static Error: (message: string) => void;
  64294. /**
  64295. * Gets current log cache (list of logs)
  64296. */
  64297. static readonly LogCache: string;
  64298. /**
  64299. * Clears the log cache
  64300. */
  64301. static ClearLogCache(): void;
  64302. /**
  64303. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  64304. */
  64305. static LogLevels: number;
  64306. }
  64307. }
  64308. declare module BABYLON {
  64309. /** @hidden */
  64310. export class _TypeStore {
  64311. /** @hidden */
  64312. static RegisteredTypes: {
  64313. [key: string]: Object;
  64314. };
  64315. /** @hidden */
  64316. static GetClass(fqdn: string): any;
  64317. }
  64318. }
  64319. declare module BABYLON {
  64320. /**
  64321. * Class containing a set of static utilities functions for deep copy.
  64322. */
  64323. export class DeepCopier {
  64324. /**
  64325. * Tries to copy an object by duplicating every property
  64326. * @param source defines the source object
  64327. * @param destination defines the target object
  64328. * @param doNotCopyList defines a list of properties to avoid
  64329. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  64330. */
  64331. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  64332. }
  64333. }
  64334. declare module BABYLON {
  64335. /**
  64336. * Class containing a set of static utilities functions for precision date
  64337. */
  64338. export class PrecisionDate {
  64339. /**
  64340. * Gets either window.performance.now() if supported or Date.now() else
  64341. */
  64342. static readonly Now: number;
  64343. }
  64344. }
  64345. declare module BABYLON {
  64346. /** @hidden */
  64347. export class _DevTools {
  64348. static WarnImport(name: string): string;
  64349. }
  64350. }
  64351. declare module BABYLON {
  64352. /**
  64353. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  64354. */
  64355. export class WebRequest {
  64356. private _xhr;
  64357. /**
  64358. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  64359. * i.e. when loading files, where the server/service expects an Authorization header
  64360. */
  64361. static CustomRequestHeaders: {
  64362. [key: string]: string;
  64363. };
  64364. /**
  64365. * Add callback functions in this array to update all the requests before they get sent to the network
  64366. */
  64367. static CustomRequestModifiers: ((request: XMLHttpRequest) => void)[];
  64368. private _injectCustomRequestHeaders;
  64369. /**
  64370. * Gets or sets a function to be called when loading progress changes
  64371. */
  64372. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  64373. /**
  64374. * Returns client's state
  64375. */
  64376. readonly readyState: number;
  64377. /**
  64378. * Returns client's status
  64379. */
  64380. readonly status: number;
  64381. /**
  64382. * Returns client's status as a text
  64383. */
  64384. readonly statusText: string;
  64385. /**
  64386. * Returns client's response
  64387. */
  64388. readonly response: any;
  64389. /**
  64390. * Returns client's response url
  64391. */
  64392. readonly responseURL: string;
  64393. /**
  64394. * Returns client's response as text
  64395. */
  64396. readonly responseText: string;
  64397. /**
  64398. * Gets or sets the expected response type
  64399. */
  64400. responseType: XMLHttpRequestResponseType;
  64401. /** @hidden */
  64402. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  64403. /** @hidden */
  64404. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  64405. /**
  64406. * Cancels any network activity
  64407. */
  64408. abort(): void;
  64409. /**
  64410. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  64411. * @param body defines an optional request body
  64412. */
  64413. send(body?: Document | BodyInit | null): void;
  64414. /**
  64415. * Sets the request method, request URL
  64416. * @param method defines the method to use (GET, POST, etc..)
  64417. * @param url defines the url to connect with
  64418. */
  64419. open(method: string, url: string): void;
  64420. }
  64421. }
  64422. declare module BABYLON {
  64423. /**
  64424. * Class used to evalaute queries containing `and` and `or` operators
  64425. */
  64426. export class AndOrNotEvaluator {
  64427. /**
  64428. * Evaluate a query
  64429. * @param query defines the query to evaluate
  64430. * @param evaluateCallback defines the callback used to filter result
  64431. * @returns true if the query matches
  64432. */
  64433. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  64434. private static _HandleParenthesisContent;
  64435. private static _SimplifyNegation;
  64436. }
  64437. }
  64438. declare module BABYLON {
  64439. /**
  64440. * Class used to store custom tags
  64441. */
  64442. export class Tags {
  64443. /**
  64444. * Adds support for tags on the given object
  64445. * @param obj defines the object to use
  64446. */
  64447. static EnableFor(obj: any): void;
  64448. /**
  64449. * Removes tags support
  64450. * @param obj defines the object to use
  64451. */
  64452. static DisableFor(obj: any): void;
  64453. /**
  64454. * Gets a boolean indicating if the given object has tags
  64455. * @param obj defines the object to use
  64456. * @returns a boolean
  64457. */
  64458. static HasTags(obj: any): boolean;
  64459. /**
  64460. * Gets the tags available on a given object
  64461. * @param obj defines the object to use
  64462. * @param asString defines if the tags must be returned as a string instead of an array of strings
  64463. * @returns the tags
  64464. */
  64465. static GetTags(obj: any, asString?: boolean): any;
  64466. /**
  64467. * Adds tags to an object
  64468. * @param obj defines the object to use
  64469. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  64470. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  64471. */
  64472. static AddTagsTo(obj: any, tagsString: string): void;
  64473. /**
  64474. * @hidden
  64475. */
  64476. static _AddTagTo(obj: any, tag: string): void;
  64477. /**
  64478. * Removes specific tags from a specific object
  64479. * @param obj defines the object to use
  64480. * @param tagsString defines the tags to remove
  64481. */
  64482. static RemoveTagsFrom(obj: any, tagsString: string): void;
  64483. /**
  64484. * @hidden
  64485. */
  64486. static _RemoveTagFrom(obj: any, tag: string): void;
  64487. /**
  64488. * Defines if tags hosted on an object match a given query
  64489. * @param obj defines the object to use
  64490. * @param tagsQuery defines the tag query
  64491. * @returns a boolean
  64492. */
  64493. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  64494. }
  64495. }
  64496. declare module BABYLON {
  64497. /**
  64498. * Manages the defines for the Material
  64499. */
  64500. export class MaterialDefines {
  64501. private _keys;
  64502. private _isDirty;
  64503. /** @hidden */
  64504. _renderId: number;
  64505. /** @hidden */
  64506. _areLightsDirty: boolean;
  64507. /** @hidden */
  64508. _areAttributesDirty: boolean;
  64509. /** @hidden */
  64510. _areTexturesDirty: boolean;
  64511. /** @hidden */
  64512. _areFresnelDirty: boolean;
  64513. /** @hidden */
  64514. _areMiscDirty: boolean;
  64515. /** @hidden */
  64516. _areImageProcessingDirty: boolean;
  64517. /** @hidden */
  64518. _normals: boolean;
  64519. /** @hidden */
  64520. _uvs: boolean;
  64521. /** @hidden */
  64522. _needNormals: boolean;
  64523. /** @hidden */
  64524. _needUVs: boolean;
  64525. /**
  64526. * Specifies if the material needs to be re-calculated
  64527. */
  64528. readonly isDirty: boolean;
  64529. /**
  64530. * Marks the material to indicate that it has been re-calculated
  64531. */
  64532. markAsProcessed(): void;
  64533. /**
  64534. * Marks the material to indicate that it needs to be re-calculated
  64535. */
  64536. markAsUnprocessed(): void;
  64537. /**
  64538. * Marks the material to indicate all of its defines need to be re-calculated
  64539. */
  64540. markAllAsDirty(): void;
  64541. /**
  64542. * Marks the material to indicate that image processing needs to be re-calculated
  64543. */
  64544. markAsImageProcessingDirty(): void;
  64545. /**
  64546. * Marks the material to indicate the lights need to be re-calculated
  64547. */
  64548. markAsLightDirty(): void;
  64549. /**
  64550. * Marks the attribute state as changed
  64551. */
  64552. markAsAttributesDirty(): void;
  64553. /**
  64554. * Marks the texture state as changed
  64555. */
  64556. markAsTexturesDirty(): void;
  64557. /**
  64558. * Marks the fresnel state as changed
  64559. */
  64560. markAsFresnelDirty(): void;
  64561. /**
  64562. * Marks the misc state as changed
  64563. */
  64564. markAsMiscDirty(): void;
  64565. /**
  64566. * Rebuilds the material defines
  64567. */
  64568. rebuild(): void;
  64569. /**
  64570. * Specifies if two material defines are equal
  64571. * @param other - A material define instance to compare to
  64572. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  64573. */
  64574. isEqual(other: MaterialDefines): boolean;
  64575. /**
  64576. * Clones this instance's defines to another instance
  64577. * @param other - material defines to clone values to
  64578. */
  64579. cloneTo(other: MaterialDefines): void;
  64580. /**
  64581. * Resets the material define values
  64582. */
  64583. reset(): void;
  64584. /**
  64585. * Converts the material define values to a string
  64586. * @returns - String of material define information
  64587. */
  64588. toString(): string;
  64589. }
  64590. }
  64591. declare module BABYLON {
  64592. /**
  64593. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  64594. */
  64595. export class PerformanceMonitor {
  64596. private _enabled;
  64597. private _rollingFrameTime;
  64598. private _lastFrameTimeMs;
  64599. /**
  64600. * constructor
  64601. * @param frameSampleSize The number of samples required to saturate the sliding window
  64602. */
  64603. constructor(frameSampleSize?: number);
  64604. /**
  64605. * Samples current frame
  64606. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  64607. */
  64608. sampleFrame(timeMs?: number): void;
  64609. /**
  64610. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  64611. */
  64612. readonly averageFrameTime: number;
  64613. /**
  64614. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  64615. */
  64616. readonly averageFrameTimeVariance: number;
  64617. /**
  64618. * Returns the frame time of the most recent frame
  64619. */
  64620. readonly instantaneousFrameTime: number;
  64621. /**
  64622. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  64623. */
  64624. readonly averageFPS: number;
  64625. /**
  64626. * Returns the average framerate in frames per second using the most recent frame time
  64627. */
  64628. readonly instantaneousFPS: number;
  64629. /**
  64630. * Returns true if enough samples have been taken to completely fill the sliding window
  64631. */
  64632. readonly isSaturated: boolean;
  64633. /**
  64634. * Enables contributions to the sliding window sample set
  64635. */
  64636. enable(): void;
  64637. /**
  64638. * Disables contributions to the sliding window sample set
  64639. * Samples will not be interpolated over the disabled period
  64640. */
  64641. disable(): void;
  64642. /**
  64643. * Returns true if sampling is enabled
  64644. */
  64645. readonly isEnabled: boolean;
  64646. /**
  64647. * Resets performance monitor
  64648. */
  64649. reset(): void;
  64650. }
  64651. /**
  64652. * RollingAverage
  64653. *
  64654. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  64655. */
  64656. export class RollingAverage {
  64657. /**
  64658. * Current average
  64659. */
  64660. average: number;
  64661. /**
  64662. * Current variance
  64663. */
  64664. variance: number;
  64665. protected _samples: Array<number>;
  64666. protected _sampleCount: number;
  64667. protected _pos: number;
  64668. protected _m2: number;
  64669. /**
  64670. * constructor
  64671. * @param length The number of samples required to saturate the sliding window
  64672. */
  64673. constructor(length: number);
  64674. /**
  64675. * Adds a sample to the sample set
  64676. * @param v The sample value
  64677. */
  64678. add(v: number): void;
  64679. /**
  64680. * Returns previously added values or null if outside of history or outside the sliding window domain
  64681. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  64682. * @return Value previously recorded with add() or null if outside of range
  64683. */
  64684. history(i: number): number;
  64685. /**
  64686. * Returns true if enough samples have been taken to completely fill the sliding window
  64687. * @return true if sample-set saturated
  64688. */
  64689. isSaturated(): boolean;
  64690. /**
  64691. * Resets the rolling average (equivalent to 0 samples taken so far)
  64692. */
  64693. reset(): void;
  64694. /**
  64695. * Wraps a value around the sample range boundaries
  64696. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  64697. * @return Wrapped position in sample range
  64698. */
  64699. protected _wrapPosition(i: number): number;
  64700. }
  64701. }
  64702. declare module BABYLON {
  64703. /**
  64704. * This class implement a typical dictionary using a string as key and the generic type T as value.
  64705. * The underlying implementation relies on an associative array to ensure the best performances.
  64706. * The value can be anything including 'null' but except 'undefined'
  64707. */
  64708. export class StringDictionary<T> {
  64709. /**
  64710. * This will clear this dictionary and copy the content from the 'source' one.
  64711. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  64712. * @param source the dictionary to take the content from and copy to this dictionary
  64713. */
  64714. copyFrom(source: StringDictionary<T>): void;
  64715. /**
  64716. * Get a value based from its key
  64717. * @param key the given key to get the matching value from
  64718. * @return the value if found, otherwise undefined is returned
  64719. */
  64720. get(key: string): T | undefined;
  64721. /**
  64722. * Get a value from its key or add it if it doesn't exist.
  64723. * This method will ensure you that a given key/data will be present in the dictionary.
  64724. * @param key the given key to get the matching value from
  64725. * @param factory the factory that will create the value if the key is not present in the dictionary.
  64726. * The factory will only be invoked if there's no data for the given key.
  64727. * @return the value corresponding to the key.
  64728. */
  64729. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  64730. /**
  64731. * Get a value from its key if present in the dictionary otherwise add it
  64732. * @param key the key to get the value from
  64733. * @param val if there's no such key/value pair in the dictionary add it with this value
  64734. * @return the value corresponding to the key
  64735. */
  64736. getOrAdd(key: string, val: T): T;
  64737. /**
  64738. * Check if there's a given key in the dictionary
  64739. * @param key the key to check for
  64740. * @return true if the key is present, false otherwise
  64741. */
  64742. contains(key: string): boolean;
  64743. /**
  64744. * Add a new key and its corresponding value
  64745. * @param key the key to add
  64746. * @param value the value corresponding to the key
  64747. * @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
  64748. */
  64749. add(key: string, value: T): boolean;
  64750. /**
  64751. * Update a specific value associated to a key
  64752. * @param key defines the key to use
  64753. * @param value defines the value to store
  64754. * @returns true if the value was updated (or false if the key was not found)
  64755. */
  64756. set(key: string, value: T): boolean;
  64757. /**
  64758. * Get the element of the given key and remove it from the dictionary
  64759. * @param key defines the key to search
  64760. * @returns the value associated with the key or null if not found
  64761. */
  64762. getAndRemove(key: string): Nullable<T>;
  64763. /**
  64764. * Remove a key/value from the dictionary.
  64765. * @param key the key to remove
  64766. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  64767. */
  64768. remove(key: string): boolean;
  64769. /**
  64770. * Clear the whole content of the dictionary
  64771. */
  64772. clear(): void;
  64773. /**
  64774. * Gets the current count
  64775. */
  64776. readonly count: number;
  64777. /**
  64778. * Execute a callback on each key/val of the dictionary.
  64779. * Note that you can remove any element in this dictionary in the callback implementation
  64780. * @param callback the callback to execute on a given key/value pair
  64781. */
  64782. forEach(callback: (key: string, val: T) => void): void;
  64783. /**
  64784. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  64785. * If the callback returns null or undefined the method will iterate to the next key/value pair
  64786. * Note that you can remove any element in this dictionary in the callback implementation
  64787. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  64788. * @returns the first item
  64789. */
  64790. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  64791. private _count;
  64792. private _data;
  64793. }
  64794. }
  64795. declare module BABYLON {
  64796. /**
  64797. * Helper class that provides a small promise polyfill
  64798. */
  64799. export class PromisePolyfill {
  64800. /**
  64801. * Static function used to check if the polyfill is required
  64802. * If this is the case then the function will inject the polyfill to window.Promise
  64803. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  64804. */
  64805. static Apply(force?: boolean): void;
  64806. }
  64807. }
  64808. declare module BABYLON {
  64809. /**
  64810. * Class used to store data that will be store in GPU memory
  64811. */
  64812. export class Buffer {
  64813. private _engine;
  64814. private _buffer;
  64815. /** @hidden */
  64816. _data: Nullable<DataArray>;
  64817. private _updatable;
  64818. private _instanced;
  64819. /**
  64820. * Gets the byte stride.
  64821. */
  64822. readonly byteStride: number;
  64823. /**
  64824. * Constructor
  64825. * @param engine the engine
  64826. * @param data the data to use for this buffer
  64827. * @param updatable whether the data is updatable
  64828. * @param stride the stride (optional)
  64829. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  64830. * @param instanced whether the buffer is instanced (optional)
  64831. * @param useBytes set to true if the stride in in bytes (optional)
  64832. */
  64833. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  64834. /**
  64835. * Create a new VertexBuffer based on the current buffer
  64836. * @param kind defines the vertex buffer kind (position, normal, etc.)
  64837. * @param offset defines offset in the buffer (0 by default)
  64838. * @param size defines the size in floats of attributes (position is 3 for instance)
  64839. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  64840. * @param instanced defines if the vertex buffer contains indexed data
  64841. * @param useBytes defines if the offset and stride are in bytes
  64842. * @returns the new vertex buffer
  64843. */
  64844. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  64845. /**
  64846. * Gets a boolean indicating if the Buffer is updatable?
  64847. * @returns true if the buffer is updatable
  64848. */
  64849. isUpdatable(): boolean;
  64850. /**
  64851. * Gets current buffer's data
  64852. * @returns a DataArray or null
  64853. */
  64854. getData(): Nullable<DataArray>;
  64855. /**
  64856. * Gets underlying native buffer
  64857. * @returns underlying native buffer
  64858. */
  64859. getBuffer(): Nullable<WebGLBuffer>;
  64860. /**
  64861. * Gets the stride in float32 units (i.e. byte stride / 4).
  64862. * May not be an integer if the byte stride is not divisible by 4.
  64863. * DEPRECATED. Use byteStride instead.
  64864. * @returns the stride in float32 units
  64865. */
  64866. getStrideSize(): number;
  64867. /**
  64868. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  64869. * @param data defines the data to store
  64870. */
  64871. create(data?: Nullable<DataArray>): void;
  64872. /** @hidden */
  64873. _rebuild(): void;
  64874. /**
  64875. * Update current buffer data
  64876. * @param data defines the data to store
  64877. */
  64878. update(data: DataArray): void;
  64879. /**
  64880. * Updates the data directly.
  64881. * @param data the new data
  64882. * @param offset the new offset
  64883. * @param vertexCount the vertex count (optional)
  64884. * @param useBytes set to true if the offset is in bytes
  64885. */
  64886. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  64887. /**
  64888. * Release all resources
  64889. */
  64890. dispose(): void;
  64891. }
  64892. /**
  64893. * Specialized buffer used to store vertex data
  64894. */
  64895. export class VertexBuffer {
  64896. /** @hidden */
  64897. _buffer: Buffer;
  64898. private _kind;
  64899. private _size;
  64900. private _ownsBuffer;
  64901. private _instanced;
  64902. private _instanceDivisor;
  64903. /**
  64904. * The byte type.
  64905. */
  64906. static readonly BYTE: number;
  64907. /**
  64908. * The unsigned byte type.
  64909. */
  64910. static readonly UNSIGNED_BYTE: number;
  64911. /**
  64912. * The short type.
  64913. */
  64914. static readonly SHORT: number;
  64915. /**
  64916. * The unsigned short type.
  64917. */
  64918. static readonly UNSIGNED_SHORT: number;
  64919. /**
  64920. * The integer type.
  64921. */
  64922. static readonly INT: number;
  64923. /**
  64924. * The unsigned integer type.
  64925. */
  64926. static readonly UNSIGNED_INT: number;
  64927. /**
  64928. * The float type.
  64929. */
  64930. static readonly FLOAT: number;
  64931. /**
  64932. * Gets or sets the instance divisor when in instanced mode
  64933. */
  64934. instanceDivisor: number;
  64935. /**
  64936. * Gets the byte stride.
  64937. */
  64938. readonly byteStride: number;
  64939. /**
  64940. * Gets the byte offset.
  64941. */
  64942. readonly byteOffset: number;
  64943. /**
  64944. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  64945. */
  64946. readonly normalized: boolean;
  64947. /**
  64948. * Gets the data type of each component in the array.
  64949. */
  64950. readonly type: number;
  64951. /**
  64952. * Constructor
  64953. * @param engine the engine
  64954. * @param data the data to use for this vertex buffer
  64955. * @param kind the vertex buffer kind
  64956. * @param updatable whether the data is updatable
  64957. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  64958. * @param stride the stride (optional)
  64959. * @param instanced whether the buffer is instanced (optional)
  64960. * @param offset the offset of the data (optional)
  64961. * @param size the number of components (optional)
  64962. * @param type the type of the component (optional)
  64963. * @param normalized whether the data contains normalized data (optional)
  64964. * @param useBytes set to true if stride and offset are in bytes (optional)
  64965. */
  64966. 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);
  64967. /** @hidden */
  64968. _rebuild(): void;
  64969. /**
  64970. * Returns the kind of the VertexBuffer (string)
  64971. * @returns a string
  64972. */
  64973. getKind(): string;
  64974. /**
  64975. * Gets a boolean indicating if the VertexBuffer is updatable?
  64976. * @returns true if the buffer is updatable
  64977. */
  64978. isUpdatable(): boolean;
  64979. /**
  64980. * Gets current buffer's data
  64981. * @returns a DataArray or null
  64982. */
  64983. getData(): Nullable<DataArray>;
  64984. /**
  64985. * Gets underlying native buffer
  64986. * @returns underlying native buffer
  64987. */
  64988. getBuffer(): Nullable<WebGLBuffer>;
  64989. /**
  64990. * Gets the stride in float32 units (i.e. byte stride / 4).
  64991. * May not be an integer if the byte stride is not divisible by 4.
  64992. * DEPRECATED. Use byteStride instead.
  64993. * @returns the stride in float32 units
  64994. */
  64995. getStrideSize(): number;
  64996. /**
  64997. * Returns the offset as a multiple of the type byte length.
  64998. * DEPRECATED. Use byteOffset instead.
  64999. * @returns the offset in bytes
  65000. */
  65001. getOffset(): number;
  65002. /**
  65003. * Returns the number of components per vertex attribute (integer)
  65004. * @returns the size in float
  65005. */
  65006. getSize(): number;
  65007. /**
  65008. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  65009. * @returns true if this buffer is instanced
  65010. */
  65011. getIsInstanced(): boolean;
  65012. /**
  65013. * Returns the instancing divisor, zero for non-instanced (integer).
  65014. * @returns a number
  65015. */
  65016. getInstanceDivisor(): number;
  65017. /**
  65018. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  65019. * @param data defines the data to store
  65020. */
  65021. create(data?: DataArray): void;
  65022. /**
  65023. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  65024. * This function will create a new buffer if the current one is not updatable
  65025. * @param data defines the data to store
  65026. */
  65027. update(data: DataArray): void;
  65028. /**
  65029. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  65030. * Returns the directly updated WebGLBuffer.
  65031. * @param data the new data
  65032. * @param offset the new offset
  65033. * @param useBytes set to true if the offset is in bytes
  65034. */
  65035. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  65036. /**
  65037. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  65038. */
  65039. dispose(): void;
  65040. /**
  65041. * Enumerates each value of this vertex buffer as numbers.
  65042. * @param count the number of values to enumerate
  65043. * @param callback the callback function called for each value
  65044. */
  65045. forEach(count: number, callback: (value: number, index: number) => void): void;
  65046. /**
  65047. * Positions
  65048. */
  65049. static readonly PositionKind: string;
  65050. /**
  65051. * Normals
  65052. */
  65053. static readonly NormalKind: string;
  65054. /**
  65055. * Tangents
  65056. */
  65057. static readonly TangentKind: string;
  65058. /**
  65059. * Texture coordinates
  65060. */
  65061. static readonly UVKind: string;
  65062. /**
  65063. * Texture coordinates 2
  65064. */
  65065. static readonly UV2Kind: string;
  65066. /**
  65067. * Texture coordinates 3
  65068. */
  65069. static readonly UV3Kind: string;
  65070. /**
  65071. * Texture coordinates 4
  65072. */
  65073. static readonly UV4Kind: string;
  65074. /**
  65075. * Texture coordinates 5
  65076. */
  65077. static readonly UV5Kind: string;
  65078. /**
  65079. * Texture coordinates 6
  65080. */
  65081. static readonly UV6Kind: string;
  65082. /**
  65083. * Colors
  65084. */
  65085. static readonly ColorKind: string;
  65086. /**
  65087. * Matrix indices (for bones)
  65088. */
  65089. static readonly MatricesIndicesKind: string;
  65090. /**
  65091. * Matrix weights (for bones)
  65092. */
  65093. static readonly MatricesWeightsKind: string;
  65094. /**
  65095. * Additional matrix indices (for bones)
  65096. */
  65097. static readonly MatricesIndicesExtraKind: string;
  65098. /**
  65099. * Additional matrix weights (for bones)
  65100. */
  65101. static readonly MatricesWeightsExtraKind: string;
  65102. /**
  65103. * Deduces the stride given a kind.
  65104. * @param kind The kind string to deduce
  65105. * @returns The deduced stride
  65106. */
  65107. static DeduceStride(kind: string): number;
  65108. /**
  65109. * Gets the byte length of the given type.
  65110. * @param type the type
  65111. * @returns the number of bytes
  65112. */
  65113. static GetTypeByteLength(type: number): number;
  65114. /**
  65115. * Enumerates each value of the given parameters as numbers.
  65116. * @param data the data to enumerate
  65117. * @param byteOffset the byte offset of the data
  65118. * @param byteStride the byte stride of the data
  65119. * @param componentCount the number of components per element
  65120. * @param componentType the type of the component
  65121. * @param count the total number of components
  65122. * @param normalized whether the data is normalized
  65123. * @param callback the callback function called for each value
  65124. */
  65125. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  65126. private static _GetFloatValue;
  65127. }
  65128. }
  65129. declare module BABYLON {
  65130. /**
  65131. * Class representing spherical polynomial coefficients to the 3rd degree
  65132. */
  65133. export class SphericalPolynomial {
  65134. /**
  65135. * The x coefficients of the spherical polynomial
  65136. */
  65137. x: Vector3;
  65138. /**
  65139. * The y coefficients of the spherical polynomial
  65140. */
  65141. y: Vector3;
  65142. /**
  65143. * The z coefficients of the spherical polynomial
  65144. */
  65145. z: Vector3;
  65146. /**
  65147. * The xx coefficients of the spherical polynomial
  65148. */
  65149. xx: Vector3;
  65150. /**
  65151. * The yy coefficients of the spherical polynomial
  65152. */
  65153. yy: Vector3;
  65154. /**
  65155. * The zz coefficients of the spherical polynomial
  65156. */
  65157. zz: Vector3;
  65158. /**
  65159. * The xy coefficients of the spherical polynomial
  65160. */
  65161. xy: Vector3;
  65162. /**
  65163. * The yz coefficients of the spherical polynomial
  65164. */
  65165. yz: Vector3;
  65166. /**
  65167. * The zx coefficients of the spherical polynomial
  65168. */
  65169. zx: Vector3;
  65170. /**
  65171. * Adds an ambient color to the spherical polynomial
  65172. * @param color the color to add
  65173. */
  65174. addAmbient(color: Color3): void;
  65175. /**
  65176. * Scales the spherical polynomial by the given amount
  65177. * @param scale the amount to scale
  65178. */
  65179. scale(scale: number): void;
  65180. /**
  65181. * Gets the spherical polynomial from harmonics
  65182. * @param harmonics the spherical harmonics
  65183. * @returns the spherical polynomial
  65184. */
  65185. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  65186. /**
  65187. * Constructs a spherical polynomial from an array.
  65188. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  65189. * @returns the spherical polynomial
  65190. */
  65191. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  65192. }
  65193. /**
  65194. * Class representing spherical harmonics coefficients to the 3rd degree
  65195. */
  65196. export class SphericalHarmonics {
  65197. /**
  65198. * The l0,0 coefficients of the spherical harmonics
  65199. */
  65200. l00: Vector3;
  65201. /**
  65202. * The l1,-1 coefficients of the spherical harmonics
  65203. */
  65204. l1_1: Vector3;
  65205. /**
  65206. * The l1,0 coefficients of the spherical harmonics
  65207. */
  65208. l10: Vector3;
  65209. /**
  65210. * The l1,1 coefficients of the spherical harmonics
  65211. */
  65212. l11: Vector3;
  65213. /**
  65214. * The l2,-2 coefficients of the spherical harmonics
  65215. */
  65216. l2_2: Vector3;
  65217. /**
  65218. * The l2,-1 coefficients of the spherical harmonics
  65219. */
  65220. l2_1: Vector3;
  65221. /**
  65222. * The l2,0 coefficients of the spherical harmonics
  65223. */
  65224. l20: Vector3;
  65225. /**
  65226. * The l2,1 coefficients of the spherical harmonics
  65227. */
  65228. l21: Vector3;
  65229. /**
  65230. * The l2,2 coefficients of the spherical harmonics
  65231. */
  65232. lL22: Vector3;
  65233. /**
  65234. * Adds a light to the spherical harmonics
  65235. * @param direction the direction of the light
  65236. * @param color the color of the light
  65237. * @param deltaSolidAngle the delta solid angle of the light
  65238. */
  65239. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  65240. /**
  65241. * Scales the spherical harmonics by the given amount
  65242. * @param scale the amount to scale
  65243. */
  65244. scale(scale: number): void;
  65245. /**
  65246. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  65247. *
  65248. * ```
  65249. * E_lm = A_l * L_lm
  65250. * ```
  65251. *
  65252. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  65253. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  65254. * the scaling factors are given in equation 9.
  65255. */
  65256. convertIncidentRadianceToIrradiance(): void;
  65257. /**
  65258. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  65259. *
  65260. * ```
  65261. * L = (1/pi) * E * rho
  65262. * ```
  65263. *
  65264. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  65265. */
  65266. convertIrradianceToLambertianRadiance(): void;
  65267. /**
  65268. * Gets the spherical harmonics from polynomial
  65269. * @param polynomial the spherical polynomial
  65270. * @returns the spherical harmonics
  65271. */
  65272. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  65273. /**
  65274. * Constructs a spherical harmonics from an array.
  65275. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  65276. * @returns the spherical harmonics
  65277. */
  65278. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  65279. }
  65280. }
  65281. declare module BABYLON {
  65282. /**
  65283. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  65284. */
  65285. export interface CubeMapInfo {
  65286. /**
  65287. * The pixel array for the front face.
  65288. * This is stored in format, left to right, up to down format.
  65289. */
  65290. front: Nullable<ArrayBufferView>;
  65291. /**
  65292. * The pixel array for the back face.
  65293. * This is stored in format, left to right, up to down format.
  65294. */
  65295. back: Nullable<ArrayBufferView>;
  65296. /**
  65297. * The pixel array for the left face.
  65298. * This is stored in format, left to right, up to down format.
  65299. */
  65300. left: Nullable<ArrayBufferView>;
  65301. /**
  65302. * The pixel array for the right face.
  65303. * This is stored in format, left to right, up to down format.
  65304. */
  65305. right: Nullable<ArrayBufferView>;
  65306. /**
  65307. * The pixel array for the up face.
  65308. * This is stored in format, left to right, up to down format.
  65309. */
  65310. up: Nullable<ArrayBufferView>;
  65311. /**
  65312. * The pixel array for the down face.
  65313. * This is stored in format, left to right, up to down format.
  65314. */
  65315. down: Nullable<ArrayBufferView>;
  65316. /**
  65317. * The size of the cubemap stored.
  65318. *
  65319. * Each faces will be size * size pixels.
  65320. */
  65321. size: number;
  65322. /**
  65323. * The format of the texture.
  65324. *
  65325. * RGBA, RGB.
  65326. */
  65327. format: number;
  65328. /**
  65329. * The type of the texture data.
  65330. *
  65331. * UNSIGNED_INT, FLOAT.
  65332. */
  65333. type: number;
  65334. /**
  65335. * Specifies whether the texture is in gamma space.
  65336. */
  65337. gammaSpace: boolean;
  65338. }
  65339. /**
  65340. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  65341. */
  65342. export class PanoramaToCubeMapTools {
  65343. private static FACE_FRONT;
  65344. private static FACE_BACK;
  65345. private static FACE_RIGHT;
  65346. private static FACE_LEFT;
  65347. private static FACE_DOWN;
  65348. private static FACE_UP;
  65349. /**
  65350. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  65351. *
  65352. * @param float32Array The source data.
  65353. * @param inputWidth The width of the input panorama.
  65354. * @param inputHeight The height of the input panorama.
  65355. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  65356. * @return The cubemap data
  65357. */
  65358. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  65359. private static CreateCubemapTexture;
  65360. private static CalcProjectionSpherical;
  65361. }
  65362. }
  65363. declare module BABYLON {
  65364. /**
  65365. * Helper class dealing with the extraction of spherical polynomial dataArray
  65366. * from a cube map.
  65367. */
  65368. export class CubeMapToSphericalPolynomialTools {
  65369. private static FileFaces;
  65370. /**
  65371. * Converts a texture to the according Spherical Polynomial data.
  65372. * This extracts the first 3 orders only as they are the only one used in the lighting.
  65373. *
  65374. * @param texture The texture to extract the information from.
  65375. * @return The Spherical Polynomial data.
  65376. */
  65377. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): SphericalPolynomial | null;
  65378. /**
  65379. * Converts a cubemap to the according Spherical Polynomial data.
  65380. * This extracts the first 3 orders only as they are the only one used in the lighting.
  65381. *
  65382. * @param cubeInfo The Cube map to extract the information from.
  65383. * @return The Spherical Polynomial data.
  65384. */
  65385. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  65386. }
  65387. }
  65388. declare module BABYLON {
  65389. /**
  65390. * The engine store class is responsible to hold all the instances of Engine and Scene created
  65391. * during the life time of the application.
  65392. */
  65393. export class EngineStore {
  65394. /** Gets the list of created engines */
  65395. static Instances: Engine[];
  65396. /**
  65397. * Gets the latest created engine
  65398. */
  65399. static readonly LastCreatedEngine: Nullable<Engine>;
  65400. /**
  65401. * Gets the latest created scene
  65402. */
  65403. static readonly LastCreatedScene: Nullable<Scene>;
  65404. }
  65405. }
  65406. declare module BABYLON {
  65407. /**
  65408. * Define options used to create a render target texture
  65409. */
  65410. export class RenderTargetCreationOptions {
  65411. /**
  65412. * Specifies is mipmaps must be generated
  65413. */
  65414. generateMipMaps?: boolean;
  65415. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  65416. generateDepthBuffer?: boolean;
  65417. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  65418. generateStencilBuffer?: boolean;
  65419. /** Defines texture type (int by default) */
  65420. type?: number;
  65421. /** Defines sampling mode (trilinear by default) */
  65422. samplingMode?: number;
  65423. /** Defines format (RGBA by default) */
  65424. format?: number;
  65425. }
  65426. }
  65427. declare module BABYLON {
  65428. /**
  65429. * @hidden
  65430. **/
  65431. export class _AlphaState {
  65432. private _isAlphaBlendDirty;
  65433. private _isBlendFunctionParametersDirty;
  65434. private _isBlendEquationParametersDirty;
  65435. private _isBlendConstantsDirty;
  65436. private _alphaBlend;
  65437. private _blendFunctionParameters;
  65438. private _blendEquationParameters;
  65439. private _blendConstants;
  65440. /**
  65441. * Initializes the state.
  65442. */
  65443. constructor();
  65444. readonly isDirty: boolean;
  65445. alphaBlend: boolean;
  65446. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  65447. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  65448. setAlphaEquationParameters(rgb: number, alpha: number): void;
  65449. reset(): void;
  65450. apply(gl: WebGLRenderingContext): void;
  65451. }
  65452. }
  65453. declare module BABYLON {
  65454. /**
  65455. * @hidden
  65456. **/
  65457. export class _DepthCullingState {
  65458. private _isDepthTestDirty;
  65459. private _isDepthMaskDirty;
  65460. private _isDepthFuncDirty;
  65461. private _isCullFaceDirty;
  65462. private _isCullDirty;
  65463. private _isZOffsetDirty;
  65464. private _isFrontFaceDirty;
  65465. private _depthTest;
  65466. private _depthMask;
  65467. private _depthFunc;
  65468. private _cull;
  65469. private _cullFace;
  65470. private _zOffset;
  65471. private _frontFace;
  65472. /**
  65473. * Initializes the state.
  65474. */
  65475. constructor();
  65476. readonly isDirty: boolean;
  65477. zOffset: number;
  65478. cullFace: Nullable<number>;
  65479. cull: Nullable<boolean>;
  65480. depthFunc: Nullable<number>;
  65481. depthMask: boolean;
  65482. depthTest: boolean;
  65483. frontFace: Nullable<number>;
  65484. reset(): void;
  65485. apply(gl: WebGLRenderingContext): void;
  65486. }
  65487. }
  65488. declare module BABYLON {
  65489. /**
  65490. * @hidden
  65491. **/
  65492. export class _StencilState {
  65493. /** 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 */
  65494. static readonly ALWAYS: number;
  65495. /** Passed to stencilOperation to specify that stencil value must be kept */
  65496. static readonly KEEP: number;
  65497. /** Passed to stencilOperation to specify that stencil value must be replaced */
  65498. static readonly REPLACE: number;
  65499. private _isStencilTestDirty;
  65500. private _isStencilMaskDirty;
  65501. private _isStencilFuncDirty;
  65502. private _isStencilOpDirty;
  65503. private _stencilTest;
  65504. private _stencilMask;
  65505. private _stencilFunc;
  65506. private _stencilFuncRef;
  65507. private _stencilFuncMask;
  65508. private _stencilOpStencilFail;
  65509. private _stencilOpDepthFail;
  65510. private _stencilOpStencilDepthPass;
  65511. readonly isDirty: boolean;
  65512. stencilFunc: number;
  65513. stencilFuncRef: number;
  65514. stencilFuncMask: number;
  65515. stencilOpStencilFail: number;
  65516. stencilOpDepthFail: number;
  65517. stencilOpStencilDepthPass: number;
  65518. stencilMask: number;
  65519. stencilTest: boolean;
  65520. constructor();
  65521. reset(): void;
  65522. apply(gl: WebGLRenderingContext): void;
  65523. }
  65524. }
  65525. declare module BABYLON {
  65526. /**
  65527. * @hidden
  65528. **/
  65529. export class _TimeToken {
  65530. _startTimeQuery: Nullable<WebGLQuery>;
  65531. _endTimeQuery: Nullable<WebGLQuery>;
  65532. _timeElapsedQuery: Nullable<WebGLQuery>;
  65533. _timeElapsedQueryEnded: boolean;
  65534. }
  65535. }
  65536. declare module BABYLON {
  65537. /**
  65538. * Class used to store data associated with WebGL texture data for the engine
  65539. * This class should not be used directly
  65540. */
  65541. export class InternalTexture {
  65542. /** hidden */
  65543. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: SphericalPolynomial | null, lodScale: number, lodOffset: number) => Promise<void>;
  65544. /**
  65545. * The source of the texture data is unknown
  65546. */
  65547. static DATASOURCE_UNKNOWN: number;
  65548. /**
  65549. * Texture data comes from an URL
  65550. */
  65551. static DATASOURCE_URL: number;
  65552. /**
  65553. * Texture data is only used for temporary storage
  65554. */
  65555. static DATASOURCE_TEMP: number;
  65556. /**
  65557. * Texture data comes from raw data (ArrayBuffer)
  65558. */
  65559. static DATASOURCE_RAW: number;
  65560. /**
  65561. * Texture content is dynamic (video or dynamic texture)
  65562. */
  65563. static DATASOURCE_DYNAMIC: number;
  65564. /**
  65565. * Texture content is generated by rendering to it
  65566. */
  65567. static DATASOURCE_RENDERTARGET: number;
  65568. /**
  65569. * Texture content is part of a multi render target process
  65570. */
  65571. static DATASOURCE_MULTIRENDERTARGET: number;
  65572. /**
  65573. * Texture data comes from a cube data file
  65574. */
  65575. static DATASOURCE_CUBE: number;
  65576. /**
  65577. * Texture data comes from a raw cube data
  65578. */
  65579. static DATASOURCE_CUBERAW: number;
  65580. /**
  65581. * Texture data come from a prefiltered cube data file
  65582. */
  65583. static DATASOURCE_CUBEPREFILTERED: number;
  65584. /**
  65585. * Texture content is raw 3D data
  65586. */
  65587. static DATASOURCE_RAW3D: number;
  65588. /**
  65589. * Texture content is a depth texture
  65590. */
  65591. static DATASOURCE_DEPTHTEXTURE: number;
  65592. /**
  65593. * Texture data comes from a raw cube data encoded with RGBD
  65594. */
  65595. static DATASOURCE_CUBERAW_RGBD: number;
  65596. /**
  65597. * Defines if the texture is ready
  65598. */
  65599. isReady: boolean;
  65600. /**
  65601. * Defines if the texture is a cube texture
  65602. */
  65603. isCube: boolean;
  65604. /**
  65605. * Defines if the texture contains 3D data
  65606. */
  65607. is3D: boolean;
  65608. /**
  65609. * Defines if the texture contains multiview data
  65610. */
  65611. isMultiview: boolean;
  65612. /**
  65613. * Gets the URL used to load this texture
  65614. */
  65615. url: string;
  65616. /**
  65617. * Gets the sampling mode of the texture
  65618. */
  65619. samplingMode: number;
  65620. /**
  65621. * Gets a boolean indicating if the texture needs mipmaps generation
  65622. */
  65623. generateMipMaps: boolean;
  65624. /**
  65625. * Gets the number of samples used by the texture (WebGL2+ only)
  65626. */
  65627. samples: number;
  65628. /**
  65629. * Gets the type of the texture (int, float...)
  65630. */
  65631. type: number;
  65632. /**
  65633. * Gets the format of the texture (RGB, RGBA...)
  65634. */
  65635. format: number;
  65636. /**
  65637. * Observable called when the texture is loaded
  65638. */
  65639. onLoadedObservable: Observable<InternalTexture>;
  65640. /**
  65641. * Gets the width of the texture
  65642. */
  65643. width: number;
  65644. /**
  65645. * Gets the height of the texture
  65646. */
  65647. height: number;
  65648. /**
  65649. * Gets the depth of the texture
  65650. */
  65651. depth: number;
  65652. /**
  65653. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  65654. */
  65655. baseWidth: number;
  65656. /**
  65657. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  65658. */
  65659. baseHeight: number;
  65660. /**
  65661. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  65662. */
  65663. baseDepth: number;
  65664. /**
  65665. * Gets a boolean indicating if the texture is inverted on Y axis
  65666. */
  65667. invertY: boolean;
  65668. /** @hidden */
  65669. _invertVScale: boolean;
  65670. /** @hidden */
  65671. _associatedChannel: number;
  65672. /** @hidden */
  65673. _dataSource: number;
  65674. /** @hidden */
  65675. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  65676. /** @hidden */
  65677. _bufferView: Nullable<ArrayBufferView>;
  65678. /** @hidden */
  65679. _bufferViewArray: Nullable<ArrayBufferView[]>;
  65680. /** @hidden */
  65681. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  65682. /** @hidden */
  65683. _size: number;
  65684. /** @hidden */
  65685. _extension: string;
  65686. /** @hidden */
  65687. _files: Nullable<string[]>;
  65688. /** @hidden */
  65689. _workingCanvas: HTMLCanvasElement;
  65690. /** @hidden */
  65691. _workingContext: CanvasRenderingContext2D;
  65692. /** @hidden */
  65693. _framebuffer: Nullable<WebGLFramebuffer>;
  65694. /** @hidden */
  65695. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  65696. /** @hidden */
  65697. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  65698. /** @hidden */
  65699. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  65700. /** @hidden */
  65701. _attachments: Nullable<number[]>;
  65702. /** @hidden */
  65703. _cachedCoordinatesMode: Nullable<number>;
  65704. /** @hidden */
  65705. _cachedWrapU: Nullable<number>;
  65706. /** @hidden */
  65707. _cachedWrapV: Nullable<number>;
  65708. /** @hidden */
  65709. _cachedWrapR: Nullable<number>;
  65710. /** @hidden */
  65711. _cachedAnisotropicFilteringLevel: Nullable<number>;
  65712. /** @hidden */
  65713. _isDisabled: boolean;
  65714. /** @hidden */
  65715. _compression: Nullable<string>;
  65716. /** @hidden */
  65717. _generateStencilBuffer: boolean;
  65718. /** @hidden */
  65719. _generateDepthBuffer: boolean;
  65720. /** @hidden */
  65721. _comparisonFunction: number;
  65722. /** @hidden */
  65723. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  65724. /** @hidden */
  65725. _lodGenerationScale: number;
  65726. /** @hidden */
  65727. _lodGenerationOffset: number;
  65728. /** @hidden */
  65729. _colorTextureArray: Nullable<WebGLTexture>;
  65730. /** @hidden */
  65731. _depthStencilTextureArray: Nullable<WebGLTexture>;
  65732. /** @hidden */
  65733. _lodTextureHigh: BaseTexture;
  65734. /** @hidden */
  65735. _lodTextureMid: BaseTexture;
  65736. /** @hidden */
  65737. _lodTextureLow: BaseTexture;
  65738. /** @hidden */
  65739. _isRGBD: boolean;
  65740. /** @hidden */
  65741. _webGLTexture: Nullable<WebGLTexture>;
  65742. /** @hidden */
  65743. _references: number;
  65744. private _engine;
  65745. /**
  65746. * Gets the Engine the texture belongs to.
  65747. * @returns The babylon engine
  65748. */
  65749. getEngine(): Engine;
  65750. /**
  65751. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  65752. */
  65753. readonly dataSource: number;
  65754. /**
  65755. * Creates a new InternalTexture
  65756. * @param engine defines the engine to use
  65757. * @param dataSource defines the type of data that will be used
  65758. * @param delayAllocation if the texture allocation should be delayed (default: false)
  65759. */
  65760. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  65761. /**
  65762. * Increments the number of references (ie. the number of Texture that point to it)
  65763. */
  65764. incrementReferences(): void;
  65765. /**
  65766. * Change the size of the texture (not the size of the content)
  65767. * @param width defines the new width
  65768. * @param height defines the new height
  65769. * @param depth defines the new depth (1 by default)
  65770. */
  65771. updateSize(width: int, height: int, depth?: int): void;
  65772. /** @hidden */
  65773. _rebuild(): void;
  65774. /** @hidden */
  65775. _swapAndDie(target: InternalTexture): void;
  65776. /**
  65777. * Dispose the current allocated resources
  65778. */
  65779. dispose(): void;
  65780. }
  65781. }
  65782. declare module BABYLON {
  65783. /**
  65784. * This represents the main contract an easing function should follow.
  65785. * Easing functions are used throughout the animation system.
  65786. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  65787. */
  65788. export interface IEasingFunction {
  65789. /**
  65790. * Given an input gradient between 0 and 1, this returns the corrseponding value
  65791. * of the easing function.
  65792. * The link below provides some of the most common examples of easing functions.
  65793. * @see https://easings.net/
  65794. * @param gradient Defines the value between 0 and 1 we want the easing value for
  65795. * @returns the corresponding value on the curve defined by the easing function
  65796. */
  65797. ease(gradient: number): number;
  65798. }
  65799. /**
  65800. * Base class used for every default easing function.
  65801. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  65802. */
  65803. export class EasingFunction implements IEasingFunction {
  65804. /**
  65805. * Interpolation follows the mathematical formula associated with the easing function.
  65806. */
  65807. static readonly EASINGMODE_EASEIN: number;
  65808. /**
  65809. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  65810. */
  65811. static readonly EASINGMODE_EASEOUT: number;
  65812. /**
  65813. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  65814. */
  65815. static readonly EASINGMODE_EASEINOUT: number;
  65816. private _easingMode;
  65817. /**
  65818. * Sets the easing mode of the current function.
  65819. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  65820. */
  65821. setEasingMode(easingMode: number): void;
  65822. /**
  65823. * Gets the current easing mode.
  65824. * @returns the easing mode
  65825. */
  65826. getEasingMode(): number;
  65827. /**
  65828. * @hidden
  65829. */
  65830. easeInCore(gradient: number): number;
  65831. /**
  65832. * Given an input gradient between 0 and 1, this returns the corrseponding value
  65833. * of the easing function.
  65834. * @param gradient Defines the value between 0 and 1 we want the easing value for
  65835. * @returns the corresponding value on the curve defined by the easing function
  65836. */
  65837. ease(gradient: number): number;
  65838. }
  65839. /**
  65840. * Easing function with a circle shape (see link below).
  65841. * @see https://easings.net/#easeInCirc
  65842. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  65843. */
  65844. export class CircleEase extends EasingFunction implements IEasingFunction {
  65845. /** @hidden */
  65846. easeInCore(gradient: number): number;
  65847. }
  65848. /**
  65849. * Easing function with a ease back shape (see link below).
  65850. * @see https://easings.net/#easeInBack
  65851. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  65852. */
  65853. export class BackEase extends EasingFunction implements IEasingFunction {
  65854. /** Defines the amplitude of the function */
  65855. amplitude: number;
  65856. /**
  65857. * Instantiates a back ease easing
  65858. * @see https://easings.net/#easeInBack
  65859. * @param amplitude Defines the amplitude of the function
  65860. */
  65861. constructor(
  65862. /** Defines the amplitude of the function */
  65863. amplitude?: number);
  65864. /** @hidden */
  65865. easeInCore(gradient: number): number;
  65866. }
  65867. /**
  65868. * Easing function with a bouncing shape (see link below).
  65869. * @see https://easings.net/#easeInBounce
  65870. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  65871. */
  65872. export class BounceEase extends EasingFunction implements IEasingFunction {
  65873. /** Defines the number of bounces */
  65874. bounces: number;
  65875. /** Defines the amplitude of the bounce */
  65876. bounciness: number;
  65877. /**
  65878. * Instantiates a bounce easing
  65879. * @see https://easings.net/#easeInBounce
  65880. * @param bounces Defines the number of bounces
  65881. * @param bounciness Defines the amplitude of the bounce
  65882. */
  65883. constructor(
  65884. /** Defines the number of bounces */
  65885. bounces?: number,
  65886. /** Defines the amplitude of the bounce */
  65887. bounciness?: number);
  65888. /** @hidden */
  65889. easeInCore(gradient: number): number;
  65890. }
  65891. /**
  65892. * Easing function with a power of 3 shape (see link below).
  65893. * @see https://easings.net/#easeInCubic
  65894. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  65895. */
  65896. export class CubicEase extends EasingFunction implements IEasingFunction {
  65897. /** @hidden */
  65898. easeInCore(gradient: number): number;
  65899. }
  65900. /**
  65901. * Easing function with an elastic shape (see link below).
  65902. * @see https://easings.net/#easeInElastic
  65903. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  65904. */
  65905. export class ElasticEase extends EasingFunction implements IEasingFunction {
  65906. /** Defines the number of oscillations*/
  65907. oscillations: number;
  65908. /** Defines the amplitude of the oscillations*/
  65909. springiness: number;
  65910. /**
  65911. * Instantiates an elastic easing function
  65912. * @see https://easings.net/#easeInElastic
  65913. * @param oscillations Defines the number of oscillations
  65914. * @param springiness Defines the amplitude of the oscillations
  65915. */
  65916. constructor(
  65917. /** Defines the number of oscillations*/
  65918. oscillations?: number,
  65919. /** Defines the amplitude of the oscillations*/
  65920. springiness?: number);
  65921. /** @hidden */
  65922. easeInCore(gradient: number): number;
  65923. }
  65924. /**
  65925. * Easing function with an exponential shape (see link below).
  65926. * @see https://easings.net/#easeInExpo
  65927. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  65928. */
  65929. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  65930. /** Defines the exponent of the function */
  65931. exponent: number;
  65932. /**
  65933. * Instantiates an exponential easing function
  65934. * @see https://easings.net/#easeInExpo
  65935. * @param exponent Defines the exponent of the function
  65936. */
  65937. constructor(
  65938. /** Defines the exponent of the function */
  65939. exponent?: number);
  65940. /** @hidden */
  65941. easeInCore(gradient: number): number;
  65942. }
  65943. /**
  65944. * Easing function with a power shape (see link below).
  65945. * @see https://easings.net/#easeInQuad
  65946. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  65947. */
  65948. export class PowerEase extends EasingFunction implements IEasingFunction {
  65949. /** Defines the power of the function */
  65950. power: number;
  65951. /**
  65952. * Instantiates an power base easing function
  65953. * @see https://easings.net/#easeInQuad
  65954. * @param power Defines the power of the function
  65955. */
  65956. constructor(
  65957. /** Defines the power of the function */
  65958. power?: number);
  65959. /** @hidden */
  65960. easeInCore(gradient: number): number;
  65961. }
  65962. /**
  65963. * Easing function with a power of 2 shape (see link below).
  65964. * @see https://easings.net/#easeInQuad
  65965. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  65966. */
  65967. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  65968. /** @hidden */
  65969. easeInCore(gradient: number): number;
  65970. }
  65971. /**
  65972. * Easing function with a power of 4 shape (see link below).
  65973. * @see https://easings.net/#easeInQuart
  65974. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  65975. */
  65976. export class QuarticEase extends EasingFunction implements IEasingFunction {
  65977. /** @hidden */
  65978. easeInCore(gradient: number): number;
  65979. }
  65980. /**
  65981. * Easing function with a power of 5 shape (see link below).
  65982. * @see https://easings.net/#easeInQuint
  65983. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  65984. */
  65985. export class QuinticEase extends EasingFunction implements IEasingFunction {
  65986. /** @hidden */
  65987. easeInCore(gradient: number): number;
  65988. }
  65989. /**
  65990. * Easing function with a sin shape (see link below).
  65991. * @see https://easings.net/#easeInSine
  65992. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  65993. */
  65994. export class SineEase extends EasingFunction implements IEasingFunction {
  65995. /** @hidden */
  65996. easeInCore(gradient: number): number;
  65997. }
  65998. /**
  65999. * Easing function with a bezier shape (see link below).
  66000. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  66001. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  66002. */
  66003. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  66004. /** Defines the x component of the start tangent in the bezier curve */
  66005. x1: number;
  66006. /** Defines the y component of the start tangent in the bezier curve */
  66007. y1: number;
  66008. /** Defines the x component of the end tangent in the bezier curve */
  66009. x2: number;
  66010. /** Defines the y component of the end tangent in the bezier curve */
  66011. y2: number;
  66012. /**
  66013. * Instantiates a bezier function
  66014. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  66015. * @param x1 Defines the x component of the start tangent in the bezier curve
  66016. * @param y1 Defines the y component of the start tangent in the bezier curve
  66017. * @param x2 Defines the x component of the end tangent in the bezier curve
  66018. * @param y2 Defines the y component of the end tangent in the bezier curve
  66019. */
  66020. constructor(
  66021. /** Defines the x component of the start tangent in the bezier curve */
  66022. x1?: number,
  66023. /** Defines the y component of the start tangent in the bezier curve */
  66024. y1?: number,
  66025. /** Defines the x component of the end tangent in the bezier curve */
  66026. x2?: number,
  66027. /** Defines the y component of the end tangent in the bezier curve */
  66028. y2?: number);
  66029. /** @hidden */
  66030. easeInCore(gradient: number): number;
  66031. }
  66032. }
  66033. declare module BABYLON {
  66034. /**
  66035. * Defines an interface which represents an animation key frame
  66036. */
  66037. export interface IAnimationKey {
  66038. /**
  66039. * Frame of the key frame
  66040. */
  66041. frame: number;
  66042. /**
  66043. * Value at the specifies key frame
  66044. */
  66045. value: any;
  66046. /**
  66047. * The input tangent for the cubic hermite spline
  66048. */
  66049. inTangent?: any;
  66050. /**
  66051. * The output tangent for the cubic hermite spline
  66052. */
  66053. outTangent?: any;
  66054. /**
  66055. * The animation interpolation type
  66056. */
  66057. interpolation?: AnimationKeyInterpolation;
  66058. }
  66059. /**
  66060. * Enum for the animation key frame interpolation type
  66061. */
  66062. export enum AnimationKeyInterpolation {
  66063. /**
  66064. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  66065. */
  66066. STEP = 1
  66067. }
  66068. }
  66069. declare module BABYLON {
  66070. /**
  66071. * Represents the range of an animation
  66072. */
  66073. export class AnimationRange {
  66074. /**The name of the animation range**/
  66075. name: string;
  66076. /**The starting frame of the animation */
  66077. from: number;
  66078. /**The ending frame of the animation*/
  66079. to: number;
  66080. /**
  66081. * Initializes the range of an animation
  66082. * @param name The name of the animation range
  66083. * @param from The starting frame of the animation
  66084. * @param to The ending frame of the animation
  66085. */
  66086. constructor(
  66087. /**The name of the animation range**/
  66088. name: string,
  66089. /**The starting frame of the animation */
  66090. from: number,
  66091. /**The ending frame of the animation*/
  66092. to: number);
  66093. /**
  66094. * Makes a copy of the animation range
  66095. * @returns A copy of the animation range
  66096. */
  66097. clone(): AnimationRange;
  66098. }
  66099. }
  66100. declare module BABYLON {
  66101. /**
  66102. * Composed of a frame, and an action function
  66103. */
  66104. export class AnimationEvent {
  66105. /** The frame for which the event is triggered **/
  66106. frame: number;
  66107. /** The event to perform when triggered **/
  66108. action: (currentFrame: number) => void;
  66109. /** Specifies if the event should be triggered only once**/
  66110. onlyOnce?: boolean | undefined;
  66111. /**
  66112. * Specifies if the animation event is done
  66113. */
  66114. isDone: boolean;
  66115. /**
  66116. * Initializes the animation event
  66117. * @param frame The frame for which the event is triggered
  66118. * @param action The event to perform when triggered
  66119. * @param onlyOnce Specifies if the event should be triggered only once
  66120. */
  66121. constructor(
  66122. /** The frame for which the event is triggered **/
  66123. frame: number,
  66124. /** The event to perform when triggered **/
  66125. action: (currentFrame: number) => void,
  66126. /** Specifies if the event should be triggered only once**/
  66127. onlyOnce?: boolean | undefined);
  66128. /** @hidden */
  66129. _clone(): AnimationEvent;
  66130. }
  66131. }
  66132. declare module BABYLON {
  66133. /**
  66134. * Interface used to define a behavior
  66135. */
  66136. export interface Behavior<T> {
  66137. /** gets or sets behavior's name */
  66138. name: string;
  66139. /**
  66140. * Function called when the behavior needs to be initialized (after attaching it to a target)
  66141. */
  66142. init(): void;
  66143. /**
  66144. * Called when the behavior is attached to a target
  66145. * @param target defines the target where the behavior is attached to
  66146. */
  66147. attach(target: T): void;
  66148. /**
  66149. * Called when the behavior is detached from its target
  66150. */
  66151. detach(): void;
  66152. }
  66153. /**
  66154. * Interface implemented by classes supporting behaviors
  66155. */
  66156. export interface IBehaviorAware<T> {
  66157. /**
  66158. * Attach a behavior
  66159. * @param behavior defines the behavior to attach
  66160. * @returns the current host
  66161. */
  66162. addBehavior(behavior: Behavior<T>): T;
  66163. /**
  66164. * Remove a behavior from the current object
  66165. * @param behavior defines the behavior to detach
  66166. * @returns the current host
  66167. */
  66168. removeBehavior(behavior: Behavior<T>): T;
  66169. /**
  66170. * Gets a behavior using its name to search
  66171. * @param name defines the name to search
  66172. * @returns the behavior or null if not found
  66173. */
  66174. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  66175. }
  66176. }
  66177. declare module BABYLON {
  66178. /**
  66179. * @hidden
  66180. */
  66181. export class IntersectionInfo {
  66182. bu: Nullable<number>;
  66183. bv: Nullable<number>;
  66184. distance: number;
  66185. faceId: number;
  66186. subMeshId: number;
  66187. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  66188. }
  66189. }
  66190. declare module BABYLON {
  66191. /**
  66192. * Class used to store bounding sphere information
  66193. */
  66194. export class BoundingSphere {
  66195. /**
  66196. * Gets the center of the bounding sphere in local space
  66197. */
  66198. readonly center: Vector3;
  66199. /**
  66200. * Radius of the bounding sphere in local space
  66201. */
  66202. radius: number;
  66203. /**
  66204. * Gets the center of the bounding sphere in world space
  66205. */
  66206. readonly centerWorld: Vector3;
  66207. /**
  66208. * Radius of the bounding sphere in world space
  66209. */
  66210. radiusWorld: number;
  66211. /**
  66212. * Gets the minimum vector in local space
  66213. */
  66214. readonly minimum: Vector3;
  66215. /**
  66216. * Gets the maximum vector in local space
  66217. */
  66218. readonly maximum: Vector3;
  66219. private _worldMatrix;
  66220. private static readonly TmpVector3;
  66221. /**
  66222. * Creates a new bounding sphere
  66223. * @param min defines the minimum vector (in local space)
  66224. * @param max defines the maximum vector (in local space)
  66225. * @param worldMatrix defines the new world matrix
  66226. */
  66227. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  66228. /**
  66229. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  66230. * @param min defines the new minimum vector (in local space)
  66231. * @param max defines the new maximum vector (in local space)
  66232. * @param worldMatrix defines the new world matrix
  66233. */
  66234. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  66235. /**
  66236. * Scale the current bounding sphere by applying a scale factor
  66237. * @param factor defines the scale factor to apply
  66238. * @returns the current bounding box
  66239. */
  66240. scale(factor: number): BoundingSphere;
  66241. /**
  66242. * Gets the world matrix of the bounding box
  66243. * @returns a matrix
  66244. */
  66245. getWorldMatrix(): DeepImmutable<Matrix>;
  66246. /** @hidden */
  66247. _update(worldMatrix: DeepImmutable<Matrix>): void;
  66248. /**
  66249. * Tests if the bounding sphere is intersecting the frustum planes
  66250. * @param frustumPlanes defines the frustum planes to test
  66251. * @returns true if there is an intersection
  66252. */
  66253. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  66254. /**
  66255. * Tests if the bounding sphere center is in between the frustum planes.
  66256. * Used for optimistic fast inclusion.
  66257. * @param frustumPlanes defines the frustum planes to test
  66258. * @returns true if the sphere center is in between the frustum planes
  66259. */
  66260. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  66261. /**
  66262. * Tests if a point is inside the bounding sphere
  66263. * @param point defines the point to test
  66264. * @returns true if the point is inside the bounding sphere
  66265. */
  66266. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  66267. /**
  66268. * Checks if two sphere intersct
  66269. * @param sphere0 sphere 0
  66270. * @param sphere1 sphere 1
  66271. * @returns true if the speres intersect
  66272. */
  66273. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  66274. }
  66275. }
  66276. declare module BABYLON {
  66277. /**
  66278. * Class used to store bounding box information
  66279. */
  66280. export class BoundingBox implements ICullable {
  66281. /**
  66282. * Gets the 8 vectors representing the bounding box in local space
  66283. */
  66284. readonly vectors: Vector3[];
  66285. /**
  66286. * Gets the center of the bounding box in local space
  66287. */
  66288. readonly center: Vector3;
  66289. /**
  66290. * Gets the center of the bounding box in world space
  66291. */
  66292. readonly centerWorld: Vector3;
  66293. /**
  66294. * Gets the extend size in local space
  66295. */
  66296. readonly extendSize: Vector3;
  66297. /**
  66298. * Gets the extend size in world space
  66299. */
  66300. readonly extendSizeWorld: Vector3;
  66301. /**
  66302. * Gets the OBB (object bounding box) directions
  66303. */
  66304. readonly directions: Vector3[];
  66305. /**
  66306. * Gets the 8 vectors representing the bounding box in world space
  66307. */
  66308. readonly vectorsWorld: Vector3[];
  66309. /**
  66310. * Gets the minimum vector in world space
  66311. */
  66312. readonly minimumWorld: Vector3;
  66313. /**
  66314. * Gets the maximum vector in world space
  66315. */
  66316. readonly maximumWorld: Vector3;
  66317. /**
  66318. * Gets the minimum vector in local space
  66319. */
  66320. readonly minimum: Vector3;
  66321. /**
  66322. * Gets the maximum vector in local space
  66323. */
  66324. readonly maximum: Vector3;
  66325. private _worldMatrix;
  66326. private static readonly TmpVector3;
  66327. /**
  66328. * @hidden
  66329. */
  66330. _tag: number;
  66331. /**
  66332. * Creates a new bounding box
  66333. * @param min defines the minimum vector (in local space)
  66334. * @param max defines the maximum vector (in local space)
  66335. * @param worldMatrix defines the new world matrix
  66336. */
  66337. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  66338. /**
  66339. * Recreates the entire bounding box from scratch as if we call the constructor in place
  66340. * @param min defines the new minimum vector (in local space)
  66341. * @param max defines the new maximum vector (in local space)
  66342. * @param worldMatrix defines the new world matrix
  66343. */
  66344. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  66345. /**
  66346. * Scale the current bounding box by applying a scale factor
  66347. * @param factor defines the scale factor to apply
  66348. * @returns the current bounding box
  66349. */
  66350. scale(factor: number): BoundingBox;
  66351. /**
  66352. * Gets the world matrix of the bounding box
  66353. * @returns a matrix
  66354. */
  66355. getWorldMatrix(): DeepImmutable<Matrix>;
  66356. /** @hidden */
  66357. _update(world: DeepImmutable<Matrix>): void;
  66358. /**
  66359. * Tests if the bounding box is intersecting the frustum planes
  66360. * @param frustumPlanes defines the frustum planes to test
  66361. * @returns true if there is an intersection
  66362. */
  66363. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  66364. /**
  66365. * Tests if the bounding box is entirely inside the frustum planes
  66366. * @param frustumPlanes defines the frustum planes to test
  66367. * @returns true if there is an inclusion
  66368. */
  66369. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  66370. /**
  66371. * Tests if a point is inside the bounding box
  66372. * @param point defines the point to test
  66373. * @returns true if the point is inside the bounding box
  66374. */
  66375. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  66376. /**
  66377. * Tests if the bounding box intersects with a bounding sphere
  66378. * @param sphere defines the sphere to test
  66379. * @returns true if there is an intersection
  66380. */
  66381. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  66382. /**
  66383. * Tests if the bounding box intersects with a box defined by a min and max vectors
  66384. * @param min defines the min vector to use
  66385. * @param max defines the max vector to use
  66386. * @returns true if there is an intersection
  66387. */
  66388. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  66389. /**
  66390. * Tests if two bounding boxes are intersections
  66391. * @param box0 defines the first box to test
  66392. * @param box1 defines the second box to test
  66393. * @returns true if there is an intersection
  66394. */
  66395. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  66396. /**
  66397. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  66398. * @param minPoint defines the minimum vector of the bounding box
  66399. * @param maxPoint defines the maximum vector of the bounding box
  66400. * @param sphereCenter defines the sphere center
  66401. * @param sphereRadius defines the sphere radius
  66402. * @returns true if there is an intersection
  66403. */
  66404. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  66405. /**
  66406. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  66407. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  66408. * @param frustumPlanes defines the frustum planes to test
  66409. * @return true if there is an inclusion
  66410. */
  66411. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  66412. /**
  66413. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  66414. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  66415. * @param frustumPlanes defines the frustum planes to test
  66416. * @return true if there is an intersection
  66417. */
  66418. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  66419. }
  66420. }
  66421. declare module BABYLON {
  66422. /** @hidden */
  66423. export class Collider {
  66424. /** Define if a collision was found */
  66425. collisionFound: boolean;
  66426. /**
  66427. * Define last intersection point in local space
  66428. */
  66429. intersectionPoint: Vector3;
  66430. /**
  66431. * Define last collided mesh
  66432. */
  66433. collidedMesh: Nullable<AbstractMesh>;
  66434. private _collisionPoint;
  66435. private _planeIntersectionPoint;
  66436. private _tempVector;
  66437. private _tempVector2;
  66438. private _tempVector3;
  66439. private _tempVector4;
  66440. private _edge;
  66441. private _baseToVertex;
  66442. private _destinationPoint;
  66443. private _slidePlaneNormal;
  66444. private _displacementVector;
  66445. /** @hidden */
  66446. _radius: Vector3;
  66447. /** @hidden */
  66448. _retry: number;
  66449. private _velocity;
  66450. private _basePoint;
  66451. private _epsilon;
  66452. /** @hidden */
  66453. _velocityWorldLength: number;
  66454. /** @hidden */
  66455. _basePointWorld: Vector3;
  66456. private _velocityWorld;
  66457. private _normalizedVelocity;
  66458. /** @hidden */
  66459. _initialVelocity: Vector3;
  66460. /** @hidden */
  66461. _initialPosition: Vector3;
  66462. private _nearestDistance;
  66463. private _collisionMask;
  66464. collisionMask: number;
  66465. /**
  66466. * Gets the plane normal used to compute the sliding response (in local space)
  66467. */
  66468. readonly slidePlaneNormal: Vector3;
  66469. /** @hidden */
  66470. _initialize(source: Vector3, dir: Vector3, e: number): void;
  66471. /** @hidden */
  66472. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  66473. /** @hidden */
  66474. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  66475. /** @hidden */
  66476. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  66477. /** @hidden */
  66478. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  66479. /** @hidden */
  66480. _getResponse(pos: Vector3, vel: Vector3): void;
  66481. }
  66482. }
  66483. declare module BABYLON {
  66484. /**
  66485. * Interface for cullable objects
  66486. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  66487. */
  66488. export interface ICullable {
  66489. /**
  66490. * Checks if the object or part of the object is in the frustum
  66491. * @param frustumPlanes Camera near/planes
  66492. * @returns true if the object is in frustum otherwise false
  66493. */
  66494. isInFrustum(frustumPlanes: Plane[]): boolean;
  66495. /**
  66496. * Checks if a cullable object (mesh...) is in the camera frustum
  66497. * Unlike isInFrustum this cheks the full bounding box
  66498. * @param frustumPlanes Camera near/planes
  66499. * @returns true if the object is in frustum otherwise false
  66500. */
  66501. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  66502. }
  66503. /**
  66504. * Info for a bounding data of a mesh
  66505. */
  66506. export class BoundingInfo implements ICullable {
  66507. /**
  66508. * Bounding box for the mesh
  66509. */
  66510. readonly boundingBox: BoundingBox;
  66511. /**
  66512. * Bounding sphere for the mesh
  66513. */
  66514. readonly boundingSphere: BoundingSphere;
  66515. private _isLocked;
  66516. private static readonly TmpVector3;
  66517. /**
  66518. * Constructs bounding info
  66519. * @param minimum min vector of the bounding box/sphere
  66520. * @param maximum max vector of the bounding box/sphere
  66521. * @param worldMatrix defines the new world matrix
  66522. */
  66523. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  66524. /**
  66525. * Recreates the entire bounding info from scratch as if we call the constructor in place
  66526. * @param min defines the new minimum vector (in local space)
  66527. * @param max defines the new maximum vector (in local space)
  66528. * @param worldMatrix defines the new world matrix
  66529. */
  66530. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  66531. /**
  66532. * min vector of the bounding box/sphere
  66533. */
  66534. readonly minimum: Vector3;
  66535. /**
  66536. * max vector of the bounding box/sphere
  66537. */
  66538. readonly maximum: Vector3;
  66539. /**
  66540. * If the info is locked and won't be updated to avoid perf overhead
  66541. */
  66542. isLocked: boolean;
  66543. /**
  66544. * Updates the bounding sphere and box
  66545. * @param world world matrix to be used to update
  66546. */
  66547. update(world: DeepImmutable<Matrix>): void;
  66548. /**
  66549. * Recreate the bounding info to be centered around a specific point given a specific extend.
  66550. * @param center New center of the bounding info
  66551. * @param extend New extend of the bounding info
  66552. * @returns the current bounding info
  66553. */
  66554. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  66555. /**
  66556. * Scale the current bounding info by applying a scale factor
  66557. * @param factor defines the scale factor to apply
  66558. * @returns the current bounding info
  66559. */
  66560. scale(factor: number): BoundingInfo;
  66561. /**
  66562. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  66563. * @param frustumPlanes defines the frustum to test
  66564. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  66565. * @returns true if the bounding info is in the frustum planes
  66566. */
  66567. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  66568. /**
  66569. * Gets the world distance between the min and max points of the bounding box
  66570. */
  66571. readonly diagonalLength: number;
  66572. /**
  66573. * Checks if a cullable object (mesh...) is in the camera frustum
  66574. * Unlike isInFrustum this cheks the full bounding box
  66575. * @param frustumPlanes Camera near/planes
  66576. * @returns true if the object is in frustum otherwise false
  66577. */
  66578. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  66579. /** @hidden */
  66580. _checkCollision(collider: Collider): boolean;
  66581. /**
  66582. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  66583. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  66584. * @param point the point to check intersection with
  66585. * @returns if the point intersects
  66586. */
  66587. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  66588. /**
  66589. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  66590. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  66591. * @param boundingInfo the bounding info to check intersection with
  66592. * @param precise if the intersection should be done using OBB
  66593. * @returns if the bounding info intersects
  66594. */
  66595. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  66596. }
  66597. }
  66598. declare module BABYLON {
  66599. /**
  66600. * Defines an array and its length.
  66601. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  66602. */
  66603. export interface ISmartArrayLike<T> {
  66604. /**
  66605. * The data of the array.
  66606. */
  66607. data: Array<T>;
  66608. /**
  66609. * The active length of the array.
  66610. */
  66611. length: number;
  66612. }
  66613. /**
  66614. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  66615. */
  66616. export class SmartArray<T> implements ISmartArrayLike<T> {
  66617. /**
  66618. * The full set of data from the array.
  66619. */
  66620. data: Array<T>;
  66621. /**
  66622. * The active length of the array.
  66623. */
  66624. length: number;
  66625. protected _id: number;
  66626. /**
  66627. * Instantiates a Smart Array.
  66628. * @param capacity defines the default capacity of the array.
  66629. */
  66630. constructor(capacity: number);
  66631. /**
  66632. * Pushes a value at the end of the active data.
  66633. * @param value defines the object to push in the array.
  66634. */
  66635. push(value: T): void;
  66636. /**
  66637. * Iterates over the active data and apply the lambda to them.
  66638. * @param func defines the action to apply on each value.
  66639. */
  66640. forEach(func: (content: T) => void): void;
  66641. /**
  66642. * Sorts the full sets of data.
  66643. * @param compareFn defines the comparison function to apply.
  66644. */
  66645. sort(compareFn: (a: T, b: T) => number): void;
  66646. /**
  66647. * Resets the active data to an empty array.
  66648. */
  66649. reset(): void;
  66650. /**
  66651. * Releases all the data from the array as well as the array.
  66652. */
  66653. dispose(): void;
  66654. /**
  66655. * Concats the active data with a given array.
  66656. * @param array defines the data to concatenate with.
  66657. */
  66658. concat(array: any): void;
  66659. /**
  66660. * Returns the position of a value in the active data.
  66661. * @param value defines the value to find the index for
  66662. * @returns the index if found in the active data otherwise -1
  66663. */
  66664. indexOf(value: T): number;
  66665. /**
  66666. * Returns whether an element is part of the active data.
  66667. * @param value defines the value to look for
  66668. * @returns true if found in the active data otherwise false
  66669. */
  66670. contains(value: T): boolean;
  66671. private static _GlobalId;
  66672. }
  66673. /**
  66674. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  66675. * The data in this array can only be present once
  66676. */
  66677. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  66678. private _duplicateId;
  66679. /**
  66680. * Pushes a value at the end of the active data.
  66681. * THIS DOES NOT PREVENT DUPPLICATE DATA
  66682. * @param value defines the object to push in the array.
  66683. */
  66684. push(value: T): void;
  66685. /**
  66686. * Pushes a value at the end of the active data.
  66687. * If the data is already present, it won t be added again
  66688. * @param value defines the object to push in the array.
  66689. * @returns true if added false if it was already present
  66690. */
  66691. pushNoDuplicate(value: T): boolean;
  66692. /**
  66693. * Resets the active data to an empty array.
  66694. */
  66695. reset(): void;
  66696. /**
  66697. * Concats the active data with a given array.
  66698. * This ensures no dupplicate will be present in the result.
  66699. * @param array defines the data to concatenate with.
  66700. */
  66701. concatWithNoDuplicate(array: any): void;
  66702. }
  66703. }
  66704. declare module BABYLON {
  66705. /**
  66706. * A multi-material is used to apply different materials to different parts of the same object without the need of
  66707. * separate meshes. This can be use to improve performances.
  66708. * @see http://doc.babylonjs.com/how_to/multi_materials
  66709. */
  66710. export class MultiMaterial extends Material {
  66711. private _subMaterials;
  66712. /**
  66713. * Gets or Sets the list of Materials used within the multi material.
  66714. * They need to be ordered according to the submeshes order in the associated mesh
  66715. */
  66716. subMaterials: Nullable<Material>[];
  66717. /**
  66718. * Function used to align with Node.getChildren()
  66719. * @returns the list of Materials used within the multi material
  66720. */
  66721. getChildren(): Nullable<Material>[];
  66722. /**
  66723. * Instantiates a new Multi Material
  66724. * A multi-material is used to apply different materials to different parts of the same object without the need of
  66725. * separate meshes. This can be use to improve performances.
  66726. * @see http://doc.babylonjs.com/how_to/multi_materials
  66727. * @param name Define the name in the scene
  66728. * @param scene Define the scene the material belongs to
  66729. */
  66730. constructor(name: string, scene: Scene);
  66731. private _hookArray;
  66732. /**
  66733. * Get one of the submaterial by its index in the submaterials array
  66734. * @param index The index to look the sub material at
  66735. * @returns The Material if the index has been defined
  66736. */
  66737. getSubMaterial(index: number): Nullable<Material>;
  66738. /**
  66739. * Get the list of active textures for the whole sub materials list.
  66740. * @returns All the textures that will be used during the rendering
  66741. */
  66742. getActiveTextures(): BaseTexture[];
  66743. /**
  66744. * Gets the current class name of the material e.g. "MultiMaterial"
  66745. * Mainly use in serialization.
  66746. * @returns the class name
  66747. */
  66748. getClassName(): string;
  66749. /**
  66750. * Checks if the material is ready to render the requested sub mesh
  66751. * @param mesh Define the mesh the submesh belongs to
  66752. * @param subMesh Define the sub mesh to look readyness for
  66753. * @param useInstances Define whether or not the material is used with instances
  66754. * @returns true if ready, otherwise false
  66755. */
  66756. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  66757. /**
  66758. * Clones the current material and its related sub materials
  66759. * @param name Define the name of the newly cloned material
  66760. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  66761. * @returns the cloned material
  66762. */
  66763. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  66764. /**
  66765. * Serializes the materials into a JSON representation.
  66766. * @returns the JSON representation
  66767. */
  66768. serialize(): any;
  66769. /**
  66770. * Dispose the material and release its associated resources
  66771. * @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)
  66772. * @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)
  66773. * @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)
  66774. */
  66775. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  66776. /**
  66777. * Creates a MultiMaterial from parsed MultiMaterial data.
  66778. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  66779. * @param scene defines the hosting scene
  66780. * @returns a new MultiMaterial
  66781. */
  66782. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  66783. }
  66784. }
  66785. declare module BABYLON {
  66786. /**
  66787. * Class used to represent data loading progression
  66788. */
  66789. export class SceneLoaderFlags {
  66790. private static _ForceFullSceneLoadingForIncremental;
  66791. private static _ShowLoadingScreen;
  66792. private static _CleanBoneMatrixWeights;
  66793. private static _loggingLevel;
  66794. /**
  66795. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  66796. */
  66797. static ForceFullSceneLoadingForIncremental: boolean;
  66798. /**
  66799. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  66800. */
  66801. static ShowLoadingScreen: boolean;
  66802. /**
  66803. * Defines the current logging level (while loading the scene)
  66804. * @ignorenaming
  66805. */
  66806. static loggingLevel: number;
  66807. /**
  66808. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  66809. */
  66810. static CleanBoneMatrixWeights: boolean;
  66811. }
  66812. }
  66813. declare module BABYLON {
  66814. /**
  66815. * 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.
  66816. * @see https://doc.babylonjs.com/how_to/transformnode
  66817. */
  66818. export class TransformNode extends Node {
  66819. /**
  66820. * Object will not rotate to face the camera
  66821. */
  66822. static BILLBOARDMODE_NONE: number;
  66823. /**
  66824. * Object will rotate to face the camera but only on the x axis
  66825. */
  66826. static BILLBOARDMODE_X: number;
  66827. /**
  66828. * Object will rotate to face the camera but only on the y axis
  66829. */
  66830. static BILLBOARDMODE_Y: number;
  66831. /**
  66832. * Object will rotate to face the camera but only on the z axis
  66833. */
  66834. static BILLBOARDMODE_Z: number;
  66835. /**
  66836. * Object will rotate to face the camera
  66837. */
  66838. static BILLBOARDMODE_ALL: number;
  66839. private _forward;
  66840. private _forwardInverted;
  66841. private _up;
  66842. private _right;
  66843. private _rightInverted;
  66844. private _usePivotMatrix;
  66845. private _position;
  66846. private _rotation;
  66847. private _rotationQuaternion;
  66848. protected _scaling: Vector3;
  66849. protected _isDirty: boolean;
  66850. private _transformToBoneReferal;
  66851. /**
  66852. * Set the billboard mode. Default is 0.
  66853. *
  66854. * | Value | Type | Description |
  66855. * | --- | --- | --- |
  66856. * | 0 | BILLBOARDMODE_NONE | |
  66857. * | 1 | BILLBOARDMODE_X | |
  66858. * | 2 | BILLBOARDMODE_Y | |
  66859. * | 4 | BILLBOARDMODE_Z | |
  66860. * | 7 | BILLBOARDMODE_ALL | |
  66861. *
  66862. */
  66863. billboardMode: number;
  66864. /**
  66865. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  66866. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  66867. */
  66868. preserveParentRotationForBillboard: boolean;
  66869. /**
  66870. * 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
  66871. */
  66872. scalingDeterminant: number;
  66873. /**
  66874. * Sets the distance of the object to max, often used by skybox
  66875. */
  66876. infiniteDistance: boolean;
  66877. /**
  66878. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  66879. * By default the system will update normals to compensate
  66880. */
  66881. ignoreNonUniformScaling: boolean;
  66882. /** @hidden */
  66883. _poseMatrix: Matrix;
  66884. /** @hidden */
  66885. _localMatrix: Matrix;
  66886. private _absolutePosition;
  66887. private _pivotMatrix;
  66888. private _pivotMatrixInverse;
  66889. protected _postMultiplyPivotMatrix: boolean;
  66890. protected _isWorldMatrixFrozen: boolean;
  66891. /** @hidden */
  66892. _indexInSceneTransformNodesArray: number;
  66893. /**
  66894. * An event triggered after the world matrix is updated
  66895. */
  66896. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  66897. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  66898. /**
  66899. * Gets a string identifying the name of the class
  66900. * @returns "TransformNode" string
  66901. */
  66902. getClassName(): string;
  66903. /**
  66904. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  66905. */
  66906. position: Vector3;
  66907. /**
  66908. * 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)).
  66909. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  66910. */
  66911. rotation: Vector3;
  66912. /**
  66913. * 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)).
  66914. */
  66915. scaling: Vector3;
  66916. /**
  66917. * 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).
  66918. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  66919. */
  66920. rotationQuaternion: Nullable<Quaternion>;
  66921. /**
  66922. * The forward direction of that transform in world space.
  66923. */
  66924. readonly forward: Vector3;
  66925. /**
  66926. * The up direction of that transform in world space.
  66927. */
  66928. readonly up: Vector3;
  66929. /**
  66930. * The right direction of that transform in world space.
  66931. */
  66932. readonly right: Vector3;
  66933. /**
  66934. * Copies the parameter passed Matrix into the mesh Pose matrix.
  66935. * @param matrix the matrix to copy the pose from
  66936. * @returns this TransformNode.
  66937. */
  66938. updatePoseMatrix(matrix: Matrix): TransformNode;
  66939. /**
  66940. * Returns the mesh Pose matrix.
  66941. * @returns the pose matrix
  66942. */
  66943. getPoseMatrix(): Matrix;
  66944. /** @hidden */
  66945. _isSynchronized(): boolean;
  66946. /** @hidden */
  66947. _initCache(): void;
  66948. /**
  66949. * Flag the transform node as dirty (Forcing it to update everything)
  66950. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  66951. * @returns this transform node
  66952. */
  66953. markAsDirty(property: string): TransformNode;
  66954. /**
  66955. * Returns the current mesh absolute position.
  66956. * Returns a Vector3.
  66957. */
  66958. readonly absolutePosition: Vector3;
  66959. /**
  66960. * Sets a new matrix to apply before all other transformation
  66961. * @param matrix defines the transform matrix
  66962. * @returns the current TransformNode
  66963. */
  66964. setPreTransformMatrix(matrix: Matrix): TransformNode;
  66965. /**
  66966. * Sets a new pivot matrix to the current node
  66967. * @param matrix defines the new pivot matrix to use
  66968. * @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
  66969. * @returns the current TransformNode
  66970. */
  66971. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  66972. /**
  66973. * Returns the mesh pivot matrix.
  66974. * Default : Identity.
  66975. * @returns the matrix
  66976. */
  66977. getPivotMatrix(): Matrix;
  66978. /**
  66979. * Prevents the World matrix to be computed any longer.
  66980. * @returns the TransformNode.
  66981. */
  66982. freezeWorldMatrix(): TransformNode;
  66983. /**
  66984. * Allows back the World matrix computation.
  66985. * @returns the TransformNode.
  66986. */
  66987. unfreezeWorldMatrix(): this;
  66988. /**
  66989. * True if the World matrix has been frozen.
  66990. */
  66991. readonly isWorldMatrixFrozen: boolean;
  66992. /**
  66993. * Retuns the mesh absolute position in the World.
  66994. * @returns a Vector3.
  66995. */
  66996. getAbsolutePosition(): Vector3;
  66997. /**
  66998. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  66999. * @param absolutePosition the absolute position to set
  67000. * @returns the TransformNode.
  67001. */
  67002. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  67003. /**
  67004. * Sets the mesh position in its local space.
  67005. * @param vector3 the position to set in localspace
  67006. * @returns the TransformNode.
  67007. */
  67008. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  67009. /**
  67010. * Returns the mesh position in the local space from the current World matrix values.
  67011. * @returns a new Vector3.
  67012. */
  67013. getPositionExpressedInLocalSpace(): Vector3;
  67014. /**
  67015. * Translates the mesh along the passed Vector3 in its local space.
  67016. * @param vector3 the distance to translate in localspace
  67017. * @returns the TransformNode.
  67018. */
  67019. locallyTranslate(vector3: Vector3): TransformNode;
  67020. private static _lookAtVectorCache;
  67021. /**
  67022. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  67023. * @param targetPoint the position (must be in same space as current mesh) to look at
  67024. * @param yawCor optional yaw (y-axis) correction in radians
  67025. * @param pitchCor optional pitch (x-axis) correction in radians
  67026. * @param rollCor optional roll (z-axis) correction in radians
  67027. * @param space the choosen space of the target
  67028. * @returns the TransformNode.
  67029. */
  67030. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  67031. /**
  67032. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  67033. * This Vector3 is expressed in the World space.
  67034. * @param localAxis axis to rotate
  67035. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  67036. */
  67037. getDirection(localAxis: Vector3): Vector3;
  67038. /**
  67039. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  67040. * localAxis is expressed in the mesh local space.
  67041. * result is computed in the Wordl space from the mesh World matrix.
  67042. * @param localAxis axis to rotate
  67043. * @param result the resulting transformnode
  67044. * @returns this TransformNode.
  67045. */
  67046. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  67047. /**
  67048. * Sets this transform node rotation to the given local axis.
  67049. * @param localAxis the axis in local space
  67050. * @param yawCor optional yaw (y-axis) correction in radians
  67051. * @param pitchCor optional pitch (x-axis) correction in radians
  67052. * @param rollCor optional roll (z-axis) correction in radians
  67053. * @returns this TransformNode
  67054. */
  67055. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  67056. /**
  67057. * Sets a new pivot point to the current node
  67058. * @param point defines the new pivot point to use
  67059. * @param space defines if the point is in world or local space (local by default)
  67060. * @returns the current TransformNode
  67061. */
  67062. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  67063. /**
  67064. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  67065. * @returns the pivot point
  67066. */
  67067. getPivotPoint(): Vector3;
  67068. /**
  67069. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  67070. * @param result the vector3 to store the result
  67071. * @returns this TransformNode.
  67072. */
  67073. getPivotPointToRef(result: Vector3): TransformNode;
  67074. /**
  67075. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  67076. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  67077. */
  67078. getAbsolutePivotPoint(): Vector3;
  67079. /**
  67080. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  67081. * @param result vector3 to store the result
  67082. * @returns this TransformNode.
  67083. */
  67084. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  67085. /**
  67086. * Defines the passed node as the parent of the current node.
  67087. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  67088. * @see https://doc.babylonjs.com/how_to/parenting
  67089. * @param node the node ot set as the parent
  67090. * @returns this TransformNode.
  67091. */
  67092. setParent(node: Nullable<Node>): TransformNode;
  67093. private _nonUniformScaling;
  67094. /**
  67095. * True if the scaling property of this object is non uniform eg. (1,2,1)
  67096. */
  67097. readonly nonUniformScaling: boolean;
  67098. /** @hidden */
  67099. _updateNonUniformScalingState(value: boolean): boolean;
  67100. /**
  67101. * Attach the current TransformNode to another TransformNode associated with a bone
  67102. * @param bone Bone affecting the TransformNode
  67103. * @param affectedTransformNode TransformNode associated with the bone
  67104. * @returns this object
  67105. */
  67106. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  67107. /**
  67108. * Detach the transform node if its associated with a bone
  67109. * @returns this object
  67110. */
  67111. detachFromBone(): TransformNode;
  67112. private static _rotationAxisCache;
  67113. /**
  67114. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  67115. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  67116. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  67117. * The passed axis is also normalized.
  67118. * @param axis the axis to rotate around
  67119. * @param amount the amount to rotate in radians
  67120. * @param space Space to rotate in (Default: local)
  67121. * @returns the TransformNode.
  67122. */
  67123. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  67124. /**
  67125. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  67126. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  67127. * The passed axis is also normalized. .
  67128. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  67129. * @param point the point to rotate around
  67130. * @param axis the axis to rotate around
  67131. * @param amount the amount to rotate in radians
  67132. * @returns the TransformNode
  67133. */
  67134. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  67135. /**
  67136. * Translates the mesh along the axis vector for the passed distance in the given space.
  67137. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  67138. * @param axis the axis to translate in
  67139. * @param distance the distance to translate
  67140. * @param space Space to rotate in (Default: local)
  67141. * @returns the TransformNode.
  67142. */
  67143. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  67144. /**
  67145. * Adds a rotation step to the mesh current rotation.
  67146. * x, y, z are Euler angles expressed in radians.
  67147. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  67148. * This means this rotation is made in the mesh local space only.
  67149. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  67150. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  67151. * ```javascript
  67152. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  67153. * ```
  67154. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  67155. * 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.
  67156. * @param x Rotation to add
  67157. * @param y Rotation to add
  67158. * @param z Rotation to add
  67159. * @returns the TransformNode.
  67160. */
  67161. addRotation(x: number, y: number, z: number): TransformNode;
  67162. /**
  67163. * @hidden
  67164. */
  67165. protected _getEffectiveParent(): Nullable<Node>;
  67166. /**
  67167. * Computes the world matrix of the node
  67168. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  67169. * @returns the world matrix
  67170. */
  67171. computeWorldMatrix(force?: boolean): Matrix;
  67172. protected _afterComputeWorldMatrix(): void;
  67173. /**
  67174. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  67175. * @param func callback function to add
  67176. *
  67177. * @returns the TransformNode.
  67178. */
  67179. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  67180. /**
  67181. * Removes a registered callback function.
  67182. * @param func callback function to remove
  67183. * @returns the TransformNode.
  67184. */
  67185. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  67186. /**
  67187. * Gets the position of the current mesh in camera space
  67188. * @param camera defines the camera to use
  67189. * @returns a position
  67190. */
  67191. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  67192. /**
  67193. * Returns the distance from the mesh to the active camera
  67194. * @param camera defines the camera to use
  67195. * @returns the distance
  67196. */
  67197. getDistanceToCamera(camera?: Nullable<Camera>): number;
  67198. /**
  67199. * Clone the current transform node
  67200. * @param name Name of the new clone
  67201. * @param newParent New parent for the clone
  67202. * @param doNotCloneChildren Do not clone children hierarchy
  67203. * @returns the new transform node
  67204. */
  67205. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  67206. /**
  67207. * Serializes the objects information.
  67208. * @param currentSerializationObject defines the object to serialize in
  67209. * @returns the serialized object
  67210. */
  67211. serialize(currentSerializationObject?: any): any;
  67212. /**
  67213. * Returns a new TransformNode object parsed from the source provided.
  67214. * @param parsedTransformNode is the source.
  67215. * @param scene the scne the object belongs to
  67216. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  67217. * @returns a new TransformNode object parsed from the source provided.
  67218. */
  67219. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  67220. /**
  67221. * Get all child-transformNodes of this node
  67222. * @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
  67223. * @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
  67224. * @returns an array of TransformNode
  67225. */
  67226. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  67227. /**
  67228. * Releases resources associated with this transform node.
  67229. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  67230. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  67231. */
  67232. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  67233. }
  67234. }
  67235. declare module BABYLON {
  67236. /**
  67237. * Class used to override all child animations of a given target
  67238. */
  67239. export class AnimationPropertiesOverride {
  67240. /**
  67241. * Gets or sets a value indicating if animation blending must be used
  67242. */
  67243. enableBlending: boolean;
  67244. /**
  67245. * Gets or sets the blending speed to use when enableBlending is true
  67246. */
  67247. blendingSpeed: number;
  67248. /**
  67249. * Gets or sets the default loop mode to use
  67250. */
  67251. loopMode: number;
  67252. }
  67253. }
  67254. declare module BABYLON {
  67255. /**
  67256. * Class used to store bone information
  67257. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  67258. */
  67259. export class Bone extends Node {
  67260. /**
  67261. * defines the bone name
  67262. */
  67263. name: string;
  67264. private static _tmpVecs;
  67265. private static _tmpQuat;
  67266. private static _tmpMats;
  67267. /**
  67268. * Gets the list of child bones
  67269. */
  67270. children: Bone[];
  67271. /** Gets the animations associated with this bone */
  67272. animations: Animation[];
  67273. /**
  67274. * Gets or sets bone length
  67275. */
  67276. length: number;
  67277. /**
  67278. * @hidden Internal only
  67279. * Set this value to map this bone to a different index in the transform matrices
  67280. * Set this value to -1 to exclude the bone from the transform matrices
  67281. */
  67282. _index: Nullable<number>;
  67283. private _skeleton;
  67284. private _localMatrix;
  67285. private _restPose;
  67286. private _baseMatrix;
  67287. private _absoluteTransform;
  67288. private _invertedAbsoluteTransform;
  67289. private _parent;
  67290. private _scalingDeterminant;
  67291. private _worldTransform;
  67292. private _localScaling;
  67293. private _localRotation;
  67294. private _localPosition;
  67295. private _needToDecompose;
  67296. private _needToCompose;
  67297. /** @hidden */
  67298. _linkedTransformNode: Nullable<TransformNode>;
  67299. /** @hidden */
  67300. /** @hidden */
  67301. _matrix: Matrix;
  67302. /**
  67303. * Create a new bone
  67304. * @param name defines the bone name
  67305. * @param skeleton defines the parent skeleton
  67306. * @param parentBone defines the parent (can be null if the bone is the root)
  67307. * @param localMatrix defines the local matrix
  67308. * @param restPose defines the rest pose matrix
  67309. * @param baseMatrix defines the base matrix
  67310. * @param index defines index of the bone in the hiearchy
  67311. */
  67312. constructor(
  67313. /**
  67314. * defines the bone name
  67315. */
  67316. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  67317. /**
  67318. * Gets the current object class name.
  67319. * @return the class name
  67320. */
  67321. getClassName(): string;
  67322. /**
  67323. * Gets the parent skeleton
  67324. * @returns a skeleton
  67325. */
  67326. getSkeleton(): Skeleton;
  67327. /**
  67328. * Gets parent bone
  67329. * @returns a bone or null if the bone is the root of the bone hierarchy
  67330. */
  67331. getParent(): Nullable<Bone>;
  67332. /**
  67333. * Returns an array containing the root bones
  67334. * @returns an array containing the root bones
  67335. */
  67336. getChildren(): Array<Bone>;
  67337. /**
  67338. * Sets the parent bone
  67339. * @param parent defines the parent (can be null if the bone is the root)
  67340. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  67341. */
  67342. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  67343. /**
  67344. * Gets the local matrix
  67345. * @returns a matrix
  67346. */
  67347. getLocalMatrix(): Matrix;
  67348. /**
  67349. * Gets the base matrix (initial matrix which remains unchanged)
  67350. * @returns a matrix
  67351. */
  67352. getBaseMatrix(): Matrix;
  67353. /**
  67354. * Gets the rest pose matrix
  67355. * @returns a matrix
  67356. */
  67357. getRestPose(): Matrix;
  67358. /**
  67359. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  67360. */
  67361. getWorldMatrix(): Matrix;
  67362. /**
  67363. * Sets the local matrix to rest pose matrix
  67364. */
  67365. returnToRest(): void;
  67366. /**
  67367. * Gets the inverse of the absolute transform matrix.
  67368. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  67369. * @returns a matrix
  67370. */
  67371. getInvertedAbsoluteTransform(): Matrix;
  67372. /**
  67373. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  67374. * @returns a matrix
  67375. */
  67376. getAbsoluteTransform(): Matrix;
  67377. /**
  67378. * Links with the given transform node.
  67379. * The local matrix of this bone is copied from the transform node every frame.
  67380. * @param transformNode defines the transform node to link to
  67381. */
  67382. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  67383. /** Gets or sets current position (in local space) */
  67384. position: Vector3;
  67385. /** Gets or sets current rotation (in local space) */
  67386. rotation: Vector3;
  67387. /** Gets or sets current rotation quaternion (in local space) */
  67388. rotationQuaternion: Quaternion;
  67389. /** Gets or sets current scaling (in local space) */
  67390. scaling: Vector3;
  67391. /**
  67392. * Gets the animation properties override
  67393. */
  67394. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  67395. private _decompose;
  67396. private _compose;
  67397. /**
  67398. * Update the base and local matrices
  67399. * @param matrix defines the new base or local matrix
  67400. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  67401. * @param updateLocalMatrix defines if the local matrix should be updated
  67402. */
  67403. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  67404. /** @hidden */
  67405. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  67406. /**
  67407. * Flag the bone as dirty (Forcing it to update everything)
  67408. */
  67409. markAsDirty(): void;
  67410. private _markAsDirtyAndCompose;
  67411. private _markAsDirtyAndDecompose;
  67412. /**
  67413. * Translate the bone in local or world space
  67414. * @param vec The amount to translate the bone
  67415. * @param space The space that the translation is in
  67416. * @param mesh The mesh that this bone is attached to. This is only used in world space
  67417. */
  67418. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  67419. /**
  67420. * Set the postion of the bone in local or world space
  67421. * @param position The position to set the bone
  67422. * @param space The space that the position is in
  67423. * @param mesh The mesh that this bone is attached to. This is only used in world space
  67424. */
  67425. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  67426. /**
  67427. * Set the absolute position of the bone (world space)
  67428. * @param position The position to set the bone
  67429. * @param mesh The mesh that this bone is attached to
  67430. */
  67431. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  67432. /**
  67433. * Scale the bone on the x, y and z axes (in local space)
  67434. * @param x The amount to scale the bone on the x axis
  67435. * @param y The amount to scale the bone on the y axis
  67436. * @param z The amount to scale the bone on the z axis
  67437. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  67438. */
  67439. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  67440. /**
  67441. * Set the bone scaling in local space
  67442. * @param scale defines the scaling vector
  67443. */
  67444. setScale(scale: Vector3): void;
  67445. /**
  67446. * Gets the current scaling in local space
  67447. * @returns the current scaling vector
  67448. */
  67449. getScale(): Vector3;
  67450. /**
  67451. * Gets the current scaling in local space and stores it in a target vector
  67452. * @param result defines the target vector
  67453. */
  67454. getScaleToRef(result: Vector3): void;
  67455. /**
  67456. * Set the yaw, pitch, and roll of the bone in local or world space
  67457. * @param yaw The rotation of the bone on the y axis
  67458. * @param pitch The rotation of the bone on the x axis
  67459. * @param roll The rotation of the bone on the z axis
  67460. * @param space The space that the axes of rotation are in
  67461. * @param mesh The mesh that this bone is attached to. This is only used in world space
  67462. */
  67463. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  67464. /**
  67465. * Add a rotation to the bone on an axis in local or world space
  67466. * @param axis The axis to rotate the bone on
  67467. * @param amount The amount to rotate the bone
  67468. * @param space The space that the axis is in
  67469. * @param mesh The mesh that this bone is attached to. This is only used in world space
  67470. */
  67471. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  67472. /**
  67473. * Set the rotation of the bone to a particular axis angle in local or world space
  67474. * @param axis The axis to rotate the bone on
  67475. * @param angle The angle that the bone should be rotated to
  67476. * @param space The space that the axis is in
  67477. * @param mesh The mesh that this bone is attached to. This is only used in world space
  67478. */
  67479. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  67480. /**
  67481. * Set the euler rotation of the bone in local of world space
  67482. * @param rotation The euler rotation that the bone should be set to
  67483. * @param space The space that the rotation is in
  67484. * @param mesh The mesh that this bone is attached to. This is only used in world space
  67485. */
  67486. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  67487. /**
  67488. * Set the quaternion rotation of the bone in local of world space
  67489. * @param quat The quaternion rotation that the bone should be set to
  67490. * @param space The space that the rotation is in
  67491. * @param mesh The mesh that this bone is attached to. This is only used in world space
  67492. */
  67493. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  67494. /**
  67495. * Set the rotation matrix of the bone in local of world space
  67496. * @param rotMat The rotation matrix that the bone should be set to
  67497. * @param space The space that the rotation is in
  67498. * @param mesh The mesh that this bone is attached to. This is only used in world space
  67499. */
  67500. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  67501. private _rotateWithMatrix;
  67502. private _getNegativeRotationToRef;
  67503. /**
  67504. * Get the position of the bone in local or world space
  67505. * @param space The space that the returned position is in
  67506. * @param mesh The mesh that this bone is attached to. This is only used in world space
  67507. * @returns The position of the bone
  67508. */
  67509. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  67510. /**
  67511. * Copy the position of the bone to a vector3 in local or world space
  67512. * @param space The space that the returned position is in
  67513. * @param mesh The mesh that this bone is attached to. This is only used in world space
  67514. * @param result The vector3 to copy the position to
  67515. */
  67516. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  67517. /**
  67518. * Get the absolute position of the bone (world space)
  67519. * @param mesh The mesh that this bone is attached to
  67520. * @returns The absolute position of the bone
  67521. */
  67522. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  67523. /**
  67524. * Copy the absolute position of the bone (world space) to the result param
  67525. * @param mesh The mesh that this bone is attached to
  67526. * @param result The vector3 to copy the absolute position to
  67527. */
  67528. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  67529. /**
  67530. * Compute the absolute transforms of this bone and its children
  67531. */
  67532. computeAbsoluteTransforms(): void;
  67533. /**
  67534. * Get the world direction from an axis that is in the local space of the bone
  67535. * @param localAxis The local direction that is used to compute the world direction
  67536. * @param mesh The mesh that this bone is attached to
  67537. * @returns The world direction
  67538. */
  67539. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  67540. /**
  67541. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  67542. * @param localAxis The local direction that is used to compute the world direction
  67543. * @param mesh The mesh that this bone is attached to
  67544. * @param result The vector3 that the world direction will be copied to
  67545. */
  67546. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  67547. /**
  67548. * Get the euler rotation of the bone in local or world space
  67549. * @param space The space that the rotation should be in
  67550. * @param mesh The mesh that this bone is attached to. This is only used in world space
  67551. * @returns The euler rotation
  67552. */
  67553. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  67554. /**
  67555. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  67556. * @param space The space that the rotation should be in
  67557. * @param mesh The mesh that this bone is attached to. This is only used in world space
  67558. * @param result The vector3 that the rotation should be copied to
  67559. */
  67560. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  67561. /**
  67562. * Get the quaternion rotation of the bone in either local or world space
  67563. * @param space The space that the rotation should be in
  67564. * @param mesh The mesh that this bone is attached to. This is only used in world space
  67565. * @returns The quaternion rotation
  67566. */
  67567. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  67568. /**
  67569. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  67570. * @param space The space that the rotation should be in
  67571. * @param mesh The mesh that this bone is attached to. This is only used in world space
  67572. * @param result The quaternion that the rotation should be copied to
  67573. */
  67574. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  67575. /**
  67576. * Get the rotation matrix of the bone in local or world space
  67577. * @param space The space that the rotation should be in
  67578. * @param mesh The mesh that this bone is attached to. This is only used in world space
  67579. * @returns The rotation matrix
  67580. */
  67581. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  67582. /**
  67583. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  67584. * @param space The space that the rotation should be in
  67585. * @param mesh The mesh that this bone is attached to. This is only used in world space
  67586. * @param result The quaternion that the rotation should be copied to
  67587. */
  67588. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  67589. /**
  67590. * Get the world position of a point that is in the local space of the bone
  67591. * @param position The local position
  67592. * @param mesh The mesh that this bone is attached to
  67593. * @returns The world position
  67594. */
  67595. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  67596. /**
  67597. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  67598. * @param position The local position
  67599. * @param mesh The mesh that this bone is attached to
  67600. * @param result The vector3 that the world position should be copied to
  67601. */
  67602. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  67603. /**
  67604. * Get the local position of a point that is in world space
  67605. * @param position The world position
  67606. * @param mesh The mesh that this bone is attached to
  67607. * @returns The local position
  67608. */
  67609. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  67610. /**
  67611. * Get the local position of a point that is in world space and copy it to the result param
  67612. * @param position The world position
  67613. * @param mesh The mesh that this bone is attached to
  67614. * @param result The vector3 that the local position should be copied to
  67615. */
  67616. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  67617. }
  67618. }
  67619. declare module BABYLON {
  67620. /**
  67621. * Enum that determines the text-wrapping mode to use.
  67622. */
  67623. export enum InspectableType {
  67624. /**
  67625. * Checkbox for booleans
  67626. */
  67627. Checkbox = 0,
  67628. /**
  67629. * Sliders for numbers
  67630. */
  67631. Slider = 1,
  67632. /**
  67633. * Vector3
  67634. */
  67635. Vector3 = 2,
  67636. /**
  67637. * Quaternions
  67638. */
  67639. Quaternion = 3,
  67640. /**
  67641. * Color3
  67642. */
  67643. Color3 = 4
  67644. }
  67645. /**
  67646. * Interface used to define custom inspectable properties.
  67647. * This interface is used by the inspector to display custom property grids
  67648. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  67649. */
  67650. export interface IInspectable {
  67651. /**
  67652. * Gets the label to display
  67653. */
  67654. label: string;
  67655. /**
  67656. * Gets the name of the property to edit
  67657. */
  67658. propertyName: string;
  67659. /**
  67660. * Gets the type of the editor to use
  67661. */
  67662. type: InspectableType;
  67663. /**
  67664. * Gets the minimum value of the property when using in "slider" mode
  67665. */
  67666. min?: number;
  67667. /**
  67668. * Gets the maximum value of the property when using in "slider" mode
  67669. */
  67670. max?: number;
  67671. /**
  67672. * Gets the setp to use when using in "slider" mode
  67673. */
  67674. step?: number;
  67675. }
  67676. }
  67677. declare module BABYLON {
  67678. /**
  67679. * Class for creating a cube texture
  67680. */
  67681. export class CubeTexture extends BaseTexture {
  67682. private _delayedOnLoad;
  67683. /**
  67684. * The url of the texture
  67685. */
  67686. url: string;
  67687. /**
  67688. * Gets or sets the center of the bounding box associated with the cube texture.
  67689. * It must define where the camera used to render the texture was set
  67690. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  67691. */
  67692. boundingBoxPosition: Vector3;
  67693. private _boundingBoxSize;
  67694. /**
  67695. * Gets or sets the size of the bounding box associated with the cube texture
  67696. * When defined, the cubemap will switch to local mode
  67697. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  67698. * @example https://www.babylonjs-playground.com/#RNASML
  67699. */
  67700. /**
  67701. * Returns the bounding box size
  67702. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  67703. */
  67704. boundingBoxSize: Vector3;
  67705. protected _rotationY: number;
  67706. /**
  67707. * Sets texture matrix rotation angle around Y axis in radians.
  67708. */
  67709. /**
  67710. * Gets texture matrix rotation angle around Y axis radians.
  67711. */
  67712. rotationY: number;
  67713. /**
  67714. * Are mip maps generated for this texture or not.
  67715. */
  67716. readonly noMipmap: boolean;
  67717. private _noMipmap;
  67718. private _files;
  67719. private _extensions;
  67720. private _textureMatrix;
  67721. private _format;
  67722. private _createPolynomials;
  67723. /** @hidden */
  67724. _prefiltered: boolean;
  67725. /**
  67726. * Creates a cube texture from an array of image urls
  67727. * @param files defines an array of image urls
  67728. * @param scene defines the hosting scene
  67729. * @param noMipmap specifies if mip maps are not used
  67730. * @returns a cube texture
  67731. */
  67732. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  67733. /**
  67734. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  67735. * @param url defines the url of the prefiltered texture
  67736. * @param scene defines the scene the texture is attached to
  67737. * @param forcedExtension defines the extension of the file if different from the url
  67738. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  67739. * @return the prefiltered texture
  67740. */
  67741. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  67742. /**
  67743. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  67744. * as prefiltered data.
  67745. * @param rootUrl defines the url of the texture or the root name of the six images
  67746. * @param scene defines the scene the texture is attached to
  67747. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  67748. * @param noMipmap defines if mipmaps should be created or not
  67749. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  67750. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  67751. * @param onError defines a callback triggered in case of error during load
  67752. * @param format defines the internal format to use for the texture once loaded
  67753. * @param prefiltered defines whether or not the texture is created from prefiltered data
  67754. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  67755. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  67756. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  67757. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  67758. * @return the cube texture
  67759. */
  67760. 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);
  67761. /**
  67762. * Get the current class name of the texture useful for serialization or dynamic coding.
  67763. * @returns "CubeTexture"
  67764. */
  67765. getClassName(): string;
  67766. /**
  67767. * Update the url (and optional buffer) of this texture if url was null during construction.
  67768. * @param url the url of the texture
  67769. * @param forcedExtension defines the extension to use
  67770. * @param onLoad callback called when the texture is loaded (defaults to null)
  67771. */
  67772. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  67773. /**
  67774. * Delays loading of the cube texture
  67775. * @param forcedExtension defines the extension to use
  67776. */
  67777. delayLoad(forcedExtension?: string): void;
  67778. /**
  67779. * Returns the reflection texture matrix
  67780. * @returns the reflection texture matrix
  67781. */
  67782. getReflectionTextureMatrix(): Matrix;
  67783. /**
  67784. * Sets the reflection texture matrix
  67785. * @param value Reflection texture matrix
  67786. */
  67787. setReflectionTextureMatrix(value: Matrix): void;
  67788. /**
  67789. * Parses text to create a cube texture
  67790. * @param parsedTexture define the serialized text to read from
  67791. * @param scene defines the hosting scene
  67792. * @param rootUrl defines the root url of the cube texture
  67793. * @returns a cube texture
  67794. */
  67795. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  67796. /**
  67797. * Makes a clone, or deep copy, of the cube texture
  67798. * @returns a new cube texture
  67799. */
  67800. clone(): CubeTexture;
  67801. }
  67802. }
  67803. declare module BABYLON {
  67804. /** @hidden */
  67805. export var postprocessVertexShader: {
  67806. name: string;
  67807. shader: string;
  67808. };
  67809. }
  67810. declare module BABYLON {
  67811. /**
  67812. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  67813. * This is the base of the follow, arc rotate cameras and Free camera
  67814. * @see http://doc.babylonjs.com/features/cameras
  67815. */
  67816. export class TargetCamera extends Camera {
  67817. private static _RigCamTransformMatrix;
  67818. private static _TargetTransformMatrix;
  67819. private static _TargetFocalPoint;
  67820. /**
  67821. * Define the current direction the camera is moving to
  67822. */
  67823. cameraDirection: Vector3;
  67824. /**
  67825. * Define the current rotation the camera is rotating to
  67826. */
  67827. cameraRotation: Vector2;
  67828. /**
  67829. * When set, the up vector of the camera will be updated by the rotation of the camera
  67830. */
  67831. updateUpVectorFromRotation: boolean;
  67832. private _tmpQuaternion;
  67833. /**
  67834. * Define the current rotation of the camera
  67835. */
  67836. rotation: Vector3;
  67837. /**
  67838. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  67839. */
  67840. rotationQuaternion: Quaternion;
  67841. /**
  67842. * Define the current speed of the camera
  67843. */
  67844. speed: number;
  67845. /**
  67846. * Add cconstraint to the camera to prevent it to move freely in all directions and
  67847. * around all axis.
  67848. */
  67849. noRotationConstraint: boolean;
  67850. /**
  67851. * Define the current target of the camera as an object or a position.
  67852. */
  67853. lockedTarget: any;
  67854. /** @hidden */
  67855. _currentTarget: Vector3;
  67856. /** @hidden */
  67857. _initialFocalDistance: number;
  67858. /** @hidden */
  67859. _viewMatrix: Matrix;
  67860. /** @hidden */
  67861. _camMatrix: Matrix;
  67862. /** @hidden */
  67863. _cameraTransformMatrix: Matrix;
  67864. /** @hidden */
  67865. _cameraRotationMatrix: Matrix;
  67866. /** @hidden */
  67867. _referencePoint: Vector3;
  67868. /** @hidden */
  67869. _transformedReferencePoint: Vector3;
  67870. protected _globalCurrentTarget: Vector3;
  67871. protected _globalCurrentUpVector: Vector3;
  67872. /** @hidden */
  67873. _reset: () => void;
  67874. private _defaultUp;
  67875. /**
  67876. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  67877. * This is the base of the follow, arc rotate cameras and Free camera
  67878. * @see http://doc.babylonjs.com/features/cameras
  67879. * @param name Defines the name of the camera in the scene
  67880. * @param position Defines the start position of the camera in the scene
  67881. * @param scene Defines the scene the camera belongs to
  67882. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  67883. */
  67884. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  67885. /**
  67886. * Gets the position in front of the camera at a given distance.
  67887. * @param distance The distance from the camera we want the position to be
  67888. * @returns the position
  67889. */
  67890. getFrontPosition(distance: number): Vector3;
  67891. /** @hidden */
  67892. _getLockedTargetPosition(): Nullable<Vector3>;
  67893. private _storedPosition;
  67894. private _storedRotation;
  67895. private _storedRotationQuaternion;
  67896. /**
  67897. * Store current camera state of the camera (fov, position, rotation, etc..)
  67898. * @returns the camera
  67899. */
  67900. storeState(): Camera;
  67901. /**
  67902. * Restored camera state. You must call storeState() first
  67903. * @returns whether it was successful or not
  67904. * @hidden
  67905. */
  67906. _restoreStateValues(): boolean;
  67907. /** @hidden */
  67908. _initCache(): void;
  67909. /** @hidden */
  67910. _updateCache(ignoreParentClass?: boolean): void;
  67911. /** @hidden */
  67912. _isSynchronizedViewMatrix(): boolean;
  67913. /** @hidden */
  67914. _computeLocalCameraSpeed(): number;
  67915. /**
  67916. * Defines the target the camera should look at.
  67917. * This will automatically adapt alpha beta and radius to fit within the new target.
  67918. * @param target Defines the new target as a Vector or a mesh
  67919. */
  67920. setTarget(target: Vector3): void;
  67921. /**
  67922. * Return the current target position of the camera. This value is expressed in local space.
  67923. * @returns the target position
  67924. */
  67925. getTarget(): Vector3;
  67926. /** @hidden */
  67927. _decideIfNeedsToMove(): boolean;
  67928. /** @hidden */
  67929. _updatePosition(): void;
  67930. /** @hidden */
  67931. _checkInputs(): void;
  67932. protected _updateCameraRotationMatrix(): void;
  67933. /**
  67934. * 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)
  67935. * @returns the current camera
  67936. */
  67937. private _rotateUpVectorWithCameraRotationMatrix;
  67938. private _cachedRotationZ;
  67939. private _cachedQuaternionRotationZ;
  67940. /** @hidden */
  67941. _getViewMatrix(): Matrix;
  67942. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  67943. /**
  67944. * @hidden
  67945. */
  67946. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  67947. /**
  67948. * @hidden
  67949. */
  67950. _updateRigCameras(): void;
  67951. private _getRigCamPositionAndTarget;
  67952. /**
  67953. * Gets the current object class name.
  67954. * @return the class name
  67955. */
  67956. getClassName(): string;
  67957. }
  67958. }
  67959. declare module BABYLON {
  67960. /**
  67961. * @ignore
  67962. * This is a list of all the different input types that are available in the application.
  67963. * Fo instance: ArcRotateCameraGamepadInput...
  67964. */
  67965. export var CameraInputTypes: {};
  67966. /**
  67967. * This is the contract to implement in order to create a new input class.
  67968. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  67969. */
  67970. export interface ICameraInput<TCamera extends Camera> {
  67971. /**
  67972. * Defines the camera the input is attached to.
  67973. */
  67974. camera: Nullable<TCamera>;
  67975. /**
  67976. * Gets the class name of the current intput.
  67977. * @returns the class name
  67978. */
  67979. getClassName(): string;
  67980. /**
  67981. * Get the friendly name associated with the input class.
  67982. * @returns the input friendly name
  67983. */
  67984. getSimpleName(): string;
  67985. /**
  67986. * Attach the input controls to a specific dom element to get the input from.
  67987. * @param element Defines the element the controls should be listened from
  67988. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  67989. */
  67990. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  67991. /**
  67992. * Detach the current controls from the specified dom element.
  67993. * @param element Defines the element to stop listening the inputs from
  67994. */
  67995. detachControl(element: Nullable<HTMLElement>): void;
  67996. /**
  67997. * Update the current camera state depending on the inputs that have been used this frame.
  67998. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  67999. */
  68000. checkInputs?: () => void;
  68001. }
  68002. /**
  68003. * Represents a map of input types to input instance or input index to input instance.
  68004. */
  68005. export interface CameraInputsMap<TCamera extends Camera> {
  68006. /**
  68007. * Accessor to the input by input type.
  68008. */
  68009. [name: string]: ICameraInput<TCamera>;
  68010. /**
  68011. * Accessor to the input by input index.
  68012. */
  68013. [idx: number]: ICameraInput<TCamera>;
  68014. }
  68015. /**
  68016. * This represents the input manager used within a camera.
  68017. * It helps dealing with all the different kind of input attached to a camera.
  68018. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  68019. */
  68020. export class CameraInputsManager<TCamera extends Camera> {
  68021. /**
  68022. * Defines the list of inputs attahed to the camera.
  68023. */
  68024. attached: CameraInputsMap<TCamera>;
  68025. /**
  68026. * Defines the dom element the camera is collecting inputs from.
  68027. * This is null if the controls have not been attached.
  68028. */
  68029. attachedElement: Nullable<HTMLElement>;
  68030. /**
  68031. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  68032. */
  68033. noPreventDefault: boolean;
  68034. /**
  68035. * Defined the camera the input manager belongs to.
  68036. */
  68037. camera: TCamera;
  68038. /**
  68039. * Update the current camera state depending on the inputs that have been used this frame.
  68040. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  68041. */
  68042. checkInputs: () => void;
  68043. /**
  68044. * Instantiate a new Camera Input Manager.
  68045. * @param camera Defines the camera the input manager blongs to
  68046. */
  68047. constructor(camera: TCamera);
  68048. /**
  68049. * Add an input method to a camera
  68050. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  68051. * @param input camera input method
  68052. */
  68053. add(input: ICameraInput<TCamera>): void;
  68054. /**
  68055. * Remove a specific input method from a camera
  68056. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  68057. * @param inputToRemove camera input method
  68058. */
  68059. remove(inputToRemove: ICameraInput<TCamera>): void;
  68060. /**
  68061. * Remove a specific input type from a camera
  68062. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  68063. * @param inputType the type of the input to remove
  68064. */
  68065. removeByType(inputType: string): void;
  68066. private _addCheckInputs;
  68067. /**
  68068. * Attach the input controls to the currently attached dom element to listen the events from.
  68069. * @param input Defines the input to attach
  68070. */
  68071. attachInput(input: ICameraInput<TCamera>): void;
  68072. /**
  68073. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  68074. * @param element Defines the dom element to collect the events from
  68075. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  68076. */
  68077. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  68078. /**
  68079. * Detach the current manager inputs controls from a specific dom element.
  68080. * @param element Defines the dom element to collect the events from
  68081. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  68082. */
  68083. detachElement(element: HTMLElement, disconnect?: boolean): void;
  68084. /**
  68085. * Rebuild the dynamic inputCheck function from the current list of
  68086. * defined inputs in the manager.
  68087. */
  68088. rebuildInputCheck(): void;
  68089. /**
  68090. * Remove all attached input methods from a camera
  68091. */
  68092. clear(): void;
  68093. /**
  68094. * Serialize the current input manager attached to a camera.
  68095. * This ensures than once parsed,
  68096. * the input associated to the camera will be identical to the current ones
  68097. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  68098. */
  68099. serialize(serializedCamera: any): void;
  68100. /**
  68101. * Parses an input manager serialized JSON to restore the previous list of inputs
  68102. * and states associated to a camera.
  68103. * @param parsedCamera Defines the JSON to parse
  68104. */
  68105. parse(parsedCamera: any): void;
  68106. }
  68107. }
  68108. declare module BABYLON {
  68109. /**
  68110. * Gather the list of keyboard event types as constants.
  68111. */
  68112. export class KeyboardEventTypes {
  68113. /**
  68114. * The keydown event is fired when a key becomes active (pressed).
  68115. */
  68116. static readonly KEYDOWN: number;
  68117. /**
  68118. * The keyup event is fired when a key has been released.
  68119. */
  68120. static readonly KEYUP: number;
  68121. }
  68122. /**
  68123. * This class is used to store keyboard related info for the onKeyboardObservable event.
  68124. */
  68125. export class KeyboardInfo {
  68126. /**
  68127. * Defines the type of event (KeyboardEventTypes)
  68128. */
  68129. type: number;
  68130. /**
  68131. * Defines the related dom event
  68132. */
  68133. event: KeyboardEvent;
  68134. /**
  68135. * Instantiates a new keyboard info.
  68136. * This class is used to store keyboard related info for the onKeyboardObservable event.
  68137. * @param type Defines the type of event (KeyboardEventTypes)
  68138. * @param event Defines the related dom event
  68139. */
  68140. constructor(
  68141. /**
  68142. * Defines the type of event (KeyboardEventTypes)
  68143. */
  68144. type: number,
  68145. /**
  68146. * Defines the related dom event
  68147. */
  68148. event: KeyboardEvent);
  68149. }
  68150. /**
  68151. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  68152. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  68153. */
  68154. export class KeyboardInfoPre extends KeyboardInfo {
  68155. /**
  68156. * Defines the type of event (KeyboardEventTypes)
  68157. */
  68158. type: number;
  68159. /**
  68160. * Defines the related dom event
  68161. */
  68162. event: KeyboardEvent;
  68163. /**
  68164. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  68165. */
  68166. skipOnPointerObservable: boolean;
  68167. /**
  68168. * Instantiates a new keyboard pre info.
  68169. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  68170. * @param type Defines the type of event (KeyboardEventTypes)
  68171. * @param event Defines the related dom event
  68172. */
  68173. constructor(
  68174. /**
  68175. * Defines the type of event (KeyboardEventTypes)
  68176. */
  68177. type: number,
  68178. /**
  68179. * Defines the related dom event
  68180. */
  68181. event: KeyboardEvent);
  68182. }
  68183. }
  68184. declare module BABYLON {
  68185. /**
  68186. * Manage the keyboard inputs to control the movement of a free camera.
  68187. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  68188. */
  68189. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  68190. /**
  68191. * Defines the camera the input is attached to.
  68192. */
  68193. camera: FreeCamera;
  68194. /**
  68195. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  68196. */
  68197. keysUp: number[];
  68198. /**
  68199. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  68200. */
  68201. keysDown: number[];
  68202. /**
  68203. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  68204. */
  68205. keysLeft: number[];
  68206. /**
  68207. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  68208. */
  68209. keysRight: number[];
  68210. private _keys;
  68211. private _onCanvasBlurObserver;
  68212. private _onKeyboardObserver;
  68213. private _engine;
  68214. private _scene;
  68215. /**
  68216. * Attach the input controls to a specific dom element to get the input from.
  68217. * @param element Defines the element the controls should be listened from
  68218. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  68219. */
  68220. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  68221. /**
  68222. * Detach the current controls from the specified dom element.
  68223. * @param element Defines the element to stop listening the inputs from
  68224. */
  68225. detachControl(element: Nullable<HTMLElement>): void;
  68226. /**
  68227. * Update the current camera state depending on the inputs that have been used this frame.
  68228. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  68229. */
  68230. checkInputs(): void;
  68231. /**
  68232. * Gets the class name of the current intput.
  68233. * @returns the class name
  68234. */
  68235. getClassName(): string;
  68236. /** @hidden */
  68237. _onLostFocus(): void;
  68238. /**
  68239. * Get the friendly name associated with the input class.
  68240. * @returns the input friendly name
  68241. */
  68242. getSimpleName(): string;
  68243. }
  68244. }
  68245. declare module BABYLON {
  68246. /**
  68247. * Interface describing all the common properties and methods a shadow light needs to implement.
  68248. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  68249. * as well as binding the different shadow properties to the effects.
  68250. */
  68251. export interface IShadowLight extends Light {
  68252. /**
  68253. * The light id in the scene (used in scene.findLighById for instance)
  68254. */
  68255. id: string;
  68256. /**
  68257. * The position the shdow will be casted from.
  68258. */
  68259. position: Vector3;
  68260. /**
  68261. * In 2d mode (needCube being false), the direction used to cast the shadow.
  68262. */
  68263. direction: Vector3;
  68264. /**
  68265. * The transformed position. Position of the light in world space taking parenting in account.
  68266. */
  68267. transformedPosition: Vector3;
  68268. /**
  68269. * The transformed direction. Direction of the light in world space taking parenting in account.
  68270. */
  68271. transformedDirection: Vector3;
  68272. /**
  68273. * The friendly name of the light in the scene.
  68274. */
  68275. name: string;
  68276. /**
  68277. * Defines the shadow projection clipping minimum z value.
  68278. */
  68279. shadowMinZ: number;
  68280. /**
  68281. * Defines the shadow projection clipping maximum z value.
  68282. */
  68283. shadowMaxZ: number;
  68284. /**
  68285. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  68286. * @returns true if the information has been computed, false if it does not need to (no parenting)
  68287. */
  68288. computeTransformedInformation(): boolean;
  68289. /**
  68290. * Gets the scene the light belongs to.
  68291. * @returns The scene
  68292. */
  68293. getScene(): Scene;
  68294. /**
  68295. * Callback defining a custom Projection Matrix Builder.
  68296. * This can be used to override the default projection matrix computation.
  68297. */
  68298. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  68299. /**
  68300. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  68301. * @param matrix The materix to updated with the projection information
  68302. * @param viewMatrix The transform matrix of the light
  68303. * @param renderList The list of mesh to render in the map
  68304. * @returns The current light
  68305. */
  68306. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  68307. /**
  68308. * Gets the current depth scale used in ESM.
  68309. * @returns The scale
  68310. */
  68311. getDepthScale(): number;
  68312. /**
  68313. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  68314. * @returns true if a cube texture needs to be use
  68315. */
  68316. needCube(): boolean;
  68317. /**
  68318. * Detects if the projection matrix requires to be recomputed this frame.
  68319. * @returns true if it requires to be recomputed otherwise, false.
  68320. */
  68321. needProjectionMatrixCompute(): boolean;
  68322. /**
  68323. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  68324. */
  68325. forceProjectionMatrixCompute(): void;
  68326. /**
  68327. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  68328. * @param faceIndex The index of the face we are computed the direction to generate shadow
  68329. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  68330. */
  68331. getShadowDirection(faceIndex?: number): Vector3;
  68332. /**
  68333. * Gets the minZ used for shadow according to both the scene and the light.
  68334. * @param activeCamera The camera we are returning the min for
  68335. * @returns the depth min z
  68336. */
  68337. getDepthMinZ(activeCamera: Camera): number;
  68338. /**
  68339. * Gets the maxZ used for shadow according to both the scene and the light.
  68340. * @param activeCamera The camera we are returning the max for
  68341. * @returns the depth max z
  68342. */
  68343. getDepthMaxZ(activeCamera: Camera): number;
  68344. }
  68345. /**
  68346. * Base implementation IShadowLight
  68347. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  68348. */
  68349. export abstract class ShadowLight extends Light implements IShadowLight {
  68350. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  68351. protected _position: Vector3;
  68352. protected _setPosition(value: Vector3): void;
  68353. /**
  68354. * Sets the position the shadow will be casted from. Also use as the light position for both
  68355. * point and spot lights.
  68356. */
  68357. /**
  68358. * Sets the position the shadow will be casted from. Also use as the light position for both
  68359. * point and spot lights.
  68360. */
  68361. position: Vector3;
  68362. protected _direction: Vector3;
  68363. protected _setDirection(value: Vector3): void;
  68364. /**
  68365. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  68366. * Also use as the light direction on spot and directional lights.
  68367. */
  68368. /**
  68369. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  68370. * Also use as the light direction on spot and directional lights.
  68371. */
  68372. direction: Vector3;
  68373. private _shadowMinZ;
  68374. /**
  68375. * Gets the shadow projection clipping minimum z value.
  68376. */
  68377. /**
  68378. * Sets the shadow projection clipping minimum z value.
  68379. */
  68380. shadowMinZ: number;
  68381. private _shadowMaxZ;
  68382. /**
  68383. * Sets the shadow projection clipping maximum z value.
  68384. */
  68385. /**
  68386. * Gets the shadow projection clipping maximum z value.
  68387. */
  68388. shadowMaxZ: number;
  68389. /**
  68390. * Callback defining a custom Projection Matrix Builder.
  68391. * This can be used to override the default projection matrix computation.
  68392. */
  68393. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  68394. /**
  68395. * The transformed position. Position of the light in world space taking parenting in account.
  68396. */
  68397. transformedPosition: Vector3;
  68398. /**
  68399. * The transformed direction. Direction of the light in world space taking parenting in account.
  68400. */
  68401. transformedDirection: Vector3;
  68402. private _needProjectionMatrixCompute;
  68403. /**
  68404. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  68405. * @returns true if the information has been computed, false if it does not need to (no parenting)
  68406. */
  68407. computeTransformedInformation(): boolean;
  68408. /**
  68409. * Return the depth scale used for the shadow map.
  68410. * @returns the depth scale.
  68411. */
  68412. getDepthScale(): number;
  68413. /**
  68414. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  68415. * @param faceIndex The index of the face we are computed the direction to generate shadow
  68416. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  68417. */
  68418. getShadowDirection(faceIndex?: number): Vector3;
  68419. /**
  68420. * Returns the ShadowLight absolute position in the World.
  68421. * @returns the position vector in world space
  68422. */
  68423. getAbsolutePosition(): Vector3;
  68424. /**
  68425. * Sets the ShadowLight direction toward the passed target.
  68426. * @param target The point to target in local space
  68427. * @returns the updated ShadowLight direction
  68428. */
  68429. setDirectionToTarget(target: Vector3): Vector3;
  68430. /**
  68431. * Returns the light rotation in euler definition.
  68432. * @returns the x y z rotation in local space.
  68433. */
  68434. getRotation(): Vector3;
  68435. /**
  68436. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  68437. * @returns true if a cube texture needs to be use
  68438. */
  68439. needCube(): boolean;
  68440. /**
  68441. * Detects if the projection matrix requires to be recomputed this frame.
  68442. * @returns true if it requires to be recomputed otherwise, false.
  68443. */
  68444. needProjectionMatrixCompute(): boolean;
  68445. /**
  68446. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  68447. */
  68448. forceProjectionMatrixCompute(): void;
  68449. /** @hidden */
  68450. _initCache(): void;
  68451. /** @hidden */
  68452. _isSynchronized(): boolean;
  68453. /**
  68454. * Computes the world matrix of the node
  68455. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  68456. * @returns the world matrix
  68457. */
  68458. computeWorldMatrix(force?: boolean): Matrix;
  68459. /**
  68460. * Gets the minZ used for shadow according to both the scene and the light.
  68461. * @param activeCamera The camera we are returning the min for
  68462. * @returns the depth min z
  68463. */
  68464. getDepthMinZ(activeCamera: Camera): number;
  68465. /**
  68466. * Gets the maxZ used for shadow according to both the scene and the light.
  68467. * @param activeCamera The camera we are returning the max for
  68468. * @returns the depth max z
  68469. */
  68470. getDepthMaxZ(activeCamera: Camera): number;
  68471. /**
  68472. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  68473. * @param matrix The materix to updated with the projection information
  68474. * @param viewMatrix The transform matrix of the light
  68475. * @param renderList The list of mesh to render in the map
  68476. * @returns The current light
  68477. */
  68478. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  68479. }
  68480. }
  68481. declare module BABYLON {
  68482. /**
  68483. * "Static Class" containing the most commonly used helper while dealing with material for
  68484. * rendering purpose.
  68485. *
  68486. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  68487. *
  68488. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  68489. */
  68490. export class MaterialHelper {
  68491. /**
  68492. * Bind the current view position to an effect.
  68493. * @param effect The effect to be bound
  68494. * @param scene The scene the eyes position is used from
  68495. */
  68496. static BindEyePosition(effect: Effect, scene: Scene): void;
  68497. /**
  68498. * Helps preparing the defines values about the UVs in used in the effect.
  68499. * UVs are shared as much as we can accross channels in the shaders.
  68500. * @param texture The texture we are preparing the UVs for
  68501. * @param defines The defines to update
  68502. * @param key The channel key "diffuse", "specular"... used in the shader
  68503. */
  68504. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  68505. /**
  68506. * Binds a texture matrix value to its corrsponding uniform
  68507. * @param texture The texture to bind the matrix for
  68508. * @param uniformBuffer The uniform buffer receivin the data
  68509. * @param key The channel key "diffuse", "specular"... used in the shader
  68510. */
  68511. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  68512. /**
  68513. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  68514. * @param mesh defines the current mesh
  68515. * @param scene defines the current scene
  68516. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  68517. * @param pointsCloud defines if point cloud rendering has to be turned on
  68518. * @param fogEnabled defines if fog has to be turned on
  68519. * @param alphaTest defines if alpha testing has to be turned on
  68520. * @param defines defines the current list of defines
  68521. */
  68522. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  68523. /**
  68524. * Helper used to prepare the list of defines associated with frame values for shader compilation
  68525. * @param scene defines the current scene
  68526. * @param engine defines the current engine
  68527. * @param defines specifies the list of active defines
  68528. * @param useInstances defines if instances have to be turned on
  68529. * @param useClipPlane defines if clip plane have to be turned on
  68530. */
  68531. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  68532. /**
  68533. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  68534. * @param mesh The mesh containing the geometry data we will draw
  68535. * @param defines The defines to update
  68536. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  68537. * @param useBones Precise whether bones should be used or not (override mesh info)
  68538. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  68539. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  68540. * @returns false if defines are considered not dirty and have not been checked
  68541. */
  68542. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  68543. /**
  68544. * Prepares the defines related to multiview
  68545. * @param scene The scene we are intending to draw
  68546. * @param defines The defines to update
  68547. */
  68548. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  68549. /**
  68550. * Prepares the defines related to the light information passed in parameter
  68551. * @param scene The scene we are intending to draw
  68552. * @param mesh The mesh the effect is compiling for
  68553. * @param defines The defines to update
  68554. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  68555. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  68556. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  68557. * @returns true if normals will be required for the rest of the effect
  68558. */
  68559. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  68560. /**
  68561. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  68562. * that won t be acctive due to defines being turned off.
  68563. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  68564. * @param samplersList The samplers list
  68565. * @param defines The defines helping in the list generation
  68566. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  68567. */
  68568. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  68569. /**
  68570. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  68571. * @param defines The defines to update while falling back
  68572. * @param fallbacks The authorized effect fallbacks
  68573. * @param maxSimultaneousLights The maximum number of lights allowed
  68574. * @param rank the current rank of the Effect
  68575. * @returns The newly affected rank
  68576. */
  68577. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  68578. /**
  68579. * Prepares the list of attributes required for morph targets according to the effect defines.
  68580. * @param attribs The current list of supported attribs
  68581. * @param mesh The mesh to prepare the morph targets attributes for
  68582. * @param defines The current Defines of the effect
  68583. */
  68584. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  68585. /**
  68586. * Prepares the list of attributes required for bones according to the effect defines.
  68587. * @param attribs The current list of supported attribs
  68588. * @param mesh The mesh to prepare the bones attributes for
  68589. * @param defines The current Defines of the effect
  68590. * @param fallbacks The current efffect fallback strategy
  68591. */
  68592. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  68593. /**
  68594. * Prepares the list of attributes required for instances according to the effect defines.
  68595. * @param attribs The current list of supported attribs
  68596. * @param defines The current Defines of the effect
  68597. */
  68598. static PrepareAttributesForInstances(attribs: string[], defines: any): void;
  68599. /**
  68600. * Binds the light shadow information to the effect for the given mesh.
  68601. * @param light The light containing the generator
  68602. * @param scene The scene the lights belongs to
  68603. * @param mesh The mesh we are binding the information to render
  68604. * @param lightIndex The light index in the effect used to render the mesh
  68605. * @param effect The effect we are binding the data to
  68606. */
  68607. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  68608. /**
  68609. * Binds the light information to the effect.
  68610. * @param light The light containing the generator
  68611. * @param effect The effect we are binding the data to
  68612. * @param lightIndex The light index in the effect used to render
  68613. */
  68614. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  68615. /**
  68616. * Binds the lights information from the scene to the effect for the given mesh.
  68617. * @param scene The scene the lights belongs to
  68618. * @param mesh The mesh we are binding the information to render
  68619. * @param effect The effect we are binding the data to
  68620. * @param defines The generated defines for the effect
  68621. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  68622. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  68623. */
  68624. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  68625. private static _tempFogColor;
  68626. /**
  68627. * Binds the fog information from the scene to the effect for the given mesh.
  68628. * @param scene The scene the lights belongs to
  68629. * @param mesh The mesh we are binding the information to render
  68630. * @param effect The effect we are binding the data to
  68631. * @param linearSpace Defines if the fog effect is applied in linear space
  68632. */
  68633. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  68634. /**
  68635. * Binds the bones information from the mesh to the effect.
  68636. * @param mesh The mesh we are binding the information to render
  68637. * @param effect The effect we are binding the data to
  68638. */
  68639. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  68640. /**
  68641. * Binds the morph targets information from the mesh to the effect.
  68642. * @param abstractMesh The mesh we are binding the information to render
  68643. * @param effect The effect we are binding the data to
  68644. */
  68645. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  68646. /**
  68647. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  68648. * @param defines The generated defines used in the effect
  68649. * @param effect The effect we are binding the data to
  68650. * @param scene The scene we are willing to render with logarithmic scale for
  68651. */
  68652. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  68653. /**
  68654. * Binds the clip plane information from the scene to the effect.
  68655. * @param scene The scene the clip plane information are extracted from
  68656. * @param effect The effect we are binding the data to
  68657. */
  68658. static BindClipPlane(effect: Effect, scene: Scene): void;
  68659. }
  68660. }
  68661. declare module BABYLON {
  68662. /** @hidden */
  68663. export var kernelBlurVaryingDeclaration: {
  68664. name: string;
  68665. shader: string;
  68666. };
  68667. }
  68668. declare module BABYLON {
  68669. /** @hidden */
  68670. export var kernelBlurFragment: {
  68671. name: string;
  68672. shader: string;
  68673. };
  68674. }
  68675. declare module BABYLON {
  68676. /** @hidden */
  68677. export var kernelBlurFragment2: {
  68678. name: string;
  68679. shader: string;
  68680. };
  68681. }
  68682. declare module BABYLON {
  68683. /** @hidden */
  68684. export var kernelBlurPixelShader: {
  68685. name: string;
  68686. shader: string;
  68687. };
  68688. }
  68689. declare module BABYLON {
  68690. /** @hidden */
  68691. export var kernelBlurVertex: {
  68692. name: string;
  68693. shader: string;
  68694. };
  68695. }
  68696. declare module BABYLON {
  68697. /** @hidden */
  68698. export var kernelBlurVertexShader: {
  68699. name: string;
  68700. shader: string;
  68701. };
  68702. }
  68703. declare module BABYLON {
  68704. /**
  68705. * The Blur Post Process which blurs an image based on a kernel and direction.
  68706. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  68707. */
  68708. export class BlurPostProcess extends PostProcess {
  68709. /** The direction in which to blur the image. */
  68710. direction: Vector2;
  68711. private blockCompilation;
  68712. protected _kernel: number;
  68713. protected _idealKernel: number;
  68714. protected _packedFloat: boolean;
  68715. private _staticDefines;
  68716. /**
  68717. * Sets the length in pixels of the blur sample region
  68718. */
  68719. /**
  68720. * Gets the length in pixels of the blur sample region
  68721. */
  68722. kernel: number;
  68723. /**
  68724. * Sets wether or not the blur needs to unpack/repack floats
  68725. */
  68726. /**
  68727. * Gets wether or not the blur is unpacking/repacking floats
  68728. */
  68729. packedFloat: boolean;
  68730. /**
  68731. * Creates a new instance BlurPostProcess
  68732. * @param name The name of the effect.
  68733. * @param direction The direction in which to blur the image.
  68734. * @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.
  68735. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  68736. * @param camera The camera to apply the render pass to.
  68737. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68738. * @param engine The engine which the post process will be applied. (default: current engine)
  68739. * @param reusable If the post process can be reused on the same frame. (default: false)
  68740. * @param textureType Type of textures used when performing the post process. (default: 0)
  68741. * @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)
  68742. */
  68743. constructor(name: string,
  68744. /** The direction in which to blur the image. */
  68745. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  68746. /**
  68747. * Updates the effect with the current post process compile time values and recompiles the shader.
  68748. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  68749. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  68750. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  68751. * @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
  68752. * @param onCompiled Called when the shader has been compiled.
  68753. * @param onError Called if there is an error when compiling a shader.
  68754. */
  68755. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  68756. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  68757. /**
  68758. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  68759. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  68760. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  68761. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  68762. * The gaps between physical kernels are compensated for in the weighting of the samples
  68763. * @param idealKernel Ideal blur kernel.
  68764. * @return Nearest best kernel.
  68765. */
  68766. protected _nearestBestKernel(idealKernel: number): number;
  68767. /**
  68768. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  68769. * @param x The point on the Gaussian distribution to sample.
  68770. * @return the value of the Gaussian function at x.
  68771. */
  68772. protected _gaussianWeight(x: number): number;
  68773. /**
  68774. * Generates a string that can be used as a floating point number in GLSL.
  68775. * @param x Value to print.
  68776. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  68777. * @return GLSL float string.
  68778. */
  68779. protected _glslFloat(x: number, decimalFigures?: number): string;
  68780. }
  68781. }
  68782. declare module BABYLON {
  68783. /** @hidden */
  68784. export var shadowMapPixelShader: {
  68785. name: string;
  68786. shader: string;
  68787. };
  68788. }
  68789. declare module BABYLON {
  68790. /** @hidden */
  68791. export var bonesDeclaration: {
  68792. name: string;
  68793. shader: string;
  68794. };
  68795. }
  68796. declare module BABYLON {
  68797. /** @hidden */
  68798. export var morphTargetsVertexGlobalDeclaration: {
  68799. name: string;
  68800. shader: string;
  68801. };
  68802. }
  68803. declare module BABYLON {
  68804. /** @hidden */
  68805. export var morphTargetsVertexDeclaration: {
  68806. name: string;
  68807. shader: string;
  68808. };
  68809. }
  68810. declare module BABYLON {
  68811. /** @hidden */
  68812. export var instancesDeclaration: {
  68813. name: string;
  68814. shader: string;
  68815. };
  68816. }
  68817. declare module BABYLON {
  68818. /** @hidden */
  68819. export var helperFunctions: {
  68820. name: string;
  68821. shader: string;
  68822. };
  68823. }
  68824. declare module BABYLON {
  68825. /** @hidden */
  68826. export var morphTargetsVertex: {
  68827. name: string;
  68828. shader: string;
  68829. };
  68830. }
  68831. declare module BABYLON {
  68832. /** @hidden */
  68833. export var instancesVertex: {
  68834. name: string;
  68835. shader: string;
  68836. };
  68837. }
  68838. declare module BABYLON {
  68839. /** @hidden */
  68840. export var bonesVertex: {
  68841. name: string;
  68842. shader: string;
  68843. };
  68844. }
  68845. declare module BABYLON {
  68846. /** @hidden */
  68847. export var shadowMapVertexShader: {
  68848. name: string;
  68849. shader: string;
  68850. };
  68851. }
  68852. declare module BABYLON {
  68853. /** @hidden */
  68854. export var depthBoxBlurPixelShader: {
  68855. name: string;
  68856. shader: string;
  68857. };
  68858. }
  68859. declare module BABYLON {
  68860. /**
  68861. * Defines the options associated with the creation of a custom shader for a shadow generator.
  68862. */
  68863. export interface ICustomShaderOptions {
  68864. /**
  68865. * Gets or sets the custom shader name to use
  68866. */
  68867. shaderName: string;
  68868. /**
  68869. * The list of attribute names used in the shader
  68870. */
  68871. attributes?: string[];
  68872. /**
  68873. * The list of unifrom names used in the shader
  68874. */
  68875. uniforms?: string[];
  68876. /**
  68877. * The list of sampler names used in the shader
  68878. */
  68879. samplers?: string[];
  68880. /**
  68881. * The list of defines used in the shader
  68882. */
  68883. defines?: string[];
  68884. }
  68885. /**
  68886. * Interface to implement to create a shadow generator compatible with BJS.
  68887. */
  68888. export interface IShadowGenerator {
  68889. /**
  68890. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  68891. * @returns The render target texture if present otherwise, null
  68892. */
  68893. getShadowMap(): Nullable<RenderTargetTexture>;
  68894. /**
  68895. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  68896. * @returns The render target texture if the shadow map is present otherwise, null
  68897. */
  68898. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  68899. /**
  68900. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  68901. * @param subMesh The submesh we want to render in the shadow map
  68902. * @param useInstances Defines wether will draw in the map using instances
  68903. * @returns true if ready otherwise, false
  68904. */
  68905. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  68906. /**
  68907. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  68908. * @param defines Defines of the material we want to update
  68909. * @param lightIndex Index of the light in the enabled light list of the material
  68910. */
  68911. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  68912. /**
  68913. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  68914. * defined in the generator but impacting the effect).
  68915. * It implies the unifroms available on the materials are the standard BJS ones.
  68916. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  68917. * @param effect The effect we are binfing the information for
  68918. */
  68919. bindShadowLight(lightIndex: string, effect: Effect): void;
  68920. /**
  68921. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  68922. * (eq to shadow prjection matrix * light transform matrix)
  68923. * @returns The transform matrix used to create the shadow map
  68924. */
  68925. getTransformMatrix(): Matrix;
  68926. /**
  68927. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  68928. * Cube and 2D textures for instance.
  68929. */
  68930. recreateShadowMap(): void;
  68931. /**
  68932. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  68933. * @param onCompiled Callback triggered at the and of the effects compilation
  68934. * @param options Sets of optional options forcing the compilation with different modes
  68935. */
  68936. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  68937. useInstances: boolean;
  68938. }>): void;
  68939. /**
  68940. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  68941. * @param options Sets of optional options forcing the compilation with different modes
  68942. * @returns A promise that resolves when the compilation completes
  68943. */
  68944. forceCompilationAsync(options?: Partial<{
  68945. useInstances: boolean;
  68946. }>): Promise<void>;
  68947. /**
  68948. * Serializes the shadow generator setup to a json object.
  68949. * @returns The serialized JSON object
  68950. */
  68951. serialize(): any;
  68952. /**
  68953. * Disposes the Shadow map and related Textures and effects.
  68954. */
  68955. dispose(): void;
  68956. }
  68957. /**
  68958. * Default implementation IShadowGenerator.
  68959. * This is the main object responsible of generating shadows in the framework.
  68960. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  68961. */
  68962. export class ShadowGenerator implements IShadowGenerator {
  68963. /**
  68964. * Shadow generator mode None: no filtering applied.
  68965. */
  68966. static readonly FILTER_NONE: number;
  68967. /**
  68968. * Shadow generator mode ESM: Exponential Shadow Mapping.
  68969. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  68970. */
  68971. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  68972. /**
  68973. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  68974. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  68975. */
  68976. static readonly FILTER_POISSONSAMPLING: number;
  68977. /**
  68978. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  68979. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  68980. */
  68981. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  68982. /**
  68983. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  68984. * edge artifacts on steep falloff.
  68985. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  68986. */
  68987. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  68988. /**
  68989. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  68990. * edge artifacts on steep falloff.
  68991. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  68992. */
  68993. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  68994. /**
  68995. * Shadow generator mode PCF: Percentage Closer Filtering
  68996. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  68997. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  68998. */
  68999. static readonly FILTER_PCF: number;
  69000. /**
  69001. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  69002. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  69003. * Contact Hardening
  69004. */
  69005. static readonly FILTER_PCSS: number;
  69006. /**
  69007. * Reserved for PCF and PCSS
  69008. * Highest Quality.
  69009. *
  69010. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  69011. *
  69012. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  69013. */
  69014. static readonly QUALITY_HIGH: number;
  69015. /**
  69016. * Reserved for PCF and PCSS
  69017. * Good tradeoff for quality/perf cross devices
  69018. *
  69019. * Execute PCF on a 3*3 kernel.
  69020. *
  69021. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  69022. */
  69023. static readonly QUALITY_MEDIUM: number;
  69024. /**
  69025. * Reserved for PCF and PCSS
  69026. * The lowest quality but the fastest.
  69027. *
  69028. * Execute PCF on a 1*1 kernel.
  69029. *
  69030. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  69031. */
  69032. static readonly QUALITY_LOW: number;
  69033. /** Gets or sets the custom shader name to use */
  69034. customShaderOptions: ICustomShaderOptions;
  69035. /**
  69036. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  69037. */
  69038. onBeforeShadowMapRenderObservable: Observable<Effect>;
  69039. /**
  69040. * Observable triggered before a mesh is rendered in the shadow map.
  69041. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  69042. */
  69043. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  69044. private _bias;
  69045. /**
  69046. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  69047. */
  69048. /**
  69049. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  69050. */
  69051. bias: number;
  69052. private _normalBias;
  69053. /**
  69054. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  69055. */
  69056. /**
  69057. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  69058. */
  69059. normalBias: number;
  69060. private _blurBoxOffset;
  69061. /**
  69062. * Gets the blur box offset: offset applied during the blur pass.
  69063. * Only useful if useKernelBlur = false
  69064. */
  69065. /**
  69066. * Sets the blur box offset: offset applied during the blur pass.
  69067. * Only useful if useKernelBlur = false
  69068. */
  69069. blurBoxOffset: number;
  69070. private _blurScale;
  69071. /**
  69072. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  69073. * 2 means half of the size.
  69074. */
  69075. /**
  69076. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  69077. * 2 means half of the size.
  69078. */
  69079. blurScale: number;
  69080. private _blurKernel;
  69081. /**
  69082. * Gets the blur kernel: kernel size of the blur pass.
  69083. * Only useful if useKernelBlur = true
  69084. */
  69085. /**
  69086. * Sets the blur kernel: kernel size of the blur pass.
  69087. * Only useful if useKernelBlur = true
  69088. */
  69089. blurKernel: number;
  69090. private _useKernelBlur;
  69091. /**
  69092. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  69093. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  69094. */
  69095. /**
  69096. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  69097. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  69098. */
  69099. useKernelBlur: boolean;
  69100. private _depthScale;
  69101. /**
  69102. * Gets the depth scale used in ESM mode.
  69103. */
  69104. /**
  69105. * Sets the depth scale used in ESM mode.
  69106. * This can override the scale stored on the light.
  69107. */
  69108. depthScale: number;
  69109. private _filter;
  69110. /**
  69111. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  69112. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  69113. */
  69114. /**
  69115. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  69116. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  69117. */
  69118. filter: number;
  69119. /**
  69120. * Gets if the current filter is set to Poisson Sampling.
  69121. */
  69122. /**
  69123. * Sets the current filter to Poisson Sampling.
  69124. */
  69125. usePoissonSampling: boolean;
  69126. /**
  69127. * Gets if the current filter is set to ESM.
  69128. */
  69129. /**
  69130. * Sets the current filter is to ESM.
  69131. */
  69132. useExponentialShadowMap: boolean;
  69133. /**
  69134. * Gets if the current filter is set to filtered ESM.
  69135. */
  69136. /**
  69137. * Gets if the current filter is set to filtered ESM.
  69138. */
  69139. useBlurExponentialShadowMap: boolean;
  69140. /**
  69141. * Gets if the current filter is set to "close ESM" (using the inverse of the
  69142. * exponential to prevent steep falloff artifacts).
  69143. */
  69144. /**
  69145. * Sets the current filter to "close ESM" (using the inverse of the
  69146. * exponential to prevent steep falloff artifacts).
  69147. */
  69148. useCloseExponentialShadowMap: boolean;
  69149. /**
  69150. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  69151. * exponential to prevent steep falloff artifacts).
  69152. */
  69153. /**
  69154. * Sets the current filter to filtered "close ESM" (using the inverse of the
  69155. * exponential to prevent steep falloff artifacts).
  69156. */
  69157. useBlurCloseExponentialShadowMap: boolean;
  69158. /**
  69159. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  69160. */
  69161. /**
  69162. * Sets the current filter to "PCF" (percentage closer filtering).
  69163. */
  69164. usePercentageCloserFiltering: boolean;
  69165. private _filteringQuality;
  69166. /**
  69167. * Gets the PCF or PCSS Quality.
  69168. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  69169. */
  69170. /**
  69171. * Sets the PCF or PCSS Quality.
  69172. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  69173. */
  69174. filteringQuality: number;
  69175. /**
  69176. * Gets if the current filter is set to "PCSS" (contact hardening).
  69177. */
  69178. /**
  69179. * Sets the current filter to "PCSS" (contact hardening).
  69180. */
  69181. useContactHardeningShadow: boolean;
  69182. private _contactHardeningLightSizeUVRatio;
  69183. /**
  69184. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  69185. * Using a ratio helps keeping shape stability independently of the map size.
  69186. *
  69187. * It does not account for the light projection as it was having too much
  69188. * instability during the light setup or during light position changes.
  69189. *
  69190. * Only valid if useContactHardeningShadow is true.
  69191. */
  69192. /**
  69193. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  69194. * Using a ratio helps keeping shape stability independently of the map size.
  69195. *
  69196. * It does not account for the light projection as it was having too much
  69197. * instability during the light setup or during light position changes.
  69198. *
  69199. * Only valid if useContactHardeningShadow is true.
  69200. */
  69201. contactHardeningLightSizeUVRatio: number;
  69202. private _darkness;
  69203. /**
  69204. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  69205. * 0 means strongest and 1 would means no shadow.
  69206. * @returns the darkness.
  69207. */
  69208. getDarkness(): number;
  69209. /**
  69210. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  69211. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  69212. * @returns the shadow generator allowing fluent coding.
  69213. */
  69214. setDarkness(darkness: number): ShadowGenerator;
  69215. private _transparencyShadow;
  69216. /**
  69217. * Sets the ability to have transparent shadow (boolean).
  69218. * @param transparent True if transparent else False
  69219. * @returns the shadow generator allowing fluent coding
  69220. */
  69221. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  69222. private _shadowMap;
  69223. private _shadowMap2;
  69224. /**
  69225. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  69226. * @returns The render target texture if present otherwise, null
  69227. */
  69228. getShadowMap(): Nullable<RenderTargetTexture>;
  69229. /**
  69230. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  69231. * @returns The render target texture if the shadow map is present otherwise, null
  69232. */
  69233. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  69234. /**
  69235. * Helper function to add a mesh and its descendants to the list of shadow casters.
  69236. * @param mesh Mesh to add
  69237. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  69238. * @returns the Shadow Generator itself
  69239. */
  69240. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  69241. /**
  69242. * Helper function to remove a mesh and its descendants from the list of shadow casters
  69243. * @param mesh Mesh to remove
  69244. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  69245. * @returns the Shadow Generator itself
  69246. */
  69247. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  69248. /**
  69249. * Controls the extent to which the shadows fade out at the edge of the frustum
  69250. * Used only by directionals and spots
  69251. */
  69252. frustumEdgeFalloff: number;
  69253. private _light;
  69254. /**
  69255. * Returns the associated light object.
  69256. * @returns the light generating the shadow
  69257. */
  69258. getLight(): IShadowLight;
  69259. /**
  69260. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  69261. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  69262. * It might on the other hand introduce peter panning.
  69263. */
  69264. forceBackFacesOnly: boolean;
  69265. private _scene;
  69266. private _lightDirection;
  69267. private _effect;
  69268. private _viewMatrix;
  69269. private _projectionMatrix;
  69270. private _transformMatrix;
  69271. private _cachedPosition;
  69272. private _cachedDirection;
  69273. private _cachedDefines;
  69274. private _currentRenderID;
  69275. private _boxBlurPostprocess;
  69276. private _kernelBlurXPostprocess;
  69277. private _kernelBlurYPostprocess;
  69278. private _blurPostProcesses;
  69279. private _mapSize;
  69280. private _currentFaceIndex;
  69281. private _currentFaceIndexCache;
  69282. private _textureType;
  69283. private _defaultTextureMatrix;
  69284. /** @hidden */
  69285. static _SceneComponentInitialization: (scene: Scene) => void;
  69286. /**
  69287. * Creates a ShadowGenerator object.
  69288. * A ShadowGenerator is the required tool to use the shadows.
  69289. * Each light casting shadows needs to use its own ShadowGenerator.
  69290. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  69291. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  69292. * @param light The light object generating the shadows.
  69293. * @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.
  69294. */
  69295. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  69296. private _initializeGenerator;
  69297. private _initializeShadowMap;
  69298. private _initializeBlurRTTAndPostProcesses;
  69299. private _renderForShadowMap;
  69300. private _renderSubMeshForShadowMap;
  69301. private _applyFilterValues;
  69302. /**
  69303. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  69304. * @param onCompiled Callback triggered at the and of the effects compilation
  69305. * @param options Sets of optional options forcing the compilation with different modes
  69306. */
  69307. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  69308. useInstances: boolean;
  69309. }>): void;
  69310. /**
  69311. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  69312. * @param options Sets of optional options forcing the compilation with different modes
  69313. * @returns A promise that resolves when the compilation completes
  69314. */
  69315. forceCompilationAsync(options?: Partial<{
  69316. useInstances: boolean;
  69317. }>): Promise<void>;
  69318. /**
  69319. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  69320. * @param subMesh The submesh we want to render in the shadow map
  69321. * @param useInstances Defines wether will draw in the map using instances
  69322. * @returns true if ready otherwise, false
  69323. */
  69324. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  69325. /**
  69326. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  69327. * @param defines Defines of the material we want to update
  69328. * @param lightIndex Index of the light in the enabled light list of the material
  69329. */
  69330. prepareDefines(defines: any, lightIndex: number): void;
  69331. /**
  69332. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  69333. * defined in the generator but impacting the effect).
  69334. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  69335. * @param effect The effect we are binfing the information for
  69336. */
  69337. bindShadowLight(lightIndex: string, effect: Effect): void;
  69338. /**
  69339. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  69340. * (eq to shadow prjection matrix * light transform matrix)
  69341. * @returns The transform matrix used to create the shadow map
  69342. */
  69343. getTransformMatrix(): Matrix;
  69344. /**
  69345. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  69346. * Cube and 2D textures for instance.
  69347. */
  69348. recreateShadowMap(): void;
  69349. private _disposeBlurPostProcesses;
  69350. private _disposeRTTandPostProcesses;
  69351. /**
  69352. * Disposes the ShadowGenerator.
  69353. * Returns nothing.
  69354. */
  69355. dispose(): void;
  69356. /**
  69357. * Serializes the shadow generator setup to a json object.
  69358. * @returns The serialized JSON object
  69359. */
  69360. serialize(): any;
  69361. /**
  69362. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  69363. * @param parsedShadowGenerator The JSON object to parse
  69364. * @param scene The scene to create the shadow map for
  69365. * @returns The parsed shadow generator
  69366. */
  69367. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  69368. }
  69369. }
  69370. declare module BABYLON {
  69371. /**
  69372. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  69373. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  69374. * 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.
  69375. */
  69376. export abstract class Light extends Node {
  69377. /**
  69378. * Falloff Default: light is falling off following the material specification:
  69379. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  69380. */
  69381. static readonly FALLOFF_DEFAULT: number;
  69382. /**
  69383. * Falloff Physical: light is falling off following the inverse squared distance law.
  69384. */
  69385. static readonly FALLOFF_PHYSICAL: number;
  69386. /**
  69387. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  69388. * to enhance interoperability with other engines.
  69389. */
  69390. static readonly FALLOFF_GLTF: number;
  69391. /**
  69392. * Falloff Standard: light is falling off like in the standard material
  69393. * to enhance interoperability with other materials.
  69394. */
  69395. static readonly FALLOFF_STANDARD: number;
  69396. /**
  69397. * If every light affecting the material is in this lightmapMode,
  69398. * material.lightmapTexture adds or multiplies
  69399. * (depends on material.useLightmapAsShadowmap)
  69400. * after every other light calculations.
  69401. */
  69402. static readonly LIGHTMAP_DEFAULT: number;
  69403. /**
  69404. * material.lightmapTexture as only diffuse lighting from this light
  69405. * adds only specular lighting from this light
  69406. * adds dynamic shadows
  69407. */
  69408. static readonly LIGHTMAP_SPECULAR: number;
  69409. /**
  69410. * material.lightmapTexture as only lighting
  69411. * no light calculation from this light
  69412. * only adds dynamic shadows from this light
  69413. */
  69414. static readonly LIGHTMAP_SHADOWSONLY: number;
  69415. /**
  69416. * Each light type uses the default quantity according to its type:
  69417. * point/spot lights use luminous intensity
  69418. * directional lights use illuminance
  69419. */
  69420. static readonly INTENSITYMODE_AUTOMATIC: number;
  69421. /**
  69422. * lumen (lm)
  69423. */
  69424. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  69425. /**
  69426. * candela (lm/sr)
  69427. */
  69428. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  69429. /**
  69430. * lux (lm/m^2)
  69431. */
  69432. static readonly INTENSITYMODE_ILLUMINANCE: number;
  69433. /**
  69434. * nit (cd/m^2)
  69435. */
  69436. static readonly INTENSITYMODE_LUMINANCE: number;
  69437. /**
  69438. * Light type const id of the point light.
  69439. */
  69440. static readonly LIGHTTYPEID_POINTLIGHT: number;
  69441. /**
  69442. * Light type const id of the directional light.
  69443. */
  69444. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  69445. /**
  69446. * Light type const id of the spot light.
  69447. */
  69448. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  69449. /**
  69450. * Light type const id of the hemispheric light.
  69451. */
  69452. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  69453. /**
  69454. * Diffuse gives the basic color to an object.
  69455. */
  69456. diffuse: Color3;
  69457. /**
  69458. * Specular produces a highlight color on an object.
  69459. * Note: This is note affecting PBR materials.
  69460. */
  69461. specular: Color3;
  69462. /**
  69463. * Defines the falloff type for this light. This lets overrriding how punctual light are
  69464. * falling off base on range or angle.
  69465. * This can be set to any values in Light.FALLOFF_x.
  69466. *
  69467. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  69468. * other types of materials.
  69469. */
  69470. falloffType: number;
  69471. /**
  69472. * Strength of the light.
  69473. * Note: By default it is define in the framework own unit.
  69474. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  69475. */
  69476. intensity: number;
  69477. private _range;
  69478. protected _inverseSquaredRange: number;
  69479. /**
  69480. * Defines how far from the source the light is impacting in scene units.
  69481. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  69482. */
  69483. /**
  69484. * Defines how far from the source the light is impacting in scene units.
  69485. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  69486. */
  69487. range: number;
  69488. /**
  69489. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  69490. * of light.
  69491. */
  69492. private _photometricScale;
  69493. private _intensityMode;
  69494. /**
  69495. * Gets the photometric scale used to interpret the intensity.
  69496. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  69497. */
  69498. /**
  69499. * Sets the photometric scale used to interpret the intensity.
  69500. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  69501. */
  69502. intensityMode: number;
  69503. private _radius;
  69504. /**
  69505. * Gets the light radius used by PBR Materials to simulate soft area lights.
  69506. */
  69507. /**
  69508. * sets the light radius used by PBR Materials to simulate soft area lights.
  69509. */
  69510. radius: number;
  69511. private _renderPriority;
  69512. /**
  69513. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  69514. * exceeding the number allowed of the materials.
  69515. */
  69516. renderPriority: number;
  69517. private _shadowEnabled;
  69518. /**
  69519. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  69520. * the current shadow generator.
  69521. */
  69522. /**
  69523. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  69524. * the current shadow generator.
  69525. */
  69526. shadowEnabled: boolean;
  69527. private _includedOnlyMeshes;
  69528. /**
  69529. * Gets the only meshes impacted by this light.
  69530. */
  69531. /**
  69532. * Sets the only meshes impacted by this light.
  69533. */
  69534. includedOnlyMeshes: AbstractMesh[];
  69535. private _excludedMeshes;
  69536. /**
  69537. * Gets the meshes not impacted by this light.
  69538. */
  69539. /**
  69540. * Sets the meshes not impacted by this light.
  69541. */
  69542. excludedMeshes: AbstractMesh[];
  69543. private _excludeWithLayerMask;
  69544. /**
  69545. * Gets the layer id use to find what meshes are not impacted by the light.
  69546. * Inactive if 0
  69547. */
  69548. /**
  69549. * Sets the layer id use to find what meshes are not impacted by the light.
  69550. * Inactive if 0
  69551. */
  69552. excludeWithLayerMask: number;
  69553. private _includeOnlyWithLayerMask;
  69554. /**
  69555. * Gets the layer id use to find what meshes are impacted by the light.
  69556. * Inactive if 0
  69557. */
  69558. /**
  69559. * Sets the layer id use to find what meshes are impacted by the light.
  69560. * Inactive if 0
  69561. */
  69562. includeOnlyWithLayerMask: number;
  69563. private _lightmapMode;
  69564. /**
  69565. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  69566. */
  69567. /**
  69568. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  69569. */
  69570. lightmapMode: number;
  69571. /**
  69572. * Shadow generator associted to the light.
  69573. * @hidden Internal use only.
  69574. */
  69575. _shadowGenerator: Nullable<IShadowGenerator>;
  69576. /**
  69577. * @hidden Internal use only.
  69578. */
  69579. _excludedMeshesIds: string[];
  69580. /**
  69581. * @hidden Internal use only.
  69582. */
  69583. _includedOnlyMeshesIds: string[];
  69584. /**
  69585. * The current light unifom buffer.
  69586. * @hidden Internal use only.
  69587. */
  69588. _uniformBuffer: UniformBuffer;
  69589. /**
  69590. * Creates a Light object in the scene.
  69591. * Documentation : https://doc.babylonjs.com/babylon101/lights
  69592. * @param name The firendly name of the light
  69593. * @param scene The scene the light belongs too
  69594. */
  69595. constructor(name: string, scene: Scene);
  69596. protected abstract _buildUniformLayout(): void;
  69597. /**
  69598. * Sets the passed Effect "effect" with the Light information.
  69599. * @param effect The effect to update
  69600. * @param lightIndex The index of the light in the effect to update
  69601. * @returns The light
  69602. */
  69603. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  69604. /**
  69605. * Returns the string "Light".
  69606. * @returns the class name
  69607. */
  69608. getClassName(): string;
  69609. /** @hidden */
  69610. readonly _isLight: boolean;
  69611. /**
  69612. * Converts the light information to a readable string for debug purpose.
  69613. * @param fullDetails Supports for multiple levels of logging within scene loading
  69614. * @returns the human readable light info
  69615. */
  69616. toString(fullDetails?: boolean): string;
  69617. /** @hidden */
  69618. protected _syncParentEnabledState(): void;
  69619. /**
  69620. * Set the enabled state of this node.
  69621. * @param value - the new enabled state
  69622. */
  69623. setEnabled(value: boolean): void;
  69624. /**
  69625. * Returns the Light associated shadow generator if any.
  69626. * @return the associated shadow generator.
  69627. */
  69628. getShadowGenerator(): Nullable<IShadowGenerator>;
  69629. /**
  69630. * Returns a Vector3, the absolute light position in the World.
  69631. * @returns the world space position of the light
  69632. */
  69633. getAbsolutePosition(): Vector3;
  69634. /**
  69635. * Specifies if the light will affect the passed mesh.
  69636. * @param mesh The mesh to test against the light
  69637. * @return true the mesh is affected otherwise, false.
  69638. */
  69639. canAffectMesh(mesh: AbstractMesh): boolean;
  69640. /**
  69641. * Sort function to order lights for rendering.
  69642. * @param a First Light object to compare to second.
  69643. * @param b Second Light object to compare first.
  69644. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  69645. */
  69646. static CompareLightsPriority(a: Light, b: Light): number;
  69647. /**
  69648. * Releases resources associated with this node.
  69649. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  69650. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  69651. */
  69652. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  69653. /**
  69654. * Returns the light type ID (integer).
  69655. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  69656. */
  69657. getTypeID(): number;
  69658. /**
  69659. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  69660. * @returns the scaled intensity in intensity mode unit
  69661. */
  69662. getScaledIntensity(): number;
  69663. /**
  69664. * Returns a new Light object, named "name", from the current one.
  69665. * @param name The name of the cloned light
  69666. * @returns the new created light
  69667. */
  69668. clone(name: string): Nullable<Light>;
  69669. /**
  69670. * Serializes the current light into a Serialization object.
  69671. * @returns the serialized object.
  69672. */
  69673. serialize(): any;
  69674. /**
  69675. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  69676. * This new light is named "name" and added to the passed scene.
  69677. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  69678. * @param name The friendly name of the light
  69679. * @param scene The scene the new light will belong to
  69680. * @returns the constructor function
  69681. */
  69682. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  69683. /**
  69684. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  69685. * @param parsedLight The JSON representation of the light
  69686. * @param scene The scene to create the parsed light in
  69687. * @returns the created light after parsing
  69688. */
  69689. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  69690. private _hookArrayForExcluded;
  69691. private _hookArrayForIncludedOnly;
  69692. private _resyncMeshes;
  69693. /**
  69694. * Forces the meshes to update their light related information in their rendering used effects
  69695. * @hidden Internal Use Only
  69696. */
  69697. _markMeshesAsLightDirty(): void;
  69698. /**
  69699. * Recomputes the cached photometric scale if needed.
  69700. */
  69701. private _computePhotometricScale;
  69702. /**
  69703. * Returns the Photometric Scale according to the light type and intensity mode.
  69704. */
  69705. private _getPhotometricScale;
  69706. /**
  69707. * Reorder the light in the scene according to their defined priority.
  69708. * @hidden Internal Use Only
  69709. */
  69710. _reorderLightsInScene(): void;
  69711. /**
  69712. * Prepares the list of defines specific to the light type.
  69713. * @param defines the list of defines
  69714. * @param lightIndex defines the index of the light for the effect
  69715. */
  69716. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  69717. }
  69718. }
  69719. declare module BABYLON {
  69720. /**
  69721. * Interface used to define Action
  69722. */
  69723. export interface IAction {
  69724. /**
  69725. * Trigger for the action
  69726. */
  69727. trigger: number;
  69728. /** Options of the trigger */
  69729. triggerOptions: any;
  69730. /**
  69731. * Gets the trigger parameters
  69732. * @returns the trigger parameters
  69733. */
  69734. getTriggerParameter(): any;
  69735. /**
  69736. * Internal only - executes current action event
  69737. * @hidden
  69738. */
  69739. _executeCurrent(evt?: ActionEvent): void;
  69740. /**
  69741. * Serialize placeholder for child classes
  69742. * @param parent of child
  69743. * @returns the serialized object
  69744. */
  69745. serialize(parent: any): any;
  69746. /**
  69747. * Internal only
  69748. * @hidden
  69749. */
  69750. _prepare(): void;
  69751. /**
  69752. * Internal only - manager for action
  69753. * @hidden
  69754. */
  69755. _actionManager: AbstractActionManager;
  69756. }
  69757. /**
  69758. * The action to be carried out following a trigger
  69759. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  69760. */
  69761. export class Action implements IAction {
  69762. /** the trigger, with or without parameters, for the action */
  69763. triggerOptions: any;
  69764. /**
  69765. * Trigger for the action
  69766. */
  69767. trigger: number;
  69768. /**
  69769. * Internal only - manager for action
  69770. * @hidden
  69771. */
  69772. _actionManager: ActionManager;
  69773. private _nextActiveAction;
  69774. private _child;
  69775. private _condition?;
  69776. private _triggerParameter;
  69777. /**
  69778. * An event triggered prior to action being executed.
  69779. */
  69780. onBeforeExecuteObservable: Observable<Action>;
  69781. /**
  69782. * Creates a new Action
  69783. * @param triggerOptions the trigger, with or without parameters, for the action
  69784. * @param condition an optional determinant of action
  69785. */
  69786. constructor(
  69787. /** the trigger, with or without parameters, for the action */
  69788. triggerOptions: any, condition?: Condition);
  69789. /**
  69790. * Internal only
  69791. * @hidden
  69792. */
  69793. _prepare(): void;
  69794. /**
  69795. * Gets the trigger parameters
  69796. * @returns the trigger parameters
  69797. */
  69798. getTriggerParameter(): any;
  69799. /**
  69800. * Internal only - executes current action event
  69801. * @hidden
  69802. */
  69803. _executeCurrent(evt?: ActionEvent): void;
  69804. /**
  69805. * Execute placeholder for child classes
  69806. * @param evt optional action event
  69807. */
  69808. execute(evt?: ActionEvent): void;
  69809. /**
  69810. * Skips to next active action
  69811. */
  69812. skipToNextActiveAction(): void;
  69813. /**
  69814. * Adds action to chain of actions, may be a DoNothingAction
  69815. * @param action defines the next action to execute
  69816. * @returns The action passed in
  69817. * @see https://www.babylonjs-playground.com/#1T30HR#0
  69818. */
  69819. then(action: Action): Action;
  69820. /**
  69821. * Internal only
  69822. * @hidden
  69823. */
  69824. _getProperty(propertyPath: string): string;
  69825. /**
  69826. * Internal only
  69827. * @hidden
  69828. */
  69829. _getEffectiveTarget(target: any, propertyPath: string): any;
  69830. /**
  69831. * Serialize placeholder for child classes
  69832. * @param parent of child
  69833. * @returns the serialized object
  69834. */
  69835. serialize(parent: any): any;
  69836. /**
  69837. * Internal only called by serialize
  69838. * @hidden
  69839. */
  69840. protected _serialize(serializedAction: any, parent?: any): any;
  69841. /**
  69842. * Internal only
  69843. * @hidden
  69844. */
  69845. static _SerializeValueAsString: (value: any) => string;
  69846. /**
  69847. * Internal only
  69848. * @hidden
  69849. */
  69850. static _GetTargetProperty: (target: Scene | Node) => {
  69851. name: string;
  69852. targetType: string;
  69853. value: string;
  69854. };
  69855. }
  69856. }
  69857. declare module BABYLON {
  69858. /**
  69859. * A Condition applied to an Action
  69860. */
  69861. export class Condition {
  69862. /**
  69863. * Internal only - manager for action
  69864. * @hidden
  69865. */
  69866. _actionManager: ActionManager;
  69867. /**
  69868. * Internal only
  69869. * @hidden
  69870. */
  69871. _evaluationId: number;
  69872. /**
  69873. * Internal only
  69874. * @hidden
  69875. */
  69876. _currentResult: boolean;
  69877. /**
  69878. * Creates a new Condition
  69879. * @param actionManager the manager of the action the condition is applied to
  69880. */
  69881. constructor(actionManager: ActionManager);
  69882. /**
  69883. * Check if the current condition is valid
  69884. * @returns a boolean
  69885. */
  69886. isValid(): boolean;
  69887. /**
  69888. * Internal only
  69889. * @hidden
  69890. */
  69891. _getProperty(propertyPath: string): string;
  69892. /**
  69893. * Internal only
  69894. * @hidden
  69895. */
  69896. _getEffectiveTarget(target: any, propertyPath: string): any;
  69897. /**
  69898. * Serialize placeholder for child classes
  69899. * @returns the serialized object
  69900. */
  69901. serialize(): any;
  69902. /**
  69903. * Internal only
  69904. * @hidden
  69905. */
  69906. protected _serialize(serializedCondition: any): any;
  69907. }
  69908. /**
  69909. * Defines specific conditional operators as extensions of Condition
  69910. */
  69911. export class ValueCondition extends Condition {
  69912. /** path to specify the property of the target the conditional operator uses */
  69913. propertyPath: string;
  69914. /** the value compared by the conditional operator against the current value of the property */
  69915. value: any;
  69916. /** the conditional operator, default ValueCondition.IsEqual */
  69917. operator: number;
  69918. /**
  69919. * Internal only
  69920. * @hidden
  69921. */
  69922. private static _IsEqual;
  69923. /**
  69924. * Internal only
  69925. * @hidden
  69926. */
  69927. private static _IsDifferent;
  69928. /**
  69929. * Internal only
  69930. * @hidden
  69931. */
  69932. private static _IsGreater;
  69933. /**
  69934. * Internal only
  69935. * @hidden
  69936. */
  69937. private static _IsLesser;
  69938. /**
  69939. * returns the number for IsEqual
  69940. */
  69941. static readonly IsEqual: number;
  69942. /**
  69943. * Returns the number for IsDifferent
  69944. */
  69945. static readonly IsDifferent: number;
  69946. /**
  69947. * Returns the number for IsGreater
  69948. */
  69949. static readonly IsGreater: number;
  69950. /**
  69951. * Returns the number for IsLesser
  69952. */
  69953. static readonly IsLesser: number;
  69954. /**
  69955. * Internal only The action manager for the condition
  69956. * @hidden
  69957. */
  69958. _actionManager: ActionManager;
  69959. /**
  69960. * Internal only
  69961. * @hidden
  69962. */
  69963. private _target;
  69964. /**
  69965. * Internal only
  69966. * @hidden
  69967. */
  69968. private _effectiveTarget;
  69969. /**
  69970. * Internal only
  69971. * @hidden
  69972. */
  69973. private _property;
  69974. /**
  69975. * Creates a new ValueCondition
  69976. * @param actionManager manager for the action the condition applies to
  69977. * @param target for the action
  69978. * @param propertyPath path to specify the property of the target the conditional operator uses
  69979. * @param value the value compared by the conditional operator against the current value of the property
  69980. * @param operator the conditional operator, default ValueCondition.IsEqual
  69981. */
  69982. constructor(actionManager: ActionManager, target: any,
  69983. /** path to specify the property of the target the conditional operator uses */
  69984. propertyPath: string,
  69985. /** the value compared by the conditional operator against the current value of the property */
  69986. value: any,
  69987. /** the conditional operator, default ValueCondition.IsEqual */
  69988. operator?: number);
  69989. /**
  69990. * Compares the given value with the property value for the specified conditional operator
  69991. * @returns the result of the comparison
  69992. */
  69993. isValid(): boolean;
  69994. /**
  69995. * Serialize the ValueCondition into a JSON compatible object
  69996. * @returns serialization object
  69997. */
  69998. serialize(): any;
  69999. /**
  70000. * Gets the name of the conditional operator for the ValueCondition
  70001. * @param operator the conditional operator
  70002. * @returns the name
  70003. */
  70004. static GetOperatorName(operator: number): string;
  70005. }
  70006. /**
  70007. * Defines a predicate condition as an extension of Condition
  70008. */
  70009. export class PredicateCondition extends Condition {
  70010. /** defines the predicate function used to validate the condition */
  70011. predicate: () => boolean;
  70012. /**
  70013. * Internal only - manager for action
  70014. * @hidden
  70015. */
  70016. _actionManager: ActionManager;
  70017. /**
  70018. * Creates a new PredicateCondition
  70019. * @param actionManager manager for the action the condition applies to
  70020. * @param predicate defines the predicate function used to validate the condition
  70021. */
  70022. constructor(actionManager: ActionManager,
  70023. /** defines the predicate function used to validate the condition */
  70024. predicate: () => boolean);
  70025. /**
  70026. * @returns the validity of the predicate condition
  70027. */
  70028. isValid(): boolean;
  70029. }
  70030. /**
  70031. * Defines a state condition as an extension of Condition
  70032. */
  70033. export class StateCondition extends Condition {
  70034. /** Value to compare with target state */
  70035. value: string;
  70036. /**
  70037. * Internal only - manager for action
  70038. * @hidden
  70039. */
  70040. _actionManager: ActionManager;
  70041. /**
  70042. * Internal only
  70043. * @hidden
  70044. */
  70045. private _target;
  70046. /**
  70047. * Creates a new StateCondition
  70048. * @param actionManager manager for the action the condition applies to
  70049. * @param target of the condition
  70050. * @param value to compare with target state
  70051. */
  70052. constructor(actionManager: ActionManager, target: any,
  70053. /** Value to compare with target state */
  70054. value: string);
  70055. /**
  70056. * Gets a boolean indicating if the current condition is met
  70057. * @returns the validity of the state
  70058. */
  70059. isValid(): boolean;
  70060. /**
  70061. * Serialize the StateCondition into a JSON compatible object
  70062. * @returns serialization object
  70063. */
  70064. serialize(): any;
  70065. }
  70066. }
  70067. declare module BABYLON {
  70068. /**
  70069. * This defines an action responsible to toggle a boolean once triggered.
  70070. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  70071. */
  70072. export class SwitchBooleanAction extends Action {
  70073. /**
  70074. * The path to the boolean property in the target object
  70075. */
  70076. propertyPath: string;
  70077. private _target;
  70078. private _effectiveTarget;
  70079. private _property;
  70080. /**
  70081. * Instantiate the action
  70082. * @param triggerOptions defines the trigger options
  70083. * @param target defines the object containing the boolean
  70084. * @param propertyPath defines the path to the boolean property in the target object
  70085. * @param condition defines the trigger related conditions
  70086. */
  70087. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  70088. /** @hidden */
  70089. _prepare(): void;
  70090. /**
  70091. * Execute the action toggle the boolean value.
  70092. */
  70093. execute(): void;
  70094. /**
  70095. * Serializes the actions and its related information.
  70096. * @param parent defines the object to serialize in
  70097. * @returns the serialized object
  70098. */
  70099. serialize(parent: any): any;
  70100. }
  70101. /**
  70102. * This defines an action responsible to set a the state field of the target
  70103. * to a desired value once triggered.
  70104. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  70105. */
  70106. export class SetStateAction extends Action {
  70107. /**
  70108. * The value to store in the state field.
  70109. */
  70110. value: string;
  70111. private _target;
  70112. /**
  70113. * Instantiate the action
  70114. * @param triggerOptions defines the trigger options
  70115. * @param target defines the object containing the state property
  70116. * @param value defines the value to store in the state field
  70117. * @param condition defines the trigger related conditions
  70118. */
  70119. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  70120. /**
  70121. * Execute the action and store the value on the target state property.
  70122. */
  70123. execute(): void;
  70124. /**
  70125. * Serializes the actions and its related information.
  70126. * @param parent defines the object to serialize in
  70127. * @returns the serialized object
  70128. */
  70129. serialize(parent: any): any;
  70130. }
  70131. /**
  70132. * This defines an action responsible to set a property of the target
  70133. * to a desired value once triggered.
  70134. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  70135. */
  70136. export class SetValueAction extends Action {
  70137. /**
  70138. * The path of the property to set in the target.
  70139. */
  70140. propertyPath: string;
  70141. /**
  70142. * The value to set in the property
  70143. */
  70144. value: any;
  70145. private _target;
  70146. private _effectiveTarget;
  70147. private _property;
  70148. /**
  70149. * Instantiate the action
  70150. * @param triggerOptions defines the trigger options
  70151. * @param target defines the object containing the property
  70152. * @param propertyPath defines the path of the property to set in the target
  70153. * @param value defines the value to set in the property
  70154. * @param condition defines the trigger related conditions
  70155. */
  70156. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  70157. /** @hidden */
  70158. _prepare(): void;
  70159. /**
  70160. * Execute the action and set the targetted property to the desired value.
  70161. */
  70162. execute(): void;
  70163. /**
  70164. * Serializes the actions and its related information.
  70165. * @param parent defines the object to serialize in
  70166. * @returns the serialized object
  70167. */
  70168. serialize(parent: any): any;
  70169. }
  70170. /**
  70171. * This defines an action responsible to increment the target value
  70172. * to a desired value once triggered.
  70173. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  70174. */
  70175. export class IncrementValueAction extends Action {
  70176. /**
  70177. * The path of the property to increment in the target.
  70178. */
  70179. propertyPath: string;
  70180. /**
  70181. * The value we should increment the property by.
  70182. */
  70183. value: any;
  70184. private _target;
  70185. private _effectiveTarget;
  70186. private _property;
  70187. /**
  70188. * Instantiate the action
  70189. * @param triggerOptions defines the trigger options
  70190. * @param target defines the object containing the property
  70191. * @param propertyPath defines the path of the property to increment in the target
  70192. * @param value defines the value value we should increment the property by
  70193. * @param condition defines the trigger related conditions
  70194. */
  70195. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  70196. /** @hidden */
  70197. _prepare(): void;
  70198. /**
  70199. * Execute the action and increment the target of the value amount.
  70200. */
  70201. execute(): void;
  70202. /**
  70203. * Serializes the actions and its related information.
  70204. * @param parent defines the object to serialize in
  70205. * @returns the serialized object
  70206. */
  70207. serialize(parent: any): any;
  70208. }
  70209. /**
  70210. * This defines an action responsible to start an animation once triggered.
  70211. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  70212. */
  70213. export class PlayAnimationAction extends Action {
  70214. /**
  70215. * Where the animation should start (animation frame)
  70216. */
  70217. from: number;
  70218. /**
  70219. * Where the animation should stop (animation frame)
  70220. */
  70221. to: number;
  70222. /**
  70223. * Define if the animation should loop or stop after the first play.
  70224. */
  70225. loop?: boolean;
  70226. private _target;
  70227. /**
  70228. * Instantiate the action
  70229. * @param triggerOptions defines the trigger options
  70230. * @param target defines the target animation or animation name
  70231. * @param from defines from where the animation should start (animation frame)
  70232. * @param end defines where the animation should stop (animation frame)
  70233. * @param loop defines if the animation should loop or stop after the first play
  70234. * @param condition defines the trigger related conditions
  70235. */
  70236. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  70237. /** @hidden */
  70238. _prepare(): void;
  70239. /**
  70240. * Execute the action and play the animation.
  70241. */
  70242. execute(): void;
  70243. /**
  70244. * Serializes the actions and its related information.
  70245. * @param parent defines the object to serialize in
  70246. * @returns the serialized object
  70247. */
  70248. serialize(parent: any): any;
  70249. }
  70250. /**
  70251. * This defines an action responsible to stop an animation once triggered.
  70252. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  70253. */
  70254. export class StopAnimationAction extends Action {
  70255. private _target;
  70256. /**
  70257. * Instantiate the action
  70258. * @param triggerOptions defines the trigger options
  70259. * @param target defines the target animation or animation name
  70260. * @param condition defines the trigger related conditions
  70261. */
  70262. constructor(triggerOptions: any, target: any, condition?: Condition);
  70263. /** @hidden */
  70264. _prepare(): void;
  70265. /**
  70266. * Execute the action and stop the animation.
  70267. */
  70268. execute(): void;
  70269. /**
  70270. * Serializes the actions and its related information.
  70271. * @param parent defines the object to serialize in
  70272. * @returns the serialized object
  70273. */
  70274. serialize(parent: any): any;
  70275. }
  70276. /**
  70277. * This defines an action responsible that does nothing once triggered.
  70278. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  70279. */
  70280. export class DoNothingAction extends Action {
  70281. /**
  70282. * Instantiate the action
  70283. * @param triggerOptions defines the trigger options
  70284. * @param condition defines the trigger related conditions
  70285. */
  70286. constructor(triggerOptions?: any, condition?: Condition);
  70287. /**
  70288. * Execute the action and do nothing.
  70289. */
  70290. execute(): void;
  70291. /**
  70292. * Serializes the actions and its related information.
  70293. * @param parent defines the object to serialize in
  70294. * @returns the serialized object
  70295. */
  70296. serialize(parent: any): any;
  70297. }
  70298. /**
  70299. * This defines an action responsible to trigger several actions once triggered.
  70300. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  70301. */
  70302. export class CombineAction extends Action {
  70303. /**
  70304. * The list of aggregated animations to run.
  70305. */
  70306. children: Action[];
  70307. /**
  70308. * Instantiate the action
  70309. * @param triggerOptions defines the trigger options
  70310. * @param children defines the list of aggregated animations to run
  70311. * @param condition defines the trigger related conditions
  70312. */
  70313. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  70314. /** @hidden */
  70315. _prepare(): void;
  70316. /**
  70317. * Execute the action and executes all the aggregated actions.
  70318. */
  70319. execute(evt: ActionEvent): void;
  70320. /**
  70321. * Serializes the actions and its related information.
  70322. * @param parent defines the object to serialize in
  70323. * @returns the serialized object
  70324. */
  70325. serialize(parent: any): any;
  70326. }
  70327. /**
  70328. * This defines an action responsible to run code (external event) once triggered.
  70329. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  70330. */
  70331. export class ExecuteCodeAction extends Action {
  70332. /**
  70333. * The callback function to run.
  70334. */
  70335. func: (evt: ActionEvent) => void;
  70336. /**
  70337. * Instantiate the action
  70338. * @param triggerOptions defines the trigger options
  70339. * @param func defines the callback function to run
  70340. * @param condition defines the trigger related conditions
  70341. */
  70342. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  70343. /**
  70344. * Execute the action and run the attached code.
  70345. */
  70346. execute(evt: ActionEvent): void;
  70347. }
  70348. /**
  70349. * This defines an action responsible to set the parent property of the target once triggered.
  70350. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  70351. */
  70352. export class SetParentAction extends Action {
  70353. private _parent;
  70354. private _target;
  70355. /**
  70356. * Instantiate the action
  70357. * @param triggerOptions defines the trigger options
  70358. * @param target defines the target containing the parent property
  70359. * @param parent defines from where the animation should start (animation frame)
  70360. * @param condition defines the trigger related conditions
  70361. */
  70362. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  70363. /** @hidden */
  70364. _prepare(): void;
  70365. /**
  70366. * Execute the action and set the parent property.
  70367. */
  70368. execute(): void;
  70369. /**
  70370. * Serializes the actions and its related information.
  70371. * @param parent defines the object to serialize in
  70372. * @returns the serialized object
  70373. */
  70374. serialize(parent: any): any;
  70375. }
  70376. }
  70377. declare module BABYLON {
  70378. /**
  70379. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  70380. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  70381. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  70382. */
  70383. export class ActionManager extends AbstractActionManager {
  70384. /**
  70385. * Nothing
  70386. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70387. */
  70388. static readonly NothingTrigger: number;
  70389. /**
  70390. * On pick
  70391. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70392. */
  70393. static readonly OnPickTrigger: number;
  70394. /**
  70395. * On left pick
  70396. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70397. */
  70398. static readonly OnLeftPickTrigger: number;
  70399. /**
  70400. * On right pick
  70401. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70402. */
  70403. static readonly OnRightPickTrigger: number;
  70404. /**
  70405. * On center pick
  70406. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70407. */
  70408. static readonly OnCenterPickTrigger: number;
  70409. /**
  70410. * On pick down
  70411. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70412. */
  70413. static readonly OnPickDownTrigger: number;
  70414. /**
  70415. * On double pick
  70416. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70417. */
  70418. static readonly OnDoublePickTrigger: number;
  70419. /**
  70420. * On pick up
  70421. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70422. */
  70423. static readonly OnPickUpTrigger: number;
  70424. /**
  70425. * On pick out.
  70426. * This trigger will only be raised if you also declared a OnPickDown
  70427. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70428. */
  70429. static readonly OnPickOutTrigger: number;
  70430. /**
  70431. * On long press
  70432. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70433. */
  70434. static readonly OnLongPressTrigger: number;
  70435. /**
  70436. * On pointer over
  70437. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70438. */
  70439. static readonly OnPointerOverTrigger: number;
  70440. /**
  70441. * On pointer out
  70442. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70443. */
  70444. static readonly OnPointerOutTrigger: number;
  70445. /**
  70446. * On every frame
  70447. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70448. */
  70449. static readonly OnEveryFrameTrigger: number;
  70450. /**
  70451. * On intersection enter
  70452. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70453. */
  70454. static readonly OnIntersectionEnterTrigger: number;
  70455. /**
  70456. * On intersection exit
  70457. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70458. */
  70459. static readonly OnIntersectionExitTrigger: number;
  70460. /**
  70461. * On key down
  70462. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70463. */
  70464. static readonly OnKeyDownTrigger: number;
  70465. /**
  70466. * On key up
  70467. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70468. */
  70469. static readonly OnKeyUpTrigger: number;
  70470. private _scene;
  70471. /**
  70472. * Creates a new action manager
  70473. * @param scene defines the hosting scene
  70474. */
  70475. constructor(scene: Scene);
  70476. /**
  70477. * Releases all associated resources
  70478. */
  70479. dispose(): void;
  70480. /**
  70481. * Gets hosting scene
  70482. * @returns the hosting scene
  70483. */
  70484. getScene(): Scene;
  70485. /**
  70486. * Does this action manager handles actions of any of the given triggers
  70487. * @param triggers defines the triggers to be tested
  70488. * @return a boolean indicating whether one (or more) of the triggers is handled
  70489. */
  70490. hasSpecificTriggers(triggers: number[]): boolean;
  70491. /**
  70492. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  70493. * speed.
  70494. * @param triggerA defines the trigger to be tested
  70495. * @param triggerB defines the trigger to be tested
  70496. * @return a boolean indicating whether one (or more) of the triggers is handled
  70497. */
  70498. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  70499. /**
  70500. * Does this action manager handles actions of a given trigger
  70501. * @param trigger defines the trigger to be tested
  70502. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  70503. * @return whether the trigger is handled
  70504. */
  70505. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  70506. /**
  70507. * Does this action manager has pointer triggers
  70508. */
  70509. readonly hasPointerTriggers: boolean;
  70510. /**
  70511. * Does this action manager has pick triggers
  70512. */
  70513. readonly hasPickTriggers: boolean;
  70514. /**
  70515. * Registers an action to this action manager
  70516. * @param action defines the action to be registered
  70517. * @return the action amended (prepared) after registration
  70518. */
  70519. registerAction(action: IAction): Nullable<IAction>;
  70520. /**
  70521. * Unregisters an action to this action manager
  70522. * @param action defines the action to be unregistered
  70523. * @return a boolean indicating whether the action has been unregistered
  70524. */
  70525. unregisterAction(action: IAction): Boolean;
  70526. /**
  70527. * Process a specific trigger
  70528. * @param trigger defines the trigger to process
  70529. * @param evt defines the event details to be processed
  70530. */
  70531. processTrigger(trigger: number, evt?: IActionEvent): void;
  70532. /** @hidden */
  70533. _getEffectiveTarget(target: any, propertyPath: string): any;
  70534. /** @hidden */
  70535. _getProperty(propertyPath: string): string;
  70536. /**
  70537. * Serialize this manager to a JSON object
  70538. * @param name defines the property name to store this manager
  70539. * @returns a JSON representation of this manager
  70540. */
  70541. serialize(name: string): any;
  70542. /**
  70543. * Creates a new ActionManager from a JSON data
  70544. * @param parsedActions defines the JSON data to read from
  70545. * @param object defines the hosting mesh
  70546. * @param scene defines the hosting scene
  70547. */
  70548. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  70549. /**
  70550. * Get a trigger name by index
  70551. * @param trigger defines the trigger index
  70552. * @returns a trigger name
  70553. */
  70554. static GetTriggerName(trigger: number): string;
  70555. }
  70556. }
  70557. declare module BABYLON {
  70558. /**
  70559. * Class representing a ray with position and direction
  70560. */
  70561. export class Ray {
  70562. /** origin point */
  70563. origin: Vector3;
  70564. /** direction */
  70565. direction: Vector3;
  70566. /** length of the ray */
  70567. length: number;
  70568. private static readonly TmpVector3;
  70569. private _tmpRay;
  70570. /**
  70571. * Creates a new ray
  70572. * @param origin origin point
  70573. * @param direction direction
  70574. * @param length length of the ray
  70575. */
  70576. constructor(
  70577. /** origin point */
  70578. origin: Vector3,
  70579. /** direction */
  70580. direction: Vector3,
  70581. /** length of the ray */
  70582. length?: number);
  70583. /**
  70584. * Checks if the ray intersects a box
  70585. * @param minimum bound of the box
  70586. * @param maximum bound of the box
  70587. * @param intersectionTreshold extra extend to be added to the box in all direction
  70588. * @returns if the box was hit
  70589. */
  70590. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  70591. /**
  70592. * Checks if the ray intersects a box
  70593. * @param box the bounding box to check
  70594. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  70595. * @returns if the box was hit
  70596. */
  70597. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  70598. /**
  70599. * If the ray hits a sphere
  70600. * @param sphere the bounding sphere to check
  70601. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  70602. * @returns true if it hits the sphere
  70603. */
  70604. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  70605. /**
  70606. * If the ray hits a triange
  70607. * @param vertex0 triangle vertex
  70608. * @param vertex1 triangle vertex
  70609. * @param vertex2 triangle vertex
  70610. * @returns intersection information if hit
  70611. */
  70612. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  70613. /**
  70614. * Checks if ray intersects a plane
  70615. * @param plane the plane to check
  70616. * @returns the distance away it was hit
  70617. */
  70618. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  70619. /**
  70620. * Checks if ray intersects a mesh
  70621. * @param mesh the mesh to check
  70622. * @param fastCheck if only the bounding box should checked
  70623. * @returns picking info of the intersecton
  70624. */
  70625. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  70626. /**
  70627. * Checks if ray intersects a mesh
  70628. * @param meshes the meshes to check
  70629. * @param fastCheck if only the bounding box should checked
  70630. * @param results array to store result in
  70631. * @returns Array of picking infos
  70632. */
  70633. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  70634. private _comparePickingInfo;
  70635. private static smallnum;
  70636. private static rayl;
  70637. /**
  70638. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  70639. * @param sega the first point of the segment to test the intersection against
  70640. * @param segb the second point of the segment to test the intersection against
  70641. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  70642. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  70643. */
  70644. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  70645. /**
  70646. * Update the ray from viewport position
  70647. * @param x position
  70648. * @param y y position
  70649. * @param viewportWidth viewport width
  70650. * @param viewportHeight viewport height
  70651. * @param world world matrix
  70652. * @param view view matrix
  70653. * @param projection projection matrix
  70654. * @returns this ray updated
  70655. */
  70656. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  70657. /**
  70658. * Creates a ray with origin and direction of 0,0,0
  70659. * @returns the new ray
  70660. */
  70661. static Zero(): Ray;
  70662. /**
  70663. * Creates a new ray from screen space and viewport
  70664. * @param x position
  70665. * @param y y position
  70666. * @param viewportWidth viewport width
  70667. * @param viewportHeight viewport height
  70668. * @param world world matrix
  70669. * @param view view matrix
  70670. * @param projection projection matrix
  70671. * @returns new ray
  70672. */
  70673. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  70674. /**
  70675. * 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
  70676. * transformed to the given world matrix.
  70677. * @param origin The origin point
  70678. * @param end The end point
  70679. * @param world a matrix to transform the ray to. Default is the identity matrix.
  70680. * @returns the new ray
  70681. */
  70682. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  70683. /**
  70684. * Transforms a ray by a matrix
  70685. * @param ray ray to transform
  70686. * @param matrix matrix to apply
  70687. * @returns the resulting new ray
  70688. */
  70689. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  70690. /**
  70691. * Transforms a ray by a matrix
  70692. * @param ray ray to transform
  70693. * @param matrix matrix to apply
  70694. * @param result ray to store result in
  70695. */
  70696. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  70697. /**
  70698. * Unproject a ray from screen space to object space
  70699. * @param sourceX defines the screen space x coordinate to use
  70700. * @param sourceY defines the screen space y coordinate to use
  70701. * @param viewportWidth defines the current width of the viewport
  70702. * @param viewportHeight defines the current height of the viewport
  70703. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  70704. * @param view defines the view matrix to use
  70705. * @param projection defines the projection matrix to use
  70706. */
  70707. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  70708. }
  70709. /**
  70710. * Type used to define predicate used to select faces when a mesh intersection is detected
  70711. */
  70712. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  70713. interface Scene {
  70714. /** @hidden */
  70715. _tempPickingRay: Nullable<Ray>;
  70716. /** @hidden */
  70717. _cachedRayForTransform: Ray;
  70718. /** @hidden */
  70719. _pickWithRayInverseMatrix: Matrix;
  70720. /** @hidden */
  70721. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  70722. /** @hidden */
  70723. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  70724. }
  70725. }
  70726. declare module BABYLON {
  70727. /**
  70728. * Groups all the scene component constants in one place to ease maintenance.
  70729. * @hidden
  70730. */
  70731. export class SceneComponentConstants {
  70732. static readonly NAME_EFFECTLAYER: string;
  70733. static readonly NAME_LAYER: string;
  70734. static readonly NAME_LENSFLARESYSTEM: string;
  70735. static readonly NAME_BOUNDINGBOXRENDERER: string;
  70736. static readonly NAME_PARTICLESYSTEM: string;
  70737. static readonly NAME_GAMEPAD: string;
  70738. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  70739. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  70740. static readonly NAME_DEPTHRENDERER: string;
  70741. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  70742. static readonly NAME_SPRITE: string;
  70743. static readonly NAME_OUTLINERENDERER: string;
  70744. static readonly NAME_PROCEDURALTEXTURE: string;
  70745. static readonly NAME_SHADOWGENERATOR: string;
  70746. static readonly NAME_OCTREE: string;
  70747. static readonly NAME_PHYSICSENGINE: string;
  70748. static readonly NAME_AUDIO: string;
  70749. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  70750. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  70751. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  70752. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  70753. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  70754. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  70755. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  70756. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  70757. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  70758. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  70759. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  70760. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  70761. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  70762. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  70763. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  70764. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  70765. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  70766. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  70767. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  70768. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  70769. static readonly STEP_AFTERRENDER_AUDIO: number;
  70770. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  70771. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  70772. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  70773. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  70774. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  70775. static readonly STEP_POINTERMOVE_SPRITE: number;
  70776. static readonly STEP_POINTERDOWN_SPRITE: number;
  70777. static readonly STEP_POINTERUP_SPRITE: number;
  70778. }
  70779. /**
  70780. * This represents a scene component.
  70781. *
  70782. * This is used to decouple the dependency the scene is having on the different workloads like
  70783. * layers, post processes...
  70784. */
  70785. export interface ISceneComponent {
  70786. /**
  70787. * The name of the component. Each component must have a unique name.
  70788. */
  70789. name: string;
  70790. /**
  70791. * The scene the component belongs to.
  70792. */
  70793. scene: Scene;
  70794. /**
  70795. * Register the component to one instance of a scene.
  70796. */
  70797. register(): void;
  70798. /**
  70799. * Rebuilds the elements related to this component in case of
  70800. * context lost for instance.
  70801. */
  70802. rebuild(): void;
  70803. /**
  70804. * Disposes the component and the associated ressources.
  70805. */
  70806. dispose(): void;
  70807. }
  70808. /**
  70809. * This represents a SERIALIZABLE scene component.
  70810. *
  70811. * This extends Scene Component to add Serialization methods on top.
  70812. */
  70813. export interface ISceneSerializableComponent extends ISceneComponent {
  70814. /**
  70815. * Adds all the element from the container to the scene
  70816. * @param container the container holding the elements
  70817. */
  70818. addFromContainer(container: AbstractScene): void;
  70819. /**
  70820. * Removes all the elements in the container from the scene
  70821. * @param container contains the elements to remove
  70822. * @param dispose if the removed element should be disposed (default: false)
  70823. */
  70824. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  70825. /**
  70826. * Serializes the component data to the specified json object
  70827. * @param serializationObject The object to serialize to
  70828. */
  70829. serialize(serializationObject: any): void;
  70830. }
  70831. /**
  70832. * Strong typing of a Mesh related stage step action
  70833. */
  70834. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  70835. /**
  70836. * Strong typing of a Evaluate Sub Mesh related stage step action
  70837. */
  70838. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  70839. /**
  70840. * Strong typing of a Active Mesh related stage step action
  70841. */
  70842. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  70843. /**
  70844. * Strong typing of a Camera related stage step action
  70845. */
  70846. export type CameraStageAction = (camera: Camera) => void;
  70847. /**
  70848. * Strong typing of a Render Target related stage step action
  70849. */
  70850. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  70851. /**
  70852. * Strong typing of a RenderingGroup related stage step action
  70853. */
  70854. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  70855. /**
  70856. * Strong typing of a Mesh Render related stage step action
  70857. */
  70858. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  70859. /**
  70860. * Strong typing of a simple stage step action
  70861. */
  70862. export type SimpleStageAction = () => void;
  70863. /**
  70864. * Strong typing of a render target action.
  70865. */
  70866. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  70867. /**
  70868. * Strong typing of a pointer move action.
  70869. */
  70870. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  70871. /**
  70872. * Strong typing of a pointer up/down action.
  70873. */
  70874. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  70875. /**
  70876. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  70877. * @hidden
  70878. */
  70879. export class Stage<T extends Function> extends Array<{
  70880. index: number;
  70881. component: ISceneComponent;
  70882. action: T;
  70883. }> {
  70884. /**
  70885. * Hide ctor from the rest of the world.
  70886. * @param items The items to add.
  70887. */
  70888. private constructor();
  70889. /**
  70890. * Creates a new Stage.
  70891. * @returns A new instance of a Stage
  70892. */
  70893. static Create<T extends Function>(): Stage<T>;
  70894. /**
  70895. * Registers a step in an ordered way in the targeted stage.
  70896. * @param index Defines the position to register the step in
  70897. * @param component Defines the component attached to the step
  70898. * @param action Defines the action to launch during the step
  70899. */
  70900. registerStep(index: number, component: ISceneComponent, action: T): void;
  70901. /**
  70902. * Clears all the steps from the stage.
  70903. */
  70904. clear(): void;
  70905. }
  70906. }
  70907. declare module BABYLON {
  70908. interface Scene {
  70909. /** @hidden */
  70910. _pointerOverSprite: Nullable<Sprite>;
  70911. /** @hidden */
  70912. _pickedDownSprite: Nullable<Sprite>;
  70913. /** @hidden */
  70914. _tempSpritePickingRay: Nullable<Ray>;
  70915. /**
  70916. * All of the sprite managers added to this scene
  70917. * @see http://doc.babylonjs.com/babylon101/sprites
  70918. */
  70919. spriteManagers: Array<ISpriteManager>;
  70920. /**
  70921. * An event triggered when sprites rendering is about to start
  70922. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  70923. */
  70924. onBeforeSpritesRenderingObservable: Observable<Scene>;
  70925. /**
  70926. * An event triggered when sprites rendering is done
  70927. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  70928. */
  70929. onAfterSpritesRenderingObservable: Observable<Scene>;
  70930. /** @hidden */
  70931. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  70932. /** Launch a ray to try to pick a sprite in the scene
  70933. * @param x position on screen
  70934. * @param y position on screen
  70935. * @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
  70936. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  70937. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  70938. * @returns a PickingInfo
  70939. */
  70940. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  70941. /** Use the given ray to pick a sprite in the scene
  70942. * @param ray The ray (in world space) to use to pick meshes
  70943. * @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
  70944. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  70945. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  70946. * @returns a PickingInfo
  70947. */
  70948. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  70949. /**
  70950. * Force the sprite under the pointer
  70951. * @param sprite defines the sprite to use
  70952. */
  70953. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  70954. /**
  70955. * Gets the sprite under the pointer
  70956. * @returns a Sprite or null if no sprite is under the pointer
  70957. */
  70958. getPointerOverSprite(): Nullable<Sprite>;
  70959. }
  70960. /**
  70961. * Defines the sprite scene component responsible to manage sprites
  70962. * in a given scene.
  70963. */
  70964. export class SpriteSceneComponent implements ISceneComponent {
  70965. /**
  70966. * The component name helpfull to identify the component in the list of scene components.
  70967. */
  70968. readonly name: string;
  70969. /**
  70970. * The scene the component belongs to.
  70971. */
  70972. scene: Scene;
  70973. /** @hidden */
  70974. private _spritePredicate;
  70975. /**
  70976. * Creates a new instance of the component for the given scene
  70977. * @param scene Defines the scene to register the component in
  70978. */
  70979. constructor(scene: Scene);
  70980. /**
  70981. * Registers the component in a given scene
  70982. */
  70983. register(): void;
  70984. /**
  70985. * Rebuilds the elements related to this component in case of
  70986. * context lost for instance.
  70987. */
  70988. rebuild(): void;
  70989. /**
  70990. * Disposes the component and the associated ressources.
  70991. */
  70992. dispose(): void;
  70993. private _pickSpriteButKeepRay;
  70994. private _pointerMove;
  70995. private _pointerDown;
  70996. private _pointerUp;
  70997. }
  70998. }
  70999. declare module BABYLON {
  71000. /** @hidden */
  71001. export var fogFragmentDeclaration: {
  71002. name: string;
  71003. shader: string;
  71004. };
  71005. }
  71006. declare module BABYLON {
  71007. /** @hidden */
  71008. export var fogFragment: {
  71009. name: string;
  71010. shader: string;
  71011. };
  71012. }
  71013. declare module BABYLON {
  71014. /** @hidden */
  71015. export var spritesPixelShader: {
  71016. name: string;
  71017. shader: string;
  71018. };
  71019. }
  71020. declare module BABYLON {
  71021. /** @hidden */
  71022. export var fogVertexDeclaration: {
  71023. name: string;
  71024. shader: string;
  71025. };
  71026. }
  71027. declare module BABYLON {
  71028. /** @hidden */
  71029. export var spritesVertexShader: {
  71030. name: string;
  71031. shader: string;
  71032. };
  71033. }
  71034. declare module BABYLON {
  71035. /**
  71036. * Defines the minimum interface to fullfil in order to be a sprite manager.
  71037. */
  71038. export interface ISpriteManager extends IDisposable {
  71039. /**
  71040. * Restricts the camera to viewing objects with the same layerMask.
  71041. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  71042. */
  71043. layerMask: number;
  71044. /**
  71045. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  71046. */
  71047. isPickable: boolean;
  71048. /**
  71049. * Specifies the rendering group id for this mesh (0 by default)
  71050. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  71051. */
  71052. renderingGroupId: number;
  71053. /**
  71054. * Defines the list of sprites managed by the manager.
  71055. */
  71056. sprites: Array<Sprite>;
  71057. /**
  71058. * Tests the intersection of a sprite with a specific ray.
  71059. * @param ray The ray we are sending to test the collision
  71060. * @param camera The camera space we are sending rays in
  71061. * @param predicate A predicate allowing excluding sprites from the list of object to test
  71062. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  71063. * @returns picking info or null.
  71064. */
  71065. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  71066. /**
  71067. * Renders the list of sprites on screen.
  71068. */
  71069. render(): void;
  71070. }
  71071. /**
  71072. * Class used to manage multiple sprites on the same spritesheet
  71073. * @see http://doc.babylonjs.com/babylon101/sprites
  71074. */
  71075. export class SpriteManager implements ISpriteManager {
  71076. /** defines the manager's name */
  71077. name: string;
  71078. /** Gets the list of sprites */
  71079. sprites: Sprite[];
  71080. /** Gets or sets the rendering group id (0 by default) */
  71081. renderingGroupId: number;
  71082. /** Gets or sets camera layer mask */
  71083. layerMask: number;
  71084. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  71085. fogEnabled: boolean;
  71086. /** Gets or sets a boolean indicating if the sprites are pickable */
  71087. isPickable: boolean;
  71088. /** Defines the default width of a cell in the spritesheet */
  71089. cellWidth: number;
  71090. /** Defines the default height of a cell in the spritesheet */
  71091. cellHeight: number;
  71092. /**
  71093. * An event triggered when the manager is disposed.
  71094. */
  71095. onDisposeObservable: Observable<SpriteManager>;
  71096. private _onDisposeObserver;
  71097. /**
  71098. * Callback called when the manager is disposed
  71099. */
  71100. onDispose: () => void;
  71101. private _capacity;
  71102. private _spriteTexture;
  71103. private _epsilon;
  71104. private _scene;
  71105. private _vertexData;
  71106. private _buffer;
  71107. private _vertexBuffers;
  71108. private _indexBuffer;
  71109. private _effectBase;
  71110. private _effectFog;
  71111. /**
  71112. * Gets or sets the spritesheet texture
  71113. */
  71114. texture: Texture;
  71115. /**
  71116. * Creates a new sprite manager
  71117. * @param name defines the manager's name
  71118. * @param imgUrl defines the sprite sheet url
  71119. * @param capacity defines the maximum allowed number of sprites
  71120. * @param cellSize defines the size of a sprite cell
  71121. * @param scene defines the hosting scene
  71122. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  71123. * @param samplingMode defines the smapling mode to use with spritesheet
  71124. */
  71125. constructor(
  71126. /** defines the manager's name */
  71127. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  71128. private _appendSpriteVertex;
  71129. /**
  71130. * Intersects the sprites with a ray
  71131. * @param ray defines the ray to intersect with
  71132. * @param camera defines the current active camera
  71133. * @param predicate defines a predicate used to select candidate sprites
  71134. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  71135. * @returns null if no hit or a PickingInfo
  71136. */
  71137. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  71138. /**
  71139. * Render all child sprites
  71140. */
  71141. render(): void;
  71142. /**
  71143. * Release associated resources
  71144. */
  71145. dispose(): void;
  71146. }
  71147. }
  71148. declare module BABYLON {
  71149. /**
  71150. * Class used to represent a sprite
  71151. * @see http://doc.babylonjs.com/babylon101/sprites
  71152. */
  71153. export class Sprite {
  71154. /** defines the name */
  71155. name: string;
  71156. /** Gets or sets the current world position */
  71157. position: Vector3;
  71158. /** Gets or sets the main color */
  71159. color: Color4;
  71160. /** Gets or sets the width */
  71161. width: number;
  71162. /** Gets or sets the height */
  71163. height: number;
  71164. /** Gets or sets rotation angle */
  71165. angle: number;
  71166. /** Gets or sets the cell index in the sprite sheet */
  71167. cellIndex: number;
  71168. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  71169. invertU: number;
  71170. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  71171. invertV: number;
  71172. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  71173. disposeWhenFinishedAnimating: boolean;
  71174. /** Gets the list of attached animations */
  71175. animations: Animation[];
  71176. /** Gets or sets a boolean indicating if the sprite can be picked */
  71177. isPickable: boolean;
  71178. /**
  71179. * Gets or sets the associated action manager
  71180. */
  71181. actionManager: Nullable<ActionManager>;
  71182. private _animationStarted;
  71183. private _loopAnimation;
  71184. private _fromIndex;
  71185. private _toIndex;
  71186. private _delay;
  71187. private _direction;
  71188. private _manager;
  71189. private _time;
  71190. private _onAnimationEnd;
  71191. /**
  71192. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  71193. */
  71194. isVisible: boolean;
  71195. /**
  71196. * Gets or sets the sprite size
  71197. */
  71198. size: number;
  71199. /**
  71200. * Creates a new Sprite
  71201. * @param name defines the name
  71202. * @param manager defines the manager
  71203. */
  71204. constructor(
  71205. /** defines the name */
  71206. name: string, manager: ISpriteManager);
  71207. /**
  71208. * Starts an animation
  71209. * @param from defines the initial key
  71210. * @param to defines the end key
  71211. * @param loop defines if the animation must loop
  71212. * @param delay defines the start delay (in ms)
  71213. * @param onAnimationEnd defines a callback to call when animation ends
  71214. */
  71215. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  71216. /** Stops current animation (if any) */
  71217. stopAnimation(): void;
  71218. /** @hidden */
  71219. _animate(deltaTime: number): void;
  71220. /** Release associated resources */
  71221. dispose(): void;
  71222. }
  71223. }
  71224. declare module BABYLON {
  71225. /**
  71226. * Information about the result of picking within a scene
  71227. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  71228. */
  71229. export class PickingInfo {
  71230. /** @hidden */
  71231. _pickingUnavailable: boolean;
  71232. /**
  71233. * If the pick collided with an object
  71234. */
  71235. hit: boolean;
  71236. /**
  71237. * Distance away where the pick collided
  71238. */
  71239. distance: number;
  71240. /**
  71241. * The location of pick collision
  71242. */
  71243. pickedPoint: Nullable<Vector3>;
  71244. /**
  71245. * The mesh corresponding the the pick collision
  71246. */
  71247. pickedMesh: Nullable<AbstractMesh>;
  71248. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calulating the texture coordinates of the collision.*/
  71249. bu: number;
  71250. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calulating the texture coordinates of the collision.*/
  71251. bv: number;
  71252. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  71253. faceId: number;
  71254. /** Id of the the submesh that was picked */
  71255. subMeshId: number;
  71256. /** If a sprite was picked, this will be the sprite the pick collided with */
  71257. pickedSprite: Nullable<Sprite>;
  71258. /**
  71259. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  71260. */
  71261. originMesh: Nullable<AbstractMesh>;
  71262. /**
  71263. * The ray that was used to perform the picking.
  71264. */
  71265. ray: Nullable<Ray>;
  71266. /**
  71267. * Gets the normal correspodning to the face the pick collided with
  71268. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  71269. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  71270. * @returns The normal correspodning to the face the pick collided with
  71271. */
  71272. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  71273. /**
  71274. * Gets the texture coordinates of where the pick occured
  71275. * @returns the vector containing the coordnates of the texture
  71276. */
  71277. getTextureCoordinates(): Nullable<Vector2>;
  71278. }
  71279. }
  71280. declare module BABYLON {
  71281. /**
  71282. * Gather the list of pointer event types as constants.
  71283. */
  71284. export class PointerEventTypes {
  71285. /**
  71286. * 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.
  71287. */
  71288. static readonly POINTERDOWN: number;
  71289. /**
  71290. * The pointerup event is fired when a pointer is no longer active.
  71291. */
  71292. static readonly POINTERUP: number;
  71293. /**
  71294. * The pointermove event is fired when a pointer changes coordinates.
  71295. */
  71296. static readonly POINTERMOVE: number;
  71297. /**
  71298. * The pointerwheel event is fired when a mouse wheel has been rotated.
  71299. */
  71300. static readonly POINTERWHEEL: number;
  71301. /**
  71302. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  71303. */
  71304. static readonly POINTERPICK: number;
  71305. /**
  71306. * The pointertap event is fired when a the object has been touched and released without drag.
  71307. */
  71308. static readonly POINTERTAP: number;
  71309. /**
  71310. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  71311. */
  71312. static readonly POINTERDOUBLETAP: number;
  71313. }
  71314. /**
  71315. * Base class of pointer info types.
  71316. */
  71317. export class PointerInfoBase {
  71318. /**
  71319. * Defines the type of event (PointerEventTypes)
  71320. */
  71321. type: number;
  71322. /**
  71323. * Defines the related dom event
  71324. */
  71325. event: PointerEvent | MouseWheelEvent;
  71326. /**
  71327. * Instantiates the base class of pointers info.
  71328. * @param type Defines the type of event (PointerEventTypes)
  71329. * @param event Defines the related dom event
  71330. */
  71331. constructor(
  71332. /**
  71333. * Defines the type of event (PointerEventTypes)
  71334. */
  71335. type: number,
  71336. /**
  71337. * Defines the related dom event
  71338. */
  71339. event: PointerEvent | MouseWheelEvent);
  71340. }
  71341. /**
  71342. * This class is used to store pointer related info for the onPrePointerObservable event.
  71343. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  71344. */
  71345. export class PointerInfoPre extends PointerInfoBase {
  71346. /**
  71347. * Ray from a pointer if availible (eg. 6dof controller)
  71348. */
  71349. ray: Nullable<Ray>;
  71350. /**
  71351. * Defines the local position of the pointer on the canvas.
  71352. */
  71353. localPosition: Vector2;
  71354. /**
  71355. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  71356. */
  71357. skipOnPointerObservable: boolean;
  71358. /**
  71359. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  71360. * @param type Defines the type of event (PointerEventTypes)
  71361. * @param event Defines the related dom event
  71362. * @param localX Defines the local x coordinates of the pointer when the event occured
  71363. * @param localY Defines the local y coordinates of the pointer when the event occured
  71364. */
  71365. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  71366. }
  71367. /**
  71368. * This type contains all the data related to a pointer event in Babylon.js.
  71369. * 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.
  71370. */
  71371. export class PointerInfo extends PointerInfoBase {
  71372. /**
  71373. * Defines the picking info associated to the info (if any)\
  71374. */
  71375. pickInfo: Nullable<PickingInfo>;
  71376. /**
  71377. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  71378. * @param type Defines the type of event (PointerEventTypes)
  71379. * @param event Defines the related dom event
  71380. * @param pickInfo Defines the picking info associated to the info (if any)\
  71381. */
  71382. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  71383. /**
  71384. * Defines the picking info associated to the info (if any)\
  71385. */
  71386. pickInfo: Nullable<PickingInfo>);
  71387. }
  71388. /**
  71389. * Data relating to a touch event on the screen.
  71390. */
  71391. export interface PointerTouch {
  71392. /**
  71393. * X coordinate of touch.
  71394. */
  71395. x: number;
  71396. /**
  71397. * Y coordinate of touch.
  71398. */
  71399. y: number;
  71400. /**
  71401. * Id of touch. Unique for each finger.
  71402. */
  71403. pointerId: number;
  71404. /**
  71405. * Event type passed from DOM.
  71406. */
  71407. type: any;
  71408. }
  71409. }
  71410. declare module BABYLON {
  71411. /**
  71412. * Manage the mouse inputs to control the movement of a free camera.
  71413. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  71414. */
  71415. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  71416. /**
  71417. * Define if touch is enabled in the mouse input
  71418. */
  71419. touchEnabled: boolean;
  71420. /**
  71421. * Defines the camera the input is attached to.
  71422. */
  71423. camera: FreeCamera;
  71424. /**
  71425. * Defines the buttons associated with the input to handle camera move.
  71426. */
  71427. buttons: number[];
  71428. /**
  71429. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  71430. */
  71431. angularSensibility: number;
  71432. private _pointerInput;
  71433. private _onMouseMove;
  71434. private _observer;
  71435. private previousPosition;
  71436. /**
  71437. * Observable for when a pointer move event occurs containing the move offset
  71438. */
  71439. onPointerMovedObservable: Observable<{
  71440. offsetX: number;
  71441. offsetY: number;
  71442. }>;
  71443. /**
  71444. * @hidden
  71445. * If the camera should be rotated automatically based on pointer movement
  71446. */
  71447. _allowCameraRotation: boolean;
  71448. /**
  71449. * Manage the mouse inputs to control the movement of a free camera.
  71450. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  71451. * @param touchEnabled Defines if touch is enabled or not
  71452. */
  71453. constructor(
  71454. /**
  71455. * Define if touch is enabled in the mouse input
  71456. */
  71457. touchEnabled?: boolean);
  71458. /**
  71459. * Attach the input controls to a specific dom element to get the input from.
  71460. * @param element Defines the element the controls should be listened from
  71461. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  71462. */
  71463. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  71464. /**
  71465. * Called on JS contextmenu event.
  71466. * Override this method to provide functionality.
  71467. */
  71468. protected onContextMenu(evt: PointerEvent): void;
  71469. /**
  71470. * Detach the current controls from the specified dom element.
  71471. * @param element Defines the element to stop listening the inputs from
  71472. */
  71473. detachControl(element: Nullable<HTMLElement>): void;
  71474. /**
  71475. * Gets the class name of the current intput.
  71476. * @returns the class name
  71477. */
  71478. getClassName(): string;
  71479. /**
  71480. * Get the friendly name associated with the input class.
  71481. * @returns the input friendly name
  71482. */
  71483. getSimpleName(): string;
  71484. }
  71485. }
  71486. declare module BABYLON {
  71487. /**
  71488. * Manage the touch inputs to control the movement of a free camera.
  71489. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  71490. */
  71491. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  71492. /**
  71493. * Defines the camera the input is attached to.
  71494. */
  71495. camera: FreeCamera;
  71496. /**
  71497. * Defines the touch sensibility for rotation.
  71498. * The higher the faster.
  71499. */
  71500. touchAngularSensibility: number;
  71501. /**
  71502. * Defines the touch sensibility for move.
  71503. * The higher the faster.
  71504. */
  71505. touchMoveSensibility: number;
  71506. private _offsetX;
  71507. private _offsetY;
  71508. private _pointerPressed;
  71509. private _pointerInput;
  71510. private _observer;
  71511. private _onLostFocus;
  71512. /**
  71513. * Attach the input controls to a specific dom element to get the input from.
  71514. * @param element Defines the element the controls should be listened from
  71515. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  71516. */
  71517. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  71518. /**
  71519. * Detach the current controls from the specified dom element.
  71520. * @param element Defines the element to stop listening the inputs from
  71521. */
  71522. detachControl(element: Nullable<HTMLElement>): void;
  71523. /**
  71524. * Update the current camera state depending on the inputs that have been used this frame.
  71525. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  71526. */
  71527. checkInputs(): void;
  71528. /**
  71529. * Gets the class name of the current intput.
  71530. * @returns the class name
  71531. */
  71532. getClassName(): string;
  71533. /**
  71534. * Get the friendly name associated with the input class.
  71535. * @returns the input friendly name
  71536. */
  71537. getSimpleName(): string;
  71538. }
  71539. }
  71540. declare module BABYLON {
  71541. /**
  71542. * Default Inputs manager for the FreeCamera.
  71543. * It groups all the default supported inputs for ease of use.
  71544. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  71545. */
  71546. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  71547. /**
  71548. * @hidden
  71549. */
  71550. _keyboardInput: Nullable<FreeCameraKeyboardMoveInput>;
  71551. /**
  71552. * @hidden
  71553. */
  71554. _mouseInput: Nullable<FreeCameraMouseInput>;
  71555. /**
  71556. * Instantiates a new FreeCameraInputsManager.
  71557. * @param camera Defines the camera the inputs belong to
  71558. */
  71559. constructor(camera: FreeCamera);
  71560. /**
  71561. * Add keyboard input support to the input manager.
  71562. * @returns the current input manager
  71563. */
  71564. addKeyboard(): FreeCameraInputsManager;
  71565. /**
  71566. * Add mouse input support to the input manager.
  71567. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  71568. * @returns the current input manager
  71569. */
  71570. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  71571. /**
  71572. * Removes the mouse input support from the manager
  71573. * @returns the current input manager
  71574. */
  71575. removeMouse(): FreeCameraInputsManager;
  71576. /**
  71577. * Add touch input support to the input manager.
  71578. * @returns the current input manager
  71579. */
  71580. addTouch(): FreeCameraInputsManager;
  71581. }
  71582. }
  71583. declare module BABYLON {
  71584. /**
  71585. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  71586. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  71587. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  71588. */
  71589. export class FreeCamera extends TargetCamera {
  71590. /**
  71591. * Define the collision ellipsoid of the camera.
  71592. * This is helpful to simulate a camera body like the player body around the camera
  71593. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  71594. */
  71595. ellipsoid: Vector3;
  71596. /**
  71597. * Define an offset for the position of the ellipsoid around the camera.
  71598. * This can be helpful to determine the center of the body near the gravity center of the body
  71599. * instead of its head.
  71600. */
  71601. ellipsoidOffset: Vector3;
  71602. /**
  71603. * Enable or disable collisions of the camera with the rest of the scene objects.
  71604. */
  71605. checkCollisions: boolean;
  71606. /**
  71607. * Enable or disable gravity on the camera.
  71608. */
  71609. applyGravity: boolean;
  71610. /**
  71611. * Define the input manager associated to the camera.
  71612. */
  71613. inputs: FreeCameraInputsManager;
  71614. /**
  71615. * Gets the input sensibility for a mouse input. (default is 2000.0)
  71616. * Higher values reduce sensitivity.
  71617. */
  71618. /**
  71619. * Sets the input sensibility for a mouse input. (default is 2000.0)
  71620. * Higher values reduce sensitivity.
  71621. */
  71622. angularSensibility: number;
  71623. /**
  71624. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  71625. */
  71626. keysUp: number[];
  71627. /**
  71628. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  71629. */
  71630. keysDown: number[];
  71631. /**
  71632. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  71633. */
  71634. keysLeft: number[];
  71635. /**
  71636. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  71637. */
  71638. keysRight: number[];
  71639. /**
  71640. * Event raised when the camera collide with a mesh in the scene.
  71641. */
  71642. onCollide: (collidedMesh: AbstractMesh) => void;
  71643. private _collider;
  71644. private _needMoveForGravity;
  71645. private _oldPosition;
  71646. private _diffPosition;
  71647. private _newPosition;
  71648. /** @hidden */
  71649. _localDirection: Vector3;
  71650. /** @hidden */
  71651. _transformedDirection: Vector3;
  71652. /**
  71653. * Instantiates a Free Camera.
  71654. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  71655. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  71656. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  71657. * @param name Define the name of the camera in the scene
  71658. * @param position Define the start position of the camera in the scene
  71659. * @param scene Define the scene the camera belongs to
  71660. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  71661. */
  71662. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  71663. /**
  71664. * Attached controls to the current camera.
  71665. * @param element Defines the element the controls should be listened from
  71666. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  71667. */
  71668. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  71669. /**
  71670. * Detach the current controls from the camera.
  71671. * The camera will stop reacting to inputs.
  71672. * @param element Defines the element to stop listening the inputs from
  71673. */
  71674. detachControl(element: HTMLElement): void;
  71675. private _collisionMask;
  71676. /**
  71677. * Define a collision mask to limit the list of object the camera can collide with
  71678. */
  71679. collisionMask: number;
  71680. /** @hidden */
  71681. _collideWithWorld(displacement: Vector3): void;
  71682. private _onCollisionPositionChange;
  71683. /** @hidden */
  71684. _checkInputs(): void;
  71685. /** @hidden */
  71686. _decideIfNeedsToMove(): boolean;
  71687. /** @hidden */
  71688. _updatePosition(): void;
  71689. /**
  71690. * Destroy the camera and release the current resources hold by it.
  71691. */
  71692. dispose(): void;
  71693. /**
  71694. * Gets the current object class name.
  71695. * @return the class name
  71696. */
  71697. getClassName(): string;
  71698. }
  71699. }
  71700. declare module BABYLON {
  71701. /**
  71702. * Represents a gamepad control stick position
  71703. */
  71704. export class StickValues {
  71705. /**
  71706. * The x component of the control stick
  71707. */
  71708. x: number;
  71709. /**
  71710. * The y component of the control stick
  71711. */
  71712. y: number;
  71713. /**
  71714. * Initializes the gamepad x and y control stick values
  71715. * @param x The x component of the gamepad control stick value
  71716. * @param y The y component of the gamepad control stick value
  71717. */
  71718. constructor(
  71719. /**
  71720. * The x component of the control stick
  71721. */
  71722. x: number,
  71723. /**
  71724. * The y component of the control stick
  71725. */
  71726. y: number);
  71727. }
  71728. /**
  71729. * An interface which manages callbacks for gamepad button changes
  71730. */
  71731. export interface GamepadButtonChanges {
  71732. /**
  71733. * Called when a gamepad has been changed
  71734. */
  71735. changed: boolean;
  71736. /**
  71737. * Called when a gamepad press event has been triggered
  71738. */
  71739. pressChanged: boolean;
  71740. /**
  71741. * Called when a touch event has been triggered
  71742. */
  71743. touchChanged: boolean;
  71744. /**
  71745. * Called when a value has changed
  71746. */
  71747. valueChanged: boolean;
  71748. }
  71749. /**
  71750. * Represents a gamepad
  71751. */
  71752. export class Gamepad {
  71753. /**
  71754. * The id of the gamepad
  71755. */
  71756. id: string;
  71757. /**
  71758. * The index of the gamepad
  71759. */
  71760. index: number;
  71761. /**
  71762. * The browser gamepad
  71763. */
  71764. browserGamepad: any;
  71765. /**
  71766. * Specifies what type of gamepad this represents
  71767. */
  71768. type: number;
  71769. private _leftStick;
  71770. private _rightStick;
  71771. /** @hidden */
  71772. _isConnected: boolean;
  71773. private _leftStickAxisX;
  71774. private _leftStickAxisY;
  71775. private _rightStickAxisX;
  71776. private _rightStickAxisY;
  71777. /**
  71778. * Triggered when the left control stick has been changed
  71779. */
  71780. private _onleftstickchanged;
  71781. /**
  71782. * Triggered when the right control stick has been changed
  71783. */
  71784. private _onrightstickchanged;
  71785. /**
  71786. * Represents a gamepad controller
  71787. */
  71788. static GAMEPAD: number;
  71789. /**
  71790. * Represents a generic controller
  71791. */
  71792. static GENERIC: number;
  71793. /**
  71794. * Represents an XBox controller
  71795. */
  71796. static XBOX: number;
  71797. /**
  71798. * Represents a pose-enabled controller
  71799. */
  71800. static POSE_ENABLED: number;
  71801. /**
  71802. * Specifies whether the left control stick should be Y-inverted
  71803. */
  71804. protected _invertLeftStickY: boolean;
  71805. /**
  71806. * Specifies if the gamepad has been connected
  71807. */
  71808. readonly isConnected: boolean;
  71809. /**
  71810. * Initializes the gamepad
  71811. * @param id The id of the gamepad
  71812. * @param index The index of the gamepad
  71813. * @param browserGamepad The browser gamepad
  71814. * @param leftStickX The x component of the left joystick
  71815. * @param leftStickY The y component of the left joystick
  71816. * @param rightStickX The x component of the right joystick
  71817. * @param rightStickY The y component of the right joystick
  71818. */
  71819. constructor(
  71820. /**
  71821. * The id of the gamepad
  71822. */
  71823. id: string,
  71824. /**
  71825. * The index of the gamepad
  71826. */
  71827. index: number,
  71828. /**
  71829. * The browser gamepad
  71830. */
  71831. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  71832. /**
  71833. * Callback triggered when the left joystick has changed
  71834. * @param callback
  71835. */
  71836. onleftstickchanged(callback: (values: StickValues) => void): void;
  71837. /**
  71838. * Callback triggered when the right joystick has changed
  71839. * @param callback
  71840. */
  71841. onrightstickchanged(callback: (values: StickValues) => void): void;
  71842. /**
  71843. * Gets the left joystick
  71844. */
  71845. /**
  71846. * Sets the left joystick values
  71847. */
  71848. leftStick: StickValues;
  71849. /**
  71850. * Gets the right joystick
  71851. */
  71852. /**
  71853. * Sets the right joystick value
  71854. */
  71855. rightStick: StickValues;
  71856. /**
  71857. * Updates the gamepad joystick positions
  71858. */
  71859. update(): void;
  71860. /**
  71861. * Disposes the gamepad
  71862. */
  71863. dispose(): void;
  71864. }
  71865. /**
  71866. * Represents a generic gamepad
  71867. */
  71868. export class GenericPad extends Gamepad {
  71869. private _buttons;
  71870. private _onbuttondown;
  71871. private _onbuttonup;
  71872. /**
  71873. * Observable triggered when a button has been pressed
  71874. */
  71875. onButtonDownObservable: Observable<number>;
  71876. /**
  71877. * Observable triggered when a button has been released
  71878. */
  71879. onButtonUpObservable: Observable<number>;
  71880. /**
  71881. * Callback triggered when a button has been pressed
  71882. * @param callback Called when a button has been pressed
  71883. */
  71884. onbuttondown(callback: (buttonPressed: number) => void): void;
  71885. /**
  71886. * Callback triggered when a button has been released
  71887. * @param callback Called when a button has been released
  71888. */
  71889. onbuttonup(callback: (buttonReleased: number) => void): void;
  71890. /**
  71891. * Initializes the generic gamepad
  71892. * @param id The id of the generic gamepad
  71893. * @param index The index of the generic gamepad
  71894. * @param browserGamepad The browser gamepad
  71895. */
  71896. constructor(id: string, index: number, browserGamepad: any);
  71897. private _setButtonValue;
  71898. /**
  71899. * Updates the generic gamepad
  71900. */
  71901. update(): void;
  71902. /**
  71903. * Disposes the generic gamepad
  71904. */
  71905. dispose(): void;
  71906. }
  71907. }
  71908. declare module BABYLON {
  71909. /**
  71910. * Defines the types of pose enabled controllers that are supported
  71911. */
  71912. export enum PoseEnabledControllerType {
  71913. /**
  71914. * HTC Vive
  71915. */
  71916. VIVE = 0,
  71917. /**
  71918. * Oculus Rift
  71919. */
  71920. OCULUS = 1,
  71921. /**
  71922. * Windows mixed reality
  71923. */
  71924. WINDOWS = 2,
  71925. /**
  71926. * Samsung gear VR
  71927. */
  71928. GEAR_VR = 3,
  71929. /**
  71930. * Google Daydream
  71931. */
  71932. DAYDREAM = 4,
  71933. /**
  71934. * Generic
  71935. */
  71936. GENERIC = 5
  71937. }
  71938. /**
  71939. * Defines the MutableGamepadButton interface for the state of a gamepad button
  71940. */
  71941. export interface MutableGamepadButton {
  71942. /**
  71943. * Value of the button/trigger
  71944. */
  71945. value: number;
  71946. /**
  71947. * If the button/trigger is currently touched
  71948. */
  71949. touched: boolean;
  71950. /**
  71951. * If the button/trigger is currently pressed
  71952. */
  71953. pressed: boolean;
  71954. }
  71955. /**
  71956. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  71957. * @hidden
  71958. */
  71959. export interface ExtendedGamepadButton extends GamepadButton {
  71960. /**
  71961. * If the button/trigger is currently pressed
  71962. */
  71963. readonly pressed: boolean;
  71964. /**
  71965. * If the button/trigger is currently touched
  71966. */
  71967. readonly touched: boolean;
  71968. /**
  71969. * Value of the button/trigger
  71970. */
  71971. readonly value: number;
  71972. }
  71973. /** @hidden */
  71974. export interface _GamePadFactory {
  71975. /**
  71976. * Returns wether or not the current gamepad can be created for this type of controller.
  71977. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  71978. * @returns true if it can be created, otherwise false
  71979. */
  71980. canCreate(gamepadInfo: any): boolean;
  71981. /**
  71982. * Creates a new instance of the Gamepad.
  71983. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  71984. * @returns the new gamepad instance
  71985. */
  71986. create(gamepadInfo: any): Gamepad;
  71987. }
  71988. /**
  71989. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  71990. */
  71991. export class PoseEnabledControllerHelper {
  71992. /** @hidden */
  71993. static _ControllerFactories: _GamePadFactory[];
  71994. /** @hidden */
  71995. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  71996. /**
  71997. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  71998. * @param vrGamepad the gamepad to initialized
  71999. * @returns a vr controller of the type the gamepad identified as
  72000. */
  72001. static InitiateController(vrGamepad: any): Gamepad;
  72002. }
  72003. /**
  72004. * Defines the PoseEnabledController object that contains state of a vr capable controller
  72005. */
  72006. export class PoseEnabledController extends Gamepad implements PoseControlled {
  72007. private _deviceRoomPosition;
  72008. private _deviceRoomRotationQuaternion;
  72009. /**
  72010. * The device position in babylon space
  72011. */
  72012. devicePosition: Vector3;
  72013. /**
  72014. * The device rotation in babylon space
  72015. */
  72016. deviceRotationQuaternion: Quaternion;
  72017. /**
  72018. * The scale factor of the device in babylon space
  72019. */
  72020. deviceScaleFactor: number;
  72021. /**
  72022. * (Likely devicePosition should be used instead) The device position in its room space
  72023. */
  72024. position: Vector3;
  72025. /**
  72026. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  72027. */
  72028. rotationQuaternion: Quaternion;
  72029. /**
  72030. * The type of controller (Eg. Windows mixed reality)
  72031. */
  72032. controllerType: PoseEnabledControllerType;
  72033. protected _calculatedPosition: Vector3;
  72034. private _calculatedRotation;
  72035. /**
  72036. * The raw pose from the device
  72037. */
  72038. rawPose: DevicePose;
  72039. private _trackPosition;
  72040. private _maxRotationDistFromHeadset;
  72041. private _draggedRoomRotation;
  72042. /**
  72043. * @hidden
  72044. */
  72045. _disableTrackPosition(fixedPosition: Vector3): void;
  72046. /**
  72047. * Internal, the mesh attached to the controller
  72048. * @hidden
  72049. */
  72050. _mesh: Nullable<AbstractMesh>;
  72051. private _poseControlledCamera;
  72052. private _leftHandSystemQuaternion;
  72053. /**
  72054. * Internal, matrix used to convert room space to babylon space
  72055. * @hidden
  72056. */
  72057. _deviceToWorld: Matrix;
  72058. /**
  72059. * Node to be used when casting a ray from the controller
  72060. * @hidden
  72061. */
  72062. _pointingPoseNode: Nullable<TransformNode>;
  72063. /**
  72064. * Name of the child mesh that can be used to cast a ray from the controller
  72065. */
  72066. static readonly POINTING_POSE: string;
  72067. /**
  72068. * Creates a new PoseEnabledController from a gamepad
  72069. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  72070. */
  72071. constructor(browserGamepad: any);
  72072. private _workingMatrix;
  72073. /**
  72074. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  72075. */
  72076. update(): void;
  72077. /**
  72078. * Updates only the pose device and mesh without doing any button event checking
  72079. */
  72080. protected _updatePoseAndMesh(): void;
  72081. /**
  72082. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  72083. * @param poseData raw pose fromthe device
  72084. */
  72085. updateFromDevice(poseData: DevicePose): void;
  72086. /**
  72087. * @hidden
  72088. */
  72089. _meshAttachedObservable: Observable<AbstractMesh>;
  72090. /**
  72091. * Attaches a mesh to the controller
  72092. * @param mesh the mesh to be attached
  72093. */
  72094. attachToMesh(mesh: AbstractMesh): void;
  72095. /**
  72096. * Attaches the controllers mesh to a camera
  72097. * @param camera the camera the mesh should be attached to
  72098. */
  72099. attachToPoseControlledCamera(camera: TargetCamera): void;
  72100. /**
  72101. * Disposes of the controller
  72102. */
  72103. dispose(): void;
  72104. /**
  72105. * The mesh that is attached to the controller
  72106. */
  72107. readonly mesh: Nullable<AbstractMesh>;
  72108. /**
  72109. * Gets the ray of the controller in the direction the controller is pointing
  72110. * @param length the length the resulting ray should be
  72111. * @returns a ray in the direction the controller is pointing
  72112. */
  72113. getForwardRay(length?: number): Ray;
  72114. }
  72115. }
  72116. declare module BABYLON {
  72117. /**
  72118. * Defines the WebVRController object that represents controllers tracked in 3D space
  72119. */
  72120. export abstract class WebVRController extends PoseEnabledController {
  72121. /**
  72122. * Internal, the default controller model for the controller
  72123. */
  72124. protected _defaultModel: AbstractMesh;
  72125. /**
  72126. * Fired when the trigger state has changed
  72127. */
  72128. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  72129. /**
  72130. * Fired when the main button state has changed
  72131. */
  72132. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  72133. /**
  72134. * Fired when the secondary button state has changed
  72135. */
  72136. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  72137. /**
  72138. * Fired when the pad state has changed
  72139. */
  72140. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  72141. /**
  72142. * Fired when controllers stick values have changed
  72143. */
  72144. onPadValuesChangedObservable: Observable<StickValues>;
  72145. /**
  72146. * Array of button availible on the controller
  72147. */
  72148. protected _buttons: Array<MutableGamepadButton>;
  72149. private _onButtonStateChange;
  72150. /**
  72151. * Fired when a controller button's state has changed
  72152. * @param callback the callback containing the button that was modified
  72153. */
  72154. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  72155. /**
  72156. * X and Y axis corrisponding to the controllers joystick
  72157. */
  72158. pad: StickValues;
  72159. /**
  72160. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  72161. */
  72162. hand: string;
  72163. /**
  72164. * The default controller model for the controller
  72165. */
  72166. readonly defaultModel: AbstractMesh;
  72167. /**
  72168. * Creates a new WebVRController from a gamepad
  72169. * @param vrGamepad the gamepad that the WebVRController should be created from
  72170. */
  72171. constructor(vrGamepad: any);
  72172. /**
  72173. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  72174. */
  72175. update(): void;
  72176. /**
  72177. * Function to be called when a button is modified
  72178. */
  72179. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  72180. /**
  72181. * Loads a mesh and attaches it to the controller
  72182. * @param scene the scene the mesh should be added to
  72183. * @param meshLoaded callback for when the mesh has been loaded
  72184. */
  72185. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  72186. private _setButtonValue;
  72187. private _changes;
  72188. private _checkChanges;
  72189. /**
  72190. * Disposes of th webVRCOntroller
  72191. */
  72192. dispose(): void;
  72193. }
  72194. }
  72195. declare module BABYLON {
  72196. /**
  72197. * The HemisphericLight simulates the ambient environment light,
  72198. * so the passed direction is the light reflection direction, not the incoming direction.
  72199. */
  72200. export class HemisphericLight extends Light {
  72201. /**
  72202. * The groundColor is the light in the opposite direction to the one specified during creation.
  72203. * 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.
  72204. */
  72205. groundColor: Color3;
  72206. /**
  72207. * The light reflection direction, not the incoming direction.
  72208. */
  72209. direction: Vector3;
  72210. /**
  72211. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  72212. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  72213. * The HemisphericLight can't cast shadows.
  72214. * Documentation : https://doc.babylonjs.com/babylon101/lights
  72215. * @param name The friendly name of the light
  72216. * @param direction The direction of the light reflection
  72217. * @param scene The scene the light belongs to
  72218. */
  72219. constructor(name: string, direction: Vector3, scene: Scene);
  72220. protected _buildUniformLayout(): void;
  72221. /**
  72222. * Returns the string "HemisphericLight".
  72223. * @return The class name
  72224. */
  72225. getClassName(): string;
  72226. /**
  72227. * Sets the HemisphericLight direction towards the passed target (Vector3).
  72228. * Returns the updated direction.
  72229. * @param target The target the direction should point to
  72230. * @return The computed direction
  72231. */
  72232. setDirectionToTarget(target: Vector3): Vector3;
  72233. /**
  72234. * Returns the shadow generator associated to the light.
  72235. * @returns Always null for hemispheric lights because it does not support shadows.
  72236. */
  72237. getShadowGenerator(): Nullable<IShadowGenerator>;
  72238. /**
  72239. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  72240. * @param effect The effect to update
  72241. * @param lightIndex The index of the light in the effect to update
  72242. * @returns The hemispheric light
  72243. */
  72244. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  72245. /**
  72246. * Computes the world matrix of the node
  72247. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  72248. * @param useWasUpdatedFlag defines a reserved property
  72249. * @returns the world matrix
  72250. */
  72251. computeWorldMatrix(): Matrix;
  72252. /**
  72253. * Returns the integer 3.
  72254. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  72255. */
  72256. getTypeID(): number;
  72257. /**
  72258. * Prepares the list of defines specific to the light type.
  72259. * @param defines the list of defines
  72260. * @param lightIndex defines the index of the light for the effect
  72261. */
  72262. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  72263. }
  72264. }
  72265. declare module BABYLON {
  72266. /** @hidden */
  72267. export var vrMultiviewToSingleviewPixelShader: {
  72268. name: string;
  72269. shader: string;
  72270. };
  72271. }
  72272. declare module BABYLON {
  72273. /**
  72274. * Renders to multiple views with a single draw call
  72275. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  72276. */
  72277. export class MultiviewRenderTarget extends RenderTargetTexture {
  72278. /**
  72279. * Creates a multiview render target
  72280. * @param scene scene used with the render target
  72281. * @param size the size of the render target (used for each view)
  72282. */
  72283. constructor(scene: Scene, size?: number | {
  72284. width: number;
  72285. height: number;
  72286. } | {
  72287. ratio: number;
  72288. });
  72289. /**
  72290. * @hidden
  72291. * @param faceIndex the face index, if its a cube texture
  72292. */
  72293. _bindFrameBuffer(faceIndex?: number): void;
  72294. /**
  72295. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  72296. * @returns the view count
  72297. */
  72298. getViewCount(): number;
  72299. }
  72300. }
  72301. declare module BABYLON {
  72302. interface Engine {
  72303. /**
  72304. * Creates a new multiview render target
  72305. * @param width defines the width of the texture
  72306. * @param height defines the height of the texture
  72307. * @returns the created multiview texture
  72308. */
  72309. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  72310. /**
  72311. * Binds a multiview framebuffer to be drawn to
  72312. * @param multiviewTexture texture to bind
  72313. */
  72314. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  72315. }
  72316. interface Camera {
  72317. /**
  72318. * @hidden
  72319. * 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)
  72320. */
  72321. _useMultiviewToSingleView: boolean;
  72322. /**
  72323. * @hidden
  72324. * 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)
  72325. */
  72326. _multiviewTexture: Nullable<RenderTargetTexture>;
  72327. /**
  72328. * @hidden
  72329. * ensures the multiview texture of the camera exists and has the specified width/height
  72330. * @param width height to set on the multiview texture
  72331. * @param height width to set on the multiview texture
  72332. */
  72333. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  72334. }
  72335. interface Scene {
  72336. /** @hidden */
  72337. _transformMatrixR: Matrix;
  72338. /** @hidden */
  72339. _multiviewSceneUbo: Nullable<UniformBuffer>;
  72340. /** @hidden */
  72341. _createMultiviewUbo(): void;
  72342. /** @hidden */
  72343. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  72344. /** @hidden */
  72345. _renderMultiviewToSingleView(camera: Camera): void;
  72346. }
  72347. }
  72348. declare module BABYLON {
  72349. /**
  72350. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  72351. * This will not be used for webXR as it supports displaying texture arrays directly
  72352. */
  72353. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  72354. /**
  72355. * Initializes a VRMultiviewToSingleview
  72356. * @param name name of the post process
  72357. * @param camera camera to be applied to
  72358. * @param scaleFactor scaling factor to the size of the output texture
  72359. */
  72360. constructor(name: string, camera: Camera, scaleFactor: number);
  72361. }
  72362. }
  72363. declare module BABYLON {
  72364. /**
  72365. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  72366. * IMPORTANT!! The data is right-hand data.
  72367. * @export
  72368. * @interface DevicePose
  72369. */
  72370. export interface DevicePose {
  72371. /**
  72372. * The position of the device, values in array are [x,y,z].
  72373. */
  72374. readonly position: Nullable<Float32Array>;
  72375. /**
  72376. * The linearVelocity of the device, values in array are [x,y,z].
  72377. */
  72378. readonly linearVelocity: Nullable<Float32Array>;
  72379. /**
  72380. * The linearAcceleration of the device, values in array are [x,y,z].
  72381. */
  72382. readonly linearAcceleration: Nullable<Float32Array>;
  72383. /**
  72384. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  72385. */
  72386. readonly orientation: Nullable<Float32Array>;
  72387. /**
  72388. * The angularVelocity of the device, values in array are [x,y,z].
  72389. */
  72390. readonly angularVelocity: Nullable<Float32Array>;
  72391. /**
  72392. * The angularAcceleration of the device, values in array are [x,y,z].
  72393. */
  72394. readonly angularAcceleration: Nullable<Float32Array>;
  72395. }
  72396. /**
  72397. * Interface representing a pose controlled object in Babylon.
  72398. * A pose controlled object has both regular pose values as well as pose values
  72399. * from an external device such as a VR head mounted display
  72400. */
  72401. export interface PoseControlled {
  72402. /**
  72403. * The position of the object in babylon space.
  72404. */
  72405. position: Vector3;
  72406. /**
  72407. * The rotation quaternion of the object in babylon space.
  72408. */
  72409. rotationQuaternion: Quaternion;
  72410. /**
  72411. * The position of the device in babylon space.
  72412. */
  72413. devicePosition?: Vector3;
  72414. /**
  72415. * The rotation quaternion of the device in babylon space.
  72416. */
  72417. deviceRotationQuaternion: Quaternion;
  72418. /**
  72419. * The raw pose coming from the device.
  72420. */
  72421. rawPose: Nullable<DevicePose>;
  72422. /**
  72423. * The scale of the device to be used when translating from device space to babylon space.
  72424. */
  72425. deviceScaleFactor: number;
  72426. /**
  72427. * Updates the poseControlled values based on the input device pose.
  72428. * @param poseData the pose data to update the object with
  72429. */
  72430. updateFromDevice(poseData: DevicePose): void;
  72431. }
  72432. /**
  72433. * Set of options to customize the webVRCamera
  72434. */
  72435. export interface WebVROptions {
  72436. /**
  72437. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  72438. */
  72439. trackPosition?: boolean;
  72440. /**
  72441. * Sets the scale of the vrDevice in babylon space. (default: 1)
  72442. */
  72443. positionScale?: number;
  72444. /**
  72445. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  72446. */
  72447. displayName?: string;
  72448. /**
  72449. * Should the native controller meshes be initialized. (default: true)
  72450. */
  72451. controllerMeshes?: boolean;
  72452. /**
  72453. * Creating a default HemiLight only on controllers. (default: true)
  72454. */
  72455. defaultLightingOnControllers?: boolean;
  72456. /**
  72457. * If you don't want to use the default VR button of the helper. (default: false)
  72458. */
  72459. useCustomVRButton?: boolean;
  72460. /**
  72461. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  72462. */
  72463. customVRButton?: HTMLButtonElement;
  72464. /**
  72465. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  72466. */
  72467. rayLength?: number;
  72468. /**
  72469. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  72470. */
  72471. defaultHeight?: number;
  72472. /**
  72473. * If multiview should be used if availible (default: false)
  72474. */
  72475. useMultiview?: boolean;
  72476. }
  72477. /**
  72478. * This represents a WebVR camera.
  72479. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  72480. * @example http://doc.babylonjs.com/how_to/webvr_camera
  72481. */
  72482. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  72483. private webVROptions;
  72484. /**
  72485. * @hidden
  72486. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  72487. */
  72488. _vrDevice: any;
  72489. /**
  72490. * The rawPose of the vrDevice.
  72491. */
  72492. rawPose: Nullable<DevicePose>;
  72493. private _onVREnabled;
  72494. private _specsVersion;
  72495. private _attached;
  72496. private _frameData;
  72497. protected _descendants: Array<Node>;
  72498. private _deviceRoomPosition;
  72499. /** @hidden */
  72500. _deviceRoomRotationQuaternion: Quaternion;
  72501. private _standingMatrix;
  72502. /**
  72503. * Represents device position in babylon space.
  72504. */
  72505. devicePosition: Vector3;
  72506. /**
  72507. * Represents device rotation in babylon space.
  72508. */
  72509. deviceRotationQuaternion: Quaternion;
  72510. /**
  72511. * The scale of the device to be used when translating from device space to babylon space.
  72512. */
  72513. deviceScaleFactor: number;
  72514. private _deviceToWorld;
  72515. private _worldToDevice;
  72516. /**
  72517. * References to the webVR controllers for the vrDevice.
  72518. */
  72519. controllers: Array<WebVRController>;
  72520. /**
  72521. * Emits an event when a controller is attached.
  72522. */
  72523. onControllersAttachedObservable: Observable<WebVRController[]>;
  72524. /**
  72525. * Emits an event when a controller's mesh has been loaded;
  72526. */
  72527. onControllerMeshLoadedObservable: Observable<WebVRController>;
  72528. /**
  72529. * Emits an event when the HMD's pose has been updated.
  72530. */
  72531. onPoseUpdatedFromDeviceObservable: Observable<any>;
  72532. private _poseSet;
  72533. /**
  72534. * If the rig cameras be used as parent instead of this camera.
  72535. */
  72536. rigParenting: boolean;
  72537. private _lightOnControllers;
  72538. private _defaultHeight?;
  72539. /**
  72540. * Instantiates a WebVRFreeCamera.
  72541. * @param name The name of the WebVRFreeCamera
  72542. * @param position The starting anchor position for the camera
  72543. * @param scene The scene the camera belongs to
  72544. * @param webVROptions a set of customizable options for the webVRCamera
  72545. */
  72546. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  72547. /**
  72548. * Gets the device distance from the ground in meters.
  72549. * @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.
  72550. */
  72551. deviceDistanceToRoomGround(): number;
  72552. /**
  72553. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  72554. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  72555. */
  72556. useStandingMatrix(callback?: (bool: boolean) => void): void;
  72557. /**
  72558. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  72559. * @returns A promise with a boolean set to if the standing matrix is supported.
  72560. */
  72561. useStandingMatrixAsync(): Promise<boolean>;
  72562. /**
  72563. * Disposes the camera
  72564. */
  72565. dispose(): void;
  72566. /**
  72567. * Gets a vrController by name.
  72568. * @param name The name of the controller to retreive
  72569. * @returns the controller matching the name specified or null if not found
  72570. */
  72571. getControllerByName(name: string): Nullable<WebVRController>;
  72572. private _leftController;
  72573. /**
  72574. * The controller corrisponding to the users left hand.
  72575. */
  72576. readonly leftController: Nullable<WebVRController>;
  72577. private _rightController;
  72578. /**
  72579. * The controller corrisponding to the users right hand.
  72580. */
  72581. readonly rightController: Nullable<WebVRController>;
  72582. /**
  72583. * Casts a ray forward from the vrCamera's gaze.
  72584. * @param length Length of the ray (default: 100)
  72585. * @returns the ray corrisponding to the gaze
  72586. */
  72587. getForwardRay(length?: number): Ray;
  72588. /**
  72589. * @hidden
  72590. * Updates the camera based on device's frame data
  72591. */
  72592. _checkInputs(): void;
  72593. /**
  72594. * Updates the poseControlled values based on the input device pose.
  72595. * @param poseData Pose coming from the device
  72596. */
  72597. updateFromDevice(poseData: DevicePose): void;
  72598. private _htmlElementAttached;
  72599. private _detachIfAttached;
  72600. /**
  72601. * WebVR's attach control will start broadcasting frames to the device.
  72602. * Note that in certain browsers (chrome for example) this function must be called
  72603. * within a user-interaction callback. Example:
  72604. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  72605. *
  72606. * @param element html element to attach the vrDevice to
  72607. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  72608. */
  72609. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  72610. /**
  72611. * Detaches the camera from the html element and disables VR
  72612. *
  72613. * @param element html element to detach from
  72614. */
  72615. detachControl(element: HTMLElement): void;
  72616. /**
  72617. * @returns the name of this class
  72618. */
  72619. getClassName(): string;
  72620. /**
  72621. * Calls resetPose on the vrDisplay
  72622. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  72623. */
  72624. resetToCurrentRotation(): void;
  72625. /**
  72626. * @hidden
  72627. * Updates the rig cameras (left and right eye)
  72628. */
  72629. _updateRigCameras(): void;
  72630. private _workingVector;
  72631. private _oneVector;
  72632. private _workingMatrix;
  72633. private updateCacheCalled;
  72634. private _correctPositionIfNotTrackPosition;
  72635. /**
  72636. * @hidden
  72637. * Updates the cached values of the camera
  72638. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  72639. */
  72640. _updateCache(ignoreParentClass?: boolean): void;
  72641. /**
  72642. * @hidden
  72643. * Get current device position in babylon world
  72644. */
  72645. _computeDevicePosition(): void;
  72646. /**
  72647. * Updates the current device position and rotation in the babylon world
  72648. */
  72649. update(): void;
  72650. /**
  72651. * @hidden
  72652. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  72653. * @returns an identity matrix
  72654. */
  72655. _getViewMatrix(): Matrix;
  72656. private _tmpMatrix;
  72657. /**
  72658. * This function is called by the two RIG cameras.
  72659. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  72660. * @hidden
  72661. */
  72662. _getWebVRViewMatrix(): Matrix;
  72663. /** @hidden */
  72664. _getWebVRProjectionMatrix(): Matrix;
  72665. private _onGamepadConnectedObserver;
  72666. private _onGamepadDisconnectedObserver;
  72667. private _updateCacheWhenTrackingDisabledObserver;
  72668. /**
  72669. * Initializes the controllers and their meshes
  72670. */
  72671. initControllers(): void;
  72672. }
  72673. }
  72674. declare module BABYLON {
  72675. /**
  72676. * Size options for a post process
  72677. */
  72678. export type PostProcessOptions = {
  72679. width: number;
  72680. height: number;
  72681. };
  72682. /**
  72683. * PostProcess can be used to apply a shader to a texture after it has been rendered
  72684. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  72685. */
  72686. export class PostProcess {
  72687. /** Name of the PostProcess. */
  72688. name: string;
  72689. /**
  72690. * Gets or sets the unique id of the post process
  72691. */
  72692. uniqueId: number;
  72693. /**
  72694. * Width of the texture to apply the post process on
  72695. */
  72696. width: number;
  72697. /**
  72698. * Height of the texture to apply the post process on
  72699. */
  72700. height: number;
  72701. /**
  72702. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  72703. * @hidden
  72704. */
  72705. _outputTexture: Nullable<InternalTexture>;
  72706. /**
  72707. * Sampling mode used by the shader
  72708. * See https://doc.babylonjs.com/classes/3.1/texture
  72709. */
  72710. renderTargetSamplingMode: number;
  72711. /**
  72712. * Clear color to use when screen clearing
  72713. */
  72714. clearColor: Color4;
  72715. /**
  72716. * If the buffer needs to be cleared before applying the post process. (default: true)
  72717. * Should be set to false if shader will overwrite all previous pixels.
  72718. */
  72719. autoClear: boolean;
  72720. /**
  72721. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  72722. */
  72723. alphaMode: number;
  72724. /**
  72725. * Sets the setAlphaBlendConstants of the babylon engine
  72726. */
  72727. alphaConstants: Color4;
  72728. /**
  72729. * Animations to be used for the post processing
  72730. */
  72731. animations: Animation[];
  72732. /**
  72733. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  72734. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  72735. */
  72736. enablePixelPerfectMode: boolean;
  72737. /**
  72738. * Force the postprocess to be applied without taking in account viewport
  72739. */
  72740. forceFullscreenViewport: boolean;
  72741. /**
  72742. * List of inspectable custom properties (used by the Inspector)
  72743. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  72744. */
  72745. inspectableCustomProperties: IInspectable[];
  72746. /**
  72747. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  72748. *
  72749. * | Value | Type | Description |
  72750. * | ----- | ----------------------------------- | ----------- |
  72751. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  72752. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  72753. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  72754. *
  72755. */
  72756. scaleMode: number;
  72757. /**
  72758. * Force textures to be a power of two (default: false)
  72759. */
  72760. alwaysForcePOT: boolean;
  72761. private _samples;
  72762. /**
  72763. * Number of sample textures (default: 1)
  72764. */
  72765. samples: number;
  72766. /**
  72767. * Modify the scale of the post process to be the same as the viewport (default: false)
  72768. */
  72769. adaptScaleToCurrentViewport: boolean;
  72770. private _camera;
  72771. private _scene;
  72772. private _engine;
  72773. private _options;
  72774. private _reusable;
  72775. private _textureType;
  72776. /**
  72777. * Smart array of input and output textures for the post process.
  72778. * @hidden
  72779. */
  72780. _textures: SmartArray<InternalTexture>;
  72781. /**
  72782. * The index in _textures that corresponds to the output texture.
  72783. * @hidden
  72784. */
  72785. _currentRenderTextureInd: number;
  72786. private _effect;
  72787. private _samplers;
  72788. private _fragmentUrl;
  72789. private _vertexUrl;
  72790. private _parameters;
  72791. private _scaleRatio;
  72792. protected _indexParameters: any;
  72793. private _shareOutputWithPostProcess;
  72794. private _texelSize;
  72795. private _forcedOutputTexture;
  72796. /**
  72797. * Returns the fragment url or shader name used in the post process.
  72798. * @returns the fragment url or name in the shader store.
  72799. */
  72800. getEffectName(): string;
  72801. /**
  72802. * An event triggered when the postprocess is activated.
  72803. */
  72804. onActivateObservable: Observable<Camera>;
  72805. private _onActivateObserver;
  72806. /**
  72807. * A function that is added to the onActivateObservable
  72808. */
  72809. onActivate: Nullable<(camera: Camera) => void>;
  72810. /**
  72811. * An event triggered when the postprocess changes its size.
  72812. */
  72813. onSizeChangedObservable: Observable<PostProcess>;
  72814. private _onSizeChangedObserver;
  72815. /**
  72816. * A function that is added to the onSizeChangedObservable
  72817. */
  72818. onSizeChanged: (postProcess: PostProcess) => void;
  72819. /**
  72820. * An event triggered when the postprocess applies its effect.
  72821. */
  72822. onApplyObservable: Observable<Effect>;
  72823. private _onApplyObserver;
  72824. /**
  72825. * A function that is added to the onApplyObservable
  72826. */
  72827. onApply: (effect: Effect) => void;
  72828. /**
  72829. * An event triggered before rendering the postprocess
  72830. */
  72831. onBeforeRenderObservable: Observable<Effect>;
  72832. private _onBeforeRenderObserver;
  72833. /**
  72834. * A function that is added to the onBeforeRenderObservable
  72835. */
  72836. onBeforeRender: (effect: Effect) => void;
  72837. /**
  72838. * An event triggered after rendering the postprocess
  72839. */
  72840. onAfterRenderObservable: Observable<Effect>;
  72841. private _onAfterRenderObserver;
  72842. /**
  72843. * A function that is added to the onAfterRenderObservable
  72844. */
  72845. onAfterRender: (efect: Effect) => void;
  72846. /**
  72847. * 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
  72848. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  72849. */
  72850. inputTexture: InternalTexture;
  72851. /**
  72852. * Gets the camera which post process is applied to.
  72853. * @returns The camera the post process is applied to.
  72854. */
  72855. getCamera(): Camera;
  72856. /**
  72857. * Gets the texel size of the postprocess.
  72858. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  72859. */
  72860. readonly texelSize: Vector2;
  72861. /**
  72862. * Creates a new instance PostProcess
  72863. * @param name The name of the PostProcess.
  72864. * @param fragmentUrl The url of the fragment shader to be used.
  72865. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  72866. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  72867. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  72868. * @param camera The camera to apply the render pass to.
  72869. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72870. * @param engine The engine which the post process will be applied. (default: current engine)
  72871. * @param reusable If the post process can be reused on the same frame. (default: false)
  72872. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  72873. * @param textureType Type of textures used when performing the post process. (default: 0)
  72874. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  72875. * @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
  72876. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  72877. */
  72878. constructor(
  72879. /** Name of the PostProcess. */
  72880. 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);
  72881. /**
  72882. * Gets a string idenfifying the name of the class
  72883. * @returns "PostProcess" string
  72884. */
  72885. getClassName(): string;
  72886. /**
  72887. * Gets the engine which this post process belongs to.
  72888. * @returns The engine the post process was enabled with.
  72889. */
  72890. getEngine(): Engine;
  72891. /**
  72892. * The effect that is created when initializing the post process.
  72893. * @returns The created effect corrisponding the the postprocess.
  72894. */
  72895. getEffect(): Effect;
  72896. /**
  72897. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  72898. * @param postProcess The post process to share the output with.
  72899. * @returns This post process.
  72900. */
  72901. shareOutputWith(postProcess: PostProcess): PostProcess;
  72902. /**
  72903. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  72904. * This should be called if the post process that shares output with this post process is disabled/disposed.
  72905. */
  72906. useOwnOutput(): void;
  72907. /**
  72908. * Updates the effect with the current post process compile time values and recompiles the shader.
  72909. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  72910. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  72911. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  72912. * @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
  72913. * @param onCompiled Called when the shader has been compiled.
  72914. * @param onError Called if there is an error when compiling a shader.
  72915. */
  72916. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  72917. /**
  72918. * The post process is reusable if it can be used multiple times within one frame.
  72919. * @returns If the post process is reusable
  72920. */
  72921. isReusable(): boolean;
  72922. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  72923. markTextureDirty(): void;
  72924. /**
  72925. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  72926. * 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.
  72927. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  72928. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  72929. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  72930. * @returns The target texture that was bound to be written to.
  72931. */
  72932. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  72933. /**
  72934. * If the post process is supported.
  72935. */
  72936. readonly isSupported: boolean;
  72937. /**
  72938. * The aspect ratio of the output texture.
  72939. */
  72940. readonly aspectRatio: number;
  72941. /**
  72942. * Get a value indicating if the post-process is ready to be used
  72943. * @returns true if the post-process is ready (shader is compiled)
  72944. */
  72945. isReady(): boolean;
  72946. /**
  72947. * Binds all textures and uniforms to the shader, this will be run on every pass.
  72948. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  72949. */
  72950. apply(): Nullable<Effect>;
  72951. private _disposeTextures;
  72952. /**
  72953. * Disposes the post process.
  72954. * @param camera The camera to dispose the post process on.
  72955. */
  72956. dispose(camera?: Camera): void;
  72957. }
  72958. }
  72959. declare module BABYLON {
  72960. /**
  72961. * PostProcessManager is used to manage one or more post processes or post process pipelines
  72962. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  72963. */
  72964. export class PostProcessManager {
  72965. private _scene;
  72966. private _indexBuffer;
  72967. private _vertexBuffers;
  72968. /**
  72969. * Creates a new instance PostProcess
  72970. * @param scene The scene that the post process is associated with.
  72971. */
  72972. constructor(scene: Scene);
  72973. private _prepareBuffers;
  72974. private _buildIndexBuffer;
  72975. /**
  72976. * Rebuilds the vertex buffers of the manager.
  72977. * @hidden
  72978. */
  72979. _rebuild(): void;
  72980. /**
  72981. * Prepares a frame to be run through a post process.
  72982. * @param sourceTexture The input texture to the post procesess. (default: null)
  72983. * @param postProcesses An array of post processes to be run. (default: null)
  72984. * @returns True if the post processes were able to be run.
  72985. * @hidden
  72986. */
  72987. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  72988. /**
  72989. * Manually render a set of post processes to a texture.
  72990. * @param postProcesses An array of post processes to be run.
  72991. * @param targetTexture The target texture to render to.
  72992. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  72993. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  72994. * @param lodLevel defines which lod of the texture to render to
  72995. */
  72996. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  72997. /**
  72998. * Finalize the result of the output of the postprocesses.
  72999. * @param doNotPresent If true the result will not be displayed to the screen.
  73000. * @param targetTexture The target texture to render to.
  73001. * @param faceIndex The index of the face to bind the target texture to.
  73002. * @param postProcesses The array of post processes to render.
  73003. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  73004. * @hidden
  73005. */
  73006. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  73007. /**
  73008. * Disposes of the post process manager.
  73009. */
  73010. dispose(): void;
  73011. }
  73012. }
  73013. declare module BABYLON {
  73014. interface AbstractScene {
  73015. /**
  73016. * The list of layers (background and foreground) of the scene
  73017. */
  73018. layers: Array<Layer>;
  73019. }
  73020. /**
  73021. * Defines the layer scene component responsible to manage any layers
  73022. * in a given scene.
  73023. */
  73024. export class LayerSceneComponent implements ISceneComponent {
  73025. /**
  73026. * The component name helpfull to identify the component in the list of scene components.
  73027. */
  73028. readonly name: string;
  73029. /**
  73030. * The scene the component belongs to.
  73031. */
  73032. scene: Scene;
  73033. private _engine;
  73034. /**
  73035. * Creates a new instance of the component for the given scene
  73036. * @param scene Defines the scene to register the component in
  73037. */
  73038. constructor(scene: Scene);
  73039. /**
  73040. * Registers the component in a given scene
  73041. */
  73042. register(): void;
  73043. /**
  73044. * Rebuilds the elements related to this component in case of
  73045. * context lost for instance.
  73046. */
  73047. rebuild(): void;
  73048. /**
  73049. * Disposes the component and the associated ressources.
  73050. */
  73051. dispose(): void;
  73052. private _draw;
  73053. private _drawCameraPredicate;
  73054. private _drawCameraBackground;
  73055. private _drawCameraForeground;
  73056. private _drawRenderTargetPredicate;
  73057. private _drawRenderTargetBackground;
  73058. private _drawRenderTargetForeground;
  73059. }
  73060. }
  73061. declare module BABYLON {
  73062. /** @hidden */
  73063. export var layerPixelShader: {
  73064. name: string;
  73065. shader: string;
  73066. };
  73067. }
  73068. declare module BABYLON {
  73069. /** @hidden */
  73070. export var layerVertexShader: {
  73071. name: string;
  73072. shader: string;
  73073. };
  73074. }
  73075. declare module BABYLON {
  73076. /**
  73077. * This represents a full screen 2d layer.
  73078. * This can be useful to display a picture in the background of your scene for instance.
  73079. * @see https://www.babylonjs-playground.com/#08A2BS#1
  73080. */
  73081. export class Layer {
  73082. /**
  73083. * Define the name of the layer.
  73084. */
  73085. name: string;
  73086. /**
  73087. * Define the texture the layer should display.
  73088. */
  73089. texture: Nullable<Texture>;
  73090. /**
  73091. * Is the layer in background or foreground.
  73092. */
  73093. isBackground: boolean;
  73094. /**
  73095. * Define the color of the layer (instead of texture).
  73096. */
  73097. color: Color4;
  73098. /**
  73099. * Define the scale of the layer in order to zoom in out of the texture.
  73100. */
  73101. scale: Vector2;
  73102. /**
  73103. * Define an offset for the layer in order to shift the texture.
  73104. */
  73105. offset: Vector2;
  73106. /**
  73107. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  73108. */
  73109. alphaBlendingMode: number;
  73110. /**
  73111. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  73112. * Alpha test will not mix with the background color in case of transparency.
  73113. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  73114. */
  73115. alphaTest: boolean;
  73116. /**
  73117. * Define a mask to restrict the layer to only some of the scene cameras.
  73118. */
  73119. layerMask: number;
  73120. /**
  73121. * Define the list of render target the layer is visible into.
  73122. */
  73123. renderTargetTextures: RenderTargetTexture[];
  73124. /**
  73125. * Define if the layer is only used in renderTarget or if it also
  73126. * renders in the main frame buffer of the canvas.
  73127. */
  73128. renderOnlyInRenderTargetTextures: boolean;
  73129. private _scene;
  73130. private _vertexBuffers;
  73131. private _indexBuffer;
  73132. private _effect;
  73133. private _alphaTestEffect;
  73134. /**
  73135. * An event triggered when the layer is disposed.
  73136. */
  73137. onDisposeObservable: Observable<Layer>;
  73138. private _onDisposeObserver;
  73139. /**
  73140. * Back compatibility with callback before the onDisposeObservable existed.
  73141. * The set callback will be triggered when the layer has been disposed.
  73142. */
  73143. onDispose: () => void;
  73144. /**
  73145. * An event triggered before rendering the scene
  73146. */
  73147. onBeforeRenderObservable: Observable<Layer>;
  73148. private _onBeforeRenderObserver;
  73149. /**
  73150. * Back compatibility with callback before the onBeforeRenderObservable existed.
  73151. * The set callback will be triggered just before rendering the layer.
  73152. */
  73153. onBeforeRender: () => void;
  73154. /**
  73155. * An event triggered after rendering the scene
  73156. */
  73157. onAfterRenderObservable: Observable<Layer>;
  73158. private _onAfterRenderObserver;
  73159. /**
  73160. * Back compatibility with callback before the onAfterRenderObservable existed.
  73161. * The set callback will be triggered just after rendering the layer.
  73162. */
  73163. onAfterRender: () => void;
  73164. /**
  73165. * Instantiates a new layer.
  73166. * This represents a full screen 2d layer.
  73167. * This can be useful to display a picture in the background of your scene for instance.
  73168. * @see https://www.babylonjs-playground.com/#08A2BS#1
  73169. * @param name Define the name of the layer in the scene
  73170. * @param imgUrl Define the url of the texture to display in the layer
  73171. * @param scene Define the scene the layer belongs to
  73172. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  73173. * @param color Defines a color for the layer
  73174. */
  73175. constructor(
  73176. /**
  73177. * Define the name of the layer.
  73178. */
  73179. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  73180. private _createIndexBuffer;
  73181. /** @hidden */
  73182. _rebuild(): void;
  73183. /**
  73184. * Renders the layer in the scene.
  73185. */
  73186. render(): void;
  73187. /**
  73188. * Disposes and releases the associated ressources.
  73189. */
  73190. dispose(): void;
  73191. }
  73192. }
  73193. declare module BABYLON {
  73194. interface AbstractScene {
  73195. /**
  73196. * The list of procedural textures added to the scene
  73197. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  73198. */
  73199. proceduralTextures: Array<ProceduralTexture>;
  73200. }
  73201. /**
  73202. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  73203. * in a given scene.
  73204. */
  73205. export class ProceduralTextureSceneComponent implements ISceneComponent {
  73206. /**
  73207. * The component name helpfull to identify the component in the list of scene components.
  73208. */
  73209. readonly name: string;
  73210. /**
  73211. * The scene the component belongs to.
  73212. */
  73213. scene: Scene;
  73214. /**
  73215. * Creates a new instance of the component for the given scene
  73216. * @param scene Defines the scene to register the component in
  73217. */
  73218. constructor(scene: Scene);
  73219. /**
  73220. * Registers the component in a given scene
  73221. */
  73222. register(): void;
  73223. /**
  73224. * Rebuilds the elements related to this component in case of
  73225. * context lost for instance.
  73226. */
  73227. rebuild(): void;
  73228. /**
  73229. * Disposes the component and the associated ressources.
  73230. */
  73231. dispose(): void;
  73232. private _beforeClear;
  73233. }
  73234. }
  73235. declare module BABYLON {
  73236. /** @hidden */
  73237. export var proceduralVertexShader: {
  73238. name: string;
  73239. shader: string;
  73240. };
  73241. }
  73242. declare module BABYLON {
  73243. /**
  73244. * 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.
  73245. * This is the base class of any Procedural texture and contains most of the shareable code.
  73246. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  73247. */
  73248. export class ProceduralTexture extends Texture {
  73249. isCube: boolean;
  73250. /**
  73251. * Define if the texture is enabled or not (disabled texture will not render)
  73252. */
  73253. isEnabled: boolean;
  73254. /**
  73255. * Define if the texture must be cleared before rendering (default is true)
  73256. */
  73257. autoClear: boolean;
  73258. /**
  73259. * Callback called when the texture is generated
  73260. */
  73261. onGenerated: () => void;
  73262. /**
  73263. * Event raised when the texture is generated
  73264. */
  73265. onGeneratedObservable: Observable<ProceduralTexture>;
  73266. /** @hidden */
  73267. _generateMipMaps: boolean;
  73268. /** @hidden **/
  73269. _effect: Effect;
  73270. /** @hidden */
  73271. _textures: {
  73272. [key: string]: Texture;
  73273. };
  73274. private _size;
  73275. private _currentRefreshId;
  73276. private _refreshRate;
  73277. private _vertexBuffers;
  73278. private _indexBuffer;
  73279. private _uniforms;
  73280. private _samplers;
  73281. private _fragment;
  73282. private _floats;
  73283. private _ints;
  73284. private _floatsArrays;
  73285. private _colors3;
  73286. private _colors4;
  73287. private _vectors2;
  73288. private _vectors3;
  73289. private _matrices;
  73290. private _fallbackTexture;
  73291. private _fallbackTextureUsed;
  73292. private _engine;
  73293. private _cachedDefines;
  73294. private _contentUpdateId;
  73295. private _contentData;
  73296. /**
  73297. * Instantiates a new procedural texture.
  73298. * 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.
  73299. * This is the base class of any Procedural texture and contains most of the shareable code.
  73300. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  73301. * @param name Define the name of the texture
  73302. * @param size Define the size of the texture to create
  73303. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  73304. * @param scene Define the scene the texture belongs to
  73305. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  73306. * @param generateMipMaps Define if the texture should creates mip maps or not
  73307. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  73308. */
  73309. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  73310. /**
  73311. * The effect that is created when initializing the post process.
  73312. * @returns The created effect corrisponding the the postprocess.
  73313. */
  73314. getEffect(): Effect;
  73315. /**
  73316. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  73317. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  73318. */
  73319. getContent(): Nullable<ArrayBufferView>;
  73320. private _createIndexBuffer;
  73321. /** @hidden */
  73322. _rebuild(): void;
  73323. /**
  73324. * Resets the texture in order to recreate its associated resources.
  73325. * This can be called in case of context loss
  73326. */
  73327. reset(): void;
  73328. protected _getDefines(): string;
  73329. /**
  73330. * Is the texture ready to be used ? (rendered at least once)
  73331. * @returns true if ready, otherwise, false.
  73332. */
  73333. isReady(): boolean;
  73334. /**
  73335. * Resets the refresh counter of the texture and start bak from scratch.
  73336. * Could be useful to regenerate the texture if it is setup to render only once.
  73337. */
  73338. resetRefreshCounter(): void;
  73339. /**
  73340. * Set the fragment shader to use in order to render the texture.
  73341. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  73342. */
  73343. setFragment(fragment: any): void;
  73344. /**
  73345. * Define the refresh rate of the texture or the rendering frequency.
  73346. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  73347. */
  73348. refreshRate: number;
  73349. /** @hidden */
  73350. _shouldRender(): boolean;
  73351. /**
  73352. * Get the size the texture is rendering at.
  73353. * @returns the size (texture is always squared)
  73354. */
  73355. getRenderSize(): number;
  73356. /**
  73357. * Resize the texture to new value.
  73358. * @param size Define the new size the texture should have
  73359. * @param generateMipMaps Define whether the new texture should create mip maps
  73360. */
  73361. resize(size: number, generateMipMaps: boolean): void;
  73362. private _checkUniform;
  73363. /**
  73364. * Set a texture in the shader program used to render.
  73365. * @param name Define the name of the uniform samplers as defined in the shader
  73366. * @param texture Define the texture to bind to this sampler
  73367. * @return the texture itself allowing "fluent" like uniform updates
  73368. */
  73369. setTexture(name: string, texture: Texture): ProceduralTexture;
  73370. /**
  73371. * Set a float in the shader.
  73372. * @param name Define the name of the uniform as defined in the shader
  73373. * @param value Define the value to give to the uniform
  73374. * @return the texture itself allowing "fluent" like uniform updates
  73375. */
  73376. setFloat(name: string, value: number): ProceduralTexture;
  73377. /**
  73378. * Set a int in the shader.
  73379. * @param name Define the name of the uniform as defined in the shader
  73380. * @param value Define the value to give to the uniform
  73381. * @return the texture itself allowing "fluent" like uniform updates
  73382. */
  73383. setInt(name: string, value: number): ProceduralTexture;
  73384. /**
  73385. * Set an array of floats in the shader.
  73386. * @param name Define the name of the uniform as defined in the shader
  73387. * @param value Define the value to give to the uniform
  73388. * @return the texture itself allowing "fluent" like uniform updates
  73389. */
  73390. setFloats(name: string, value: number[]): ProceduralTexture;
  73391. /**
  73392. * Set a vec3 in the shader from a Color3.
  73393. * @param name Define the name of the uniform as defined in the shader
  73394. * @param value Define the value to give to the uniform
  73395. * @return the texture itself allowing "fluent" like uniform updates
  73396. */
  73397. setColor3(name: string, value: Color3): ProceduralTexture;
  73398. /**
  73399. * Set a vec4 in the shader from a Color4.
  73400. * @param name Define the name of the uniform as defined in the shader
  73401. * @param value Define the value to give to the uniform
  73402. * @return the texture itself allowing "fluent" like uniform updates
  73403. */
  73404. setColor4(name: string, value: Color4): ProceduralTexture;
  73405. /**
  73406. * Set a vec2 in the shader from a Vector2.
  73407. * @param name Define the name of the uniform as defined in the shader
  73408. * @param value Define the value to give to the uniform
  73409. * @return the texture itself allowing "fluent" like uniform updates
  73410. */
  73411. setVector2(name: string, value: Vector2): ProceduralTexture;
  73412. /**
  73413. * Set a vec3 in the shader from a Vector3.
  73414. * @param name Define the name of the uniform as defined in the shader
  73415. * @param value Define the value to give to the uniform
  73416. * @return the texture itself allowing "fluent" like uniform updates
  73417. */
  73418. setVector3(name: string, value: Vector3): ProceduralTexture;
  73419. /**
  73420. * Set a mat4 in the shader from a MAtrix.
  73421. * @param name Define the name of the uniform as defined in the shader
  73422. * @param value Define the value to give to the uniform
  73423. * @return the texture itself allowing "fluent" like uniform updates
  73424. */
  73425. setMatrix(name: string, value: Matrix): ProceduralTexture;
  73426. /**
  73427. * Render the texture to its associated render target.
  73428. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  73429. */
  73430. render(useCameraPostProcess?: boolean): void;
  73431. /**
  73432. * Clone the texture.
  73433. * @returns the cloned texture
  73434. */
  73435. clone(): ProceduralTexture;
  73436. /**
  73437. * Dispose the texture and release its asoociated resources.
  73438. */
  73439. dispose(): void;
  73440. }
  73441. }
  73442. declare module BABYLON {
  73443. /**
  73444. * This represents the base class for particle system in Babylon.
  73445. * 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.
  73446. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  73447. * @example https://doc.babylonjs.com/babylon101/particles
  73448. */
  73449. export class BaseParticleSystem {
  73450. /**
  73451. * Source color is added to the destination color without alpha affecting the result
  73452. */
  73453. static BLENDMODE_ONEONE: number;
  73454. /**
  73455. * Blend current color and particle color using particle’s alpha
  73456. */
  73457. static BLENDMODE_STANDARD: number;
  73458. /**
  73459. * Add current color and particle color multiplied by particle’s alpha
  73460. */
  73461. static BLENDMODE_ADD: number;
  73462. /**
  73463. * Multiply current color with particle color
  73464. */
  73465. static BLENDMODE_MULTIPLY: number;
  73466. /**
  73467. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  73468. */
  73469. static BLENDMODE_MULTIPLYADD: number;
  73470. /**
  73471. * List of animations used by the particle system.
  73472. */
  73473. animations: Animation[];
  73474. /**
  73475. * The id of the Particle system.
  73476. */
  73477. id: string;
  73478. /**
  73479. * The friendly name of the Particle system.
  73480. */
  73481. name: string;
  73482. /**
  73483. * The rendering group used by the Particle system to chose when to render.
  73484. */
  73485. renderingGroupId: number;
  73486. /**
  73487. * The emitter represents the Mesh or position we are attaching the particle system to.
  73488. */
  73489. emitter: Nullable<AbstractMesh | Vector3>;
  73490. /**
  73491. * The maximum number of particles to emit per frame
  73492. */
  73493. emitRate: number;
  73494. /**
  73495. * If you want to launch only a few particles at once, that can be done, as well.
  73496. */
  73497. manualEmitCount: number;
  73498. /**
  73499. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  73500. */
  73501. updateSpeed: number;
  73502. /**
  73503. * The amount of time the particle system is running (depends of the overall update speed).
  73504. */
  73505. targetStopDuration: number;
  73506. /**
  73507. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  73508. */
  73509. disposeOnStop: boolean;
  73510. /**
  73511. * Minimum power of emitting particles.
  73512. */
  73513. minEmitPower: number;
  73514. /**
  73515. * Maximum power of emitting particles.
  73516. */
  73517. maxEmitPower: number;
  73518. /**
  73519. * Minimum life time of emitting particles.
  73520. */
  73521. minLifeTime: number;
  73522. /**
  73523. * Maximum life time of emitting particles.
  73524. */
  73525. maxLifeTime: number;
  73526. /**
  73527. * Minimum Size of emitting particles.
  73528. */
  73529. minSize: number;
  73530. /**
  73531. * Maximum Size of emitting particles.
  73532. */
  73533. maxSize: number;
  73534. /**
  73535. * Minimum scale of emitting particles on X axis.
  73536. */
  73537. minScaleX: number;
  73538. /**
  73539. * Maximum scale of emitting particles on X axis.
  73540. */
  73541. maxScaleX: number;
  73542. /**
  73543. * Minimum scale of emitting particles on Y axis.
  73544. */
  73545. minScaleY: number;
  73546. /**
  73547. * Maximum scale of emitting particles on Y axis.
  73548. */
  73549. maxScaleY: number;
  73550. /**
  73551. * Gets or sets the minimal initial rotation in radians.
  73552. */
  73553. minInitialRotation: number;
  73554. /**
  73555. * Gets or sets the maximal initial rotation in radians.
  73556. */
  73557. maxInitialRotation: number;
  73558. /**
  73559. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  73560. */
  73561. minAngularSpeed: number;
  73562. /**
  73563. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  73564. */
  73565. maxAngularSpeed: number;
  73566. /**
  73567. * The texture used to render each particle. (this can be a spritesheet)
  73568. */
  73569. particleTexture: Nullable<Texture>;
  73570. /**
  73571. * The layer mask we are rendering the particles through.
  73572. */
  73573. layerMask: number;
  73574. /**
  73575. * This can help using your own shader to render the particle system.
  73576. * The according effect will be created
  73577. */
  73578. customShader: any;
  73579. /**
  73580. * By default particle system starts as soon as they are created. This prevents the
  73581. * automatic start to happen and let you decide when to start emitting particles.
  73582. */
  73583. preventAutoStart: boolean;
  73584. private _noiseTexture;
  73585. /**
  73586. * Gets or sets a texture used to add random noise to particle positions
  73587. */
  73588. noiseTexture: Nullable<ProceduralTexture>;
  73589. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  73590. noiseStrength: Vector3;
  73591. /**
  73592. * Callback triggered when the particle animation is ending.
  73593. */
  73594. onAnimationEnd: Nullable<() => void>;
  73595. /**
  73596. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  73597. */
  73598. blendMode: number;
  73599. /**
  73600. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  73601. * to override the particles.
  73602. */
  73603. forceDepthWrite: boolean;
  73604. /** 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 */
  73605. preWarmCycles: number;
  73606. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  73607. preWarmStepOffset: number;
  73608. /**
  73609. * 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)
  73610. */
  73611. spriteCellChangeSpeed: number;
  73612. /**
  73613. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  73614. */
  73615. startSpriteCellID: number;
  73616. /**
  73617. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  73618. */
  73619. endSpriteCellID: number;
  73620. /**
  73621. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  73622. */
  73623. spriteCellWidth: number;
  73624. /**
  73625. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  73626. */
  73627. spriteCellHeight: number;
  73628. /**
  73629. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  73630. */
  73631. spriteRandomStartCell: boolean;
  73632. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  73633. translationPivot: Vector2;
  73634. /** @hidden */
  73635. protected _isAnimationSheetEnabled: boolean;
  73636. /**
  73637. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  73638. */
  73639. beginAnimationOnStart: boolean;
  73640. /**
  73641. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  73642. */
  73643. beginAnimationFrom: number;
  73644. /**
  73645. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  73646. */
  73647. beginAnimationTo: number;
  73648. /**
  73649. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  73650. */
  73651. beginAnimationLoop: boolean;
  73652. /**
  73653. * Gets or sets a world offset applied to all particles
  73654. */
  73655. worldOffset: Vector3;
  73656. /**
  73657. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  73658. */
  73659. isAnimationSheetEnabled: boolean;
  73660. /**
  73661. * Get hosting scene
  73662. * @returns the scene
  73663. */
  73664. getScene(): Scene;
  73665. /**
  73666. * You can use gravity if you want to give an orientation to your particles.
  73667. */
  73668. gravity: Vector3;
  73669. protected _colorGradients: Nullable<Array<ColorGradient>>;
  73670. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  73671. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  73672. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  73673. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  73674. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  73675. protected _dragGradients: Nullable<Array<FactorGradient>>;
  73676. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  73677. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  73678. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  73679. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  73680. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  73681. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  73682. /**
  73683. * Defines the delay in milliseconds before starting the system (0 by default)
  73684. */
  73685. startDelay: number;
  73686. /**
  73687. * Gets the current list of drag gradients.
  73688. * You must use addDragGradient and removeDragGradient to udpate this list
  73689. * @returns the list of drag gradients
  73690. */
  73691. getDragGradients(): Nullable<Array<FactorGradient>>;
  73692. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  73693. limitVelocityDamping: number;
  73694. /**
  73695. * Gets the current list of limit velocity gradients.
  73696. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  73697. * @returns the list of limit velocity gradients
  73698. */
  73699. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  73700. /**
  73701. * Gets the current list of color gradients.
  73702. * You must use addColorGradient and removeColorGradient to udpate this list
  73703. * @returns the list of color gradients
  73704. */
  73705. getColorGradients(): Nullable<Array<ColorGradient>>;
  73706. /**
  73707. * Gets the current list of size gradients.
  73708. * You must use addSizeGradient and removeSizeGradient to udpate this list
  73709. * @returns the list of size gradients
  73710. */
  73711. getSizeGradients(): Nullable<Array<FactorGradient>>;
  73712. /**
  73713. * Gets the current list of color remap gradients.
  73714. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  73715. * @returns the list of color remap gradients
  73716. */
  73717. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  73718. /**
  73719. * Gets the current list of alpha remap gradients.
  73720. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  73721. * @returns the list of alpha remap gradients
  73722. */
  73723. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  73724. /**
  73725. * Gets the current list of life time gradients.
  73726. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  73727. * @returns the list of life time gradients
  73728. */
  73729. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  73730. /**
  73731. * Gets the current list of angular speed gradients.
  73732. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  73733. * @returns the list of angular speed gradients
  73734. */
  73735. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  73736. /**
  73737. * Gets the current list of velocity gradients.
  73738. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  73739. * @returns the list of velocity gradients
  73740. */
  73741. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  73742. /**
  73743. * Gets the current list of start size gradients.
  73744. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  73745. * @returns the list of start size gradients
  73746. */
  73747. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  73748. /**
  73749. * Gets the current list of emit rate gradients.
  73750. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  73751. * @returns the list of emit rate gradients
  73752. */
  73753. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  73754. /**
  73755. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  73756. * This only works when particleEmitterTyps is a BoxParticleEmitter
  73757. */
  73758. direction1: Vector3;
  73759. /**
  73760. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  73761. * This only works when particleEmitterTyps is a BoxParticleEmitter
  73762. */
  73763. direction2: Vector3;
  73764. /**
  73765. * 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.
  73766. * This only works when particleEmitterTyps is a BoxParticleEmitter
  73767. */
  73768. minEmitBox: Vector3;
  73769. /**
  73770. * 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.
  73771. * This only works when particleEmitterTyps is a BoxParticleEmitter
  73772. */
  73773. maxEmitBox: Vector3;
  73774. /**
  73775. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  73776. */
  73777. color1: Color4;
  73778. /**
  73779. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  73780. */
  73781. color2: Color4;
  73782. /**
  73783. * Color the particle will have at the end of its lifetime
  73784. */
  73785. colorDead: Color4;
  73786. /**
  73787. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  73788. */
  73789. textureMask: Color4;
  73790. /**
  73791. * The particle emitter type defines the emitter used by the particle system.
  73792. * It can be for example box, sphere, or cone...
  73793. */
  73794. particleEmitterType: IParticleEmitterType;
  73795. /** @hidden */
  73796. _isSubEmitter: boolean;
  73797. /**
  73798. * Gets or sets the billboard mode to use when isBillboardBased = true.
  73799. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  73800. */
  73801. billboardMode: number;
  73802. protected _isBillboardBased: boolean;
  73803. /**
  73804. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  73805. */
  73806. isBillboardBased: boolean;
  73807. /**
  73808. * The scene the particle system belongs to.
  73809. */
  73810. protected _scene: Scene;
  73811. /**
  73812. * Local cache of defines for image processing.
  73813. */
  73814. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  73815. /**
  73816. * Default configuration related to image processing available in the standard Material.
  73817. */
  73818. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  73819. /**
  73820. * Gets the image processing configuration used either in this material.
  73821. */
  73822. /**
  73823. * Sets the Default image processing configuration used either in the this material.
  73824. *
  73825. * If sets to null, the scene one is in use.
  73826. */
  73827. imageProcessingConfiguration: ImageProcessingConfiguration;
  73828. /**
  73829. * Attaches a new image processing configuration to the Standard Material.
  73830. * @param configuration
  73831. */
  73832. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  73833. /** @hidden */
  73834. protected _reset(): void;
  73835. /** @hidden */
  73836. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  73837. /**
  73838. * Instantiates a particle system.
  73839. * 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.
  73840. * @param name The name of the particle system
  73841. */
  73842. constructor(name: string);
  73843. /**
  73844. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  73845. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  73846. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  73847. * @returns the emitter
  73848. */
  73849. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  73850. /**
  73851. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  73852. * @param radius The radius of the hemisphere to emit from
  73853. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  73854. * @returns the emitter
  73855. */
  73856. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  73857. /**
  73858. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  73859. * @param radius The radius of the sphere to emit from
  73860. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  73861. * @returns the emitter
  73862. */
  73863. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  73864. /**
  73865. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  73866. * @param radius The radius of the sphere to emit from
  73867. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  73868. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  73869. * @returns the emitter
  73870. */
  73871. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  73872. /**
  73873. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  73874. * @param radius The radius of the emission cylinder
  73875. * @param height The height of the emission cylinder
  73876. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  73877. * @param directionRandomizer How much to randomize the particle direction [0-1]
  73878. * @returns the emitter
  73879. */
  73880. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  73881. /**
  73882. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  73883. * @param radius The radius of the cylinder to emit from
  73884. * @param height The height of the emission cylinder
  73885. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  73886. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  73887. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  73888. * @returns the emitter
  73889. */
  73890. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  73891. /**
  73892. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  73893. * @param radius The radius of the cone to emit from
  73894. * @param angle The base angle of the cone
  73895. * @returns the emitter
  73896. */
  73897. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  73898. /**
  73899. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  73900. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  73901. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  73902. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  73903. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  73904. * @returns the emitter
  73905. */
  73906. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  73907. }
  73908. }
  73909. declare module BABYLON {
  73910. /**
  73911. * Type of sub emitter
  73912. */
  73913. export enum SubEmitterType {
  73914. /**
  73915. * Attached to the particle over it's lifetime
  73916. */
  73917. ATTACHED = 0,
  73918. /**
  73919. * Created when the particle dies
  73920. */
  73921. END = 1
  73922. }
  73923. /**
  73924. * Sub emitter class used to emit particles from an existing particle
  73925. */
  73926. export class SubEmitter {
  73927. /**
  73928. * the particle system to be used by the sub emitter
  73929. */
  73930. particleSystem: ParticleSystem;
  73931. /**
  73932. * Type of the submitter (Default: END)
  73933. */
  73934. type: SubEmitterType;
  73935. /**
  73936. * 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)
  73937. * Note: This only is supported when using an emitter of type Mesh
  73938. */
  73939. inheritDirection: boolean;
  73940. /**
  73941. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  73942. */
  73943. inheritedVelocityAmount: number;
  73944. /**
  73945. * Creates a sub emitter
  73946. * @param particleSystem the particle system to be used by the sub emitter
  73947. */
  73948. constructor(
  73949. /**
  73950. * the particle system to be used by the sub emitter
  73951. */
  73952. particleSystem: ParticleSystem);
  73953. /**
  73954. * Clones the sub emitter
  73955. * @returns the cloned sub emitter
  73956. */
  73957. clone(): SubEmitter;
  73958. /**
  73959. * Serialize current object to a JSON object
  73960. * @returns the serialized object
  73961. */
  73962. serialize(): any;
  73963. /** @hidden */
  73964. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  73965. /**
  73966. * Creates a new SubEmitter from a serialized JSON version
  73967. * @param serializationObject defines the JSON object to read from
  73968. * @param scene defines the hosting scene
  73969. * @param rootUrl defines the rootUrl for data loading
  73970. * @returns a new SubEmitter
  73971. */
  73972. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  73973. /** Release associated resources */
  73974. dispose(): void;
  73975. }
  73976. }
  73977. declare module BABYLON {
  73978. /** @hidden */
  73979. export var clipPlaneFragmentDeclaration: {
  73980. name: string;
  73981. shader: string;
  73982. };
  73983. }
  73984. declare module BABYLON {
  73985. /** @hidden */
  73986. export var imageProcessingDeclaration: {
  73987. name: string;
  73988. shader: string;
  73989. };
  73990. }
  73991. declare module BABYLON {
  73992. /** @hidden */
  73993. export var imageProcessingFunctions: {
  73994. name: string;
  73995. shader: string;
  73996. };
  73997. }
  73998. declare module BABYLON {
  73999. /** @hidden */
  74000. export var clipPlaneFragment: {
  74001. name: string;
  74002. shader: string;
  74003. };
  74004. }
  74005. declare module BABYLON {
  74006. /** @hidden */
  74007. export var particlesPixelShader: {
  74008. name: string;
  74009. shader: string;
  74010. };
  74011. }
  74012. declare module BABYLON {
  74013. /** @hidden */
  74014. export var clipPlaneVertexDeclaration: {
  74015. name: string;
  74016. shader: string;
  74017. };
  74018. }
  74019. declare module BABYLON {
  74020. /** @hidden */
  74021. export var clipPlaneVertex: {
  74022. name: string;
  74023. shader: string;
  74024. };
  74025. }
  74026. declare module BABYLON {
  74027. /** @hidden */
  74028. export var particlesVertexShader: {
  74029. name: string;
  74030. shader: string;
  74031. };
  74032. }
  74033. declare module BABYLON {
  74034. /**
  74035. * This represents a particle system in Babylon.
  74036. * 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.
  74037. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  74038. * @example https://doc.babylonjs.com/babylon101/particles
  74039. */
  74040. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  74041. /**
  74042. * Billboard mode will only apply to Y axis
  74043. */
  74044. static readonly BILLBOARDMODE_Y: number;
  74045. /**
  74046. * Billboard mode will apply to all axes
  74047. */
  74048. static readonly BILLBOARDMODE_ALL: number;
  74049. /**
  74050. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  74051. */
  74052. static readonly BILLBOARDMODE_STRETCHED: number;
  74053. /**
  74054. * This function can be defined to provide custom update for active particles.
  74055. * This function will be called instead of regular update (age, position, color, etc.).
  74056. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  74057. */
  74058. updateFunction: (particles: Particle[]) => void;
  74059. private _emitterWorldMatrix;
  74060. /**
  74061. * This function can be defined to specify initial direction for every new particle.
  74062. * It by default use the emitterType defined function
  74063. */
  74064. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  74065. /**
  74066. * This function can be defined to specify initial position for every new particle.
  74067. * It by default use the emitterType defined function
  74068. */
  74069. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  74070. /**
  74071. * @hidden
  74072. */
  74073. _inheritedVelocityOffset: Vector3;
  74074. /**
  74075. * An event triggered when the system is disposed
  74076. */
  74077. onDisposeObservable: Observable<ParticleSystem>;
  74078. private _onDisposeObserver;
  74079. /**
  74080. * Sets a callback that will be triggered when the system is disposed
  74081. */
  74082. onDispose: () => void;
  74083. private _particles;
  74084. private _epsilon;
  74085. private _capacity;
  74086. private _stockParticles;
  74087. private _newPartsExcess;
  74088. private _vertexData;
  74089. private _vertexBuffer;
  74090. private _vertexBuffers;
  74091. private _spriteBuffer;
  74092. private _indexBuffer;
  74093. private _effect;
  74094. private _customEffect;
  74095. private _cachedDefines;
  74096. private _scaledColorStep;
  74097. private _colorDiff;
  74098. private _scaledDirection;
  74099. private _scaledGravity;
  74100. private _currentRenderId;
  74101. private _alive;
  74102. private _useInstancing;
  74103. private _started;
  74104. private _stopped;
  74105. private _actualFrame;
  74106. private _scaledUpdateSpeed;
  74107. private _vertexBufferSize;
  74108. /** @hidden */
  74109. _currentEmitRateGradient: Nullable<FactorGradient>;
  74110. /** @hidden */
  74111. _currentEmitRate1: number;
  74112. /** @hidden */
  74113. _currentEmitRate2: number;
  74114. /** @hidden */
  74115. _currentStartSizeGradient: Nullable<FactorGradient>;
  74116. /** @hidden */
  74117. _currentStartSize1: number;
  74118. /** @hidden */
  74119. _currentStartSize2: number;
  74120. private readonly _rawTextureWidth;
  74121. private _rampGradientsTexture;
  74122. private _useRampGradients;
  74123. /** Gets or sets a boolean indicating that ramp gradients must be used
  74124. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  74125. */
  74126. useRampGradients: boolean;
  74127. /**
  74128. * 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.
  74129. * 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: [])
  74130. */
  74131. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  74132. private _subEmitters;
  74133. /**
  74134. * @hidden
  74135. * If the particle systems emitter should be disposed when the particle system is disposed
  74136. */
  74137. _disposeEmitterOnDispose: boolean;
  74138. /**
  74139. * The current active Sub-systems, this property is used by the root particle system only.
  74140. */
  74141. activeSubSystems: Array<ParticleSystem>;
  74142. private _rootParticleSystem;
  74143. /**
  74144. * Gets the current list of active particles
  74145. */
  74146. readonly particles: Particle[];
  74147. /**
  74148. * Returns the string "ParticleSystem"
  74149. * @returns a string containing the class name
  74150. */
  74151. getClassName(): string;
  74152. /**
  74153. * Instantiates a particle system.
  74154. * 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.
  74155. * @param name The name of the particle system
  74156. * @param capacity The max number of particles alive at the same time
  74157. * @param scene The scene the particle system belongs to
  74158. * @param customEffect a custom effect used to change the way particles are rendered by default
  74159. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  74160. * @param epsilon Offset used to render the particles
  74161. */
  74162. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  74163. private _addFactorGradient;
  74164. private _removeFactorGradient;
  74165. /**
  74166. * Adds a new life time gradient
  74167. * @param gradient defines the gradient to use (between 0 and 1)
  74168. * @param factor defines the life time factor to affect to the specified gradient
  74169. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  74170. * @returns the current particle system
  74171. */
  74172. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  74173. /**
  74174. * Remove a specific life time gradient
  74175. * @param gradient defines the gradient to remove
  74176. * @returns the current particle system
  74177. */
  74178. removeLifeTimeGradient(gradient: number): IParticleSystem;
  74179. /**
  74180. * Adds a new size gradient
  74181. * @param gradient defines the gradient to use (between 0 and 1)
  74182. * @param factor defines the size factor to affect to the specified gradient
  74183. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  74184. * @returns the current particle system
  74185. */
  74186. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  74187. /**
  74188. * Remove a specific size gradient
  74189. * @param gradient defines the gradient to remove
  74190. * @returns the current particle system
  74191. */
  74192. removeSizeGradient(gradient: number): IParticleSystem;
  74193. /**
  74194. * Adds a new color remap gradient
  74195. * @param gradient defines the gradient to use (between 0 and 1)
  74196. * @param min defines the color remap minimal range
  74197. * @param max defines the color remap maximal range
  74198. * @returns the current particle system
  74199. */
  74200. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  74201. /**
  74202. * Remove a specific color remap gradient
  74203. * @param gradient defines the gradient to remove
  74204. * @returns the current particle system
  74205. */
  74206. removeColorRemapGradient(gradient: number): IParticleSystem;
  74207. /**
  74208. * Adds a new alpha remap gradient
  74209. * @param gradient defines the gradient to use (between 0 and 1)
  74210. * @param min defines the alpha remap minimal range
  74211. * @param max defines the alpha remap maximal range
  74212. * @returns the current particle system
  74213. */
  74214. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  74215. /**
  74216. * Remove a specific alpha remap gradient
  74217. * @param gradient defines the gradient to remove
  74218. * @returns the current particle system
  74219. */
  74220. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  74221. /**
  74222. * Adds a new angular speed gradient
  74223. * @param gradient defines the gradient to use (between 0 and 1)
  74224. * @param factor defines the angular speed to affect to the specified gradient
  74225. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  74226. * @returns the current particle system
  74227. */
  74228. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  74229. /**
  74230. * Remove a specific angular speed gradient
  74231. * @param gradient defines the gradient to remove
  74232. * @returns the current particle system
  74233. */
  74234. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  74235. /**
  74236. * Adds a new velocity gradient
  74237. * @param gradient defines the gradient to use (between 0 and 1)
  74238. * @param factor defines the velocity to affect to the specified gradient
  74239. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  74240. * @returns the current particle system
  74241. */
  74242. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  74243. /**
  74244. * Remove a specific velocity gradient
  74245. * @param gradient defines the gradient to remove
  74246. * @returns the current particle system
  74247. */
  74248. removeVelocityGradient(gradient: number): IParticleSystem;
  74249. /**
  74250. * Adds a new limit velocity gradient
  74251. * @param gradient defines the gradient to use (between 0 and 1)
  74252. * @param factor defines the limit velocity value to affect to the specified gradient
  74253. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  74254. * @returns the current particle system
  74255. */
  74256. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  74257. /**
  74258. * Remove a specific limit velocity gradient
  74259. * @param gradient defines the gradient to remove
  74260. * @returns the current particle system
  74261. */
  74262. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  74263. /**
  74264. * Adds a new drag gradient
  74265. * @param gradient defines the gradient to use (between 0 and 1)
  74266. * @param factor defines the drag value to affect to the specified gradient
  74267. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  74268. * @returns the current particle system
  74269. */
  74270. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  74271. /**
  74272. * Remove a specific drag gradient
  74273. * @param gradient defines the gradient to remove
  74274. * @returns the current particle system
  74275. */
  74276. removeDragGradient(gradient: number): IParticleSystem;
  74277. /**
  74278. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  74279. * @param gradient defines the gradient to use (between 0 and 1)
  74280. * @param factor defines the emit rate value to affect to the specified gradient
  74281. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  74282. * @returns the current particle system
  74283. */
  74284. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  74285. /**
  74286. * Remove a specific emit rate gradient
  74287. * @param gradient defines the gradient to remove
  74288. * @returns the current particle system
  74289. */
  74290. removeEmitRateGradient(gradient: number): IParticleSystem;
  74291. /**
  74292. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  74293. * @param gradient defines the gradient to use (between 0 and 1)
  74294. * @param factor defines the start size value to affect to the specified gradient
  74295. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  74296. * @returns the current particle system
  74297. */
  74298. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  74299. /**
  74300. * Remove a specific start size gradient
  74301. * @param gradient defines the gradient to remove
  74302. * @returns the current particle system
  74303. */
  74304. removeStartSizeGradient(gradient: number): IParticleSystem;
  74305. private _createRampGradientTexture;
  74306. /**
  74307. * Gets the current list of ramp gradients.
  74308. * You must use addRampGradient and removeRampGradient to udpate this list
  74309. * @returns the list of ramp gradients
  74310. */
  74311. getRampGradients(): Nullable<Array<Color3Gradient>>;
  74312. /**
  74313. * Adds a new ramp gradient used to remap particle colors
  74314. * @param gradient defines the gradient to use (between 0 and 1)
  74315. * @param color defines the color to affect to the specified gradient
  74316. * @returns the current particle system
  74317. */
  74318. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  74319. /**
  74320. * Remove a specific ramp gradient
  74321. * @param gradient defines the gradient to remove
  74322. * @returns the current particle system
  74323. */
  74324. removeRampGradient(gradient: number): ParticleSystem;
  74325. /**
  74326. * Adds a new color gradient
  74327. * @param gradient defines the gradient to use (between 0 and 1)
  74328. * @param color1 defines the color to affect to the specified gradient
  74329. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  74330. * @returns this particle system
  74331. */
  74332. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  74333. /**
  74334. * Remove a specific color gradient
  74335. * @param gradient defines the gradient to remove
  74336. * @returns this particle system
  74337. */
  74338. removeColorGradient(gradient: number): IParticleSystem;
  74339. private _fetchR;
  74340. protected _reset(): void;
  74341. private _resetEffect;
  74342. private _createVertexBuffers;
  74343. private _createIndexBuffer;
  74344. /**
  74345. * Gets the maximum number of particles active at the same time.
  74346. * @returns The max number of active particles.
  74347. */
  74348. getCapacity(): number;
  74349. /**
  74350. * Gets whether there are still active particles in the system.
  74351. * @returns True if it is alive, otherwise false.
  74352. */
  74353. isAlive(): boolean;
  74354. /**
  74355. * Gets if the system has been started. (Note: this will still be true after stop is called)
  74356. * @returns True if it has been started, otherwise false.
  74357. */
  74358. isStarted(): boolean;
  74359. private _prepareSubEmitterInternalArray;
  74360. /**
  74361. * Starts the particle system and begins to emit
  74362. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  74363. */
  74364. start(delay?: number): void;
  74365. /**
  74366. * Stops the particle system.
  74367. * @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.
  74368. */
  74369. stop(stopSubEmitters?: boolean): void;
  74370. /**
  74371. * Remove all active particles
  74372. */
  74373. reset(): void;
  74374. /**
  74375. * @hidden (for internal use only)
  74376. */
  74377. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  74378. /**
  74379. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  74380. * Its lifetime will start back at 0.
  74381. */
  74382. recycleParticle: (particle: Particle) => void;
  74383. private _stopSubEmitters;
  74384. private _createParticle;
  74385. private _removeFromRoot;
  74386. private _emitFromParticle;
  74387. private _update;
  74388. /** @hidden */
  74389. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  74390. /** @hidden */
  74391. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  74392. /** @hidden */
  74393. private _getEffect;
  74394. /**
  74395. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  74396. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  74397. */
  74398. animate(preWarmOnly?: boolean): void;
  74399. private _appendParticleVertices;
  74400. /**
  74401. * Rebuilds the particle system.
  74402. */
  74403. rebuild(): void;
  74404. /**
  74405. * Is this system ready to be used/rendered
  74406. * @return true if the system is ready
  74407. */
  74408. isReady(): boolean;
  74409. private _render;
  74410. /**
  74411. * Renders the particle system in its current state.
  74412. * @returns the current number of particles
  74413. */
  74414. render(): number;
  74415. /**
  74416. * Disposes the particle system and free the associated resources
  74417. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  74418. */
  74419. dispose(disposeTexture?: boolean): void;
  74420. /**
  74421. * Clones the particle system.
  74422. * @param name The name of the cloned object
  74423. * @param newEmitter The new emitter to use
  74424. * @returns the cloned particle system
  74425. */
  74426. clone(name: string, newEmitter: any): ParticleSystem;
  74427. /**
  74428. * Serializes the particle system to a JSON object.
  74429. * @returns the JSON object
  74430. */
  74431. serialize(): any;
  74432. /** @hidden */
  74433. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  74434. /** @hidden */
  74435. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  74436. /**
  74437. * Parses a JSON object to create a particle system.
  74438. * @param parsedParticleSystem The JSON object to parse
  74439. * @param scene The scene to create the particle system in
  74440. * @param rootUrl The root url to use to load external dependencies like texture
  74441. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  74442. * @returns the Parsed particle system
  74443. */
  74444. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  74445. }
  74446. }
  74447. declare module BABYLON {
  74448. /**
  74449. * A particle represents one of the element emitted by a particle system.
  74450. * This is mainly define by its coordinates, direction, velocity and age.
  74451. */
  74452. export class Particle {
  74453. /**
  74454. * The particle system the particle belongs to.
  74455. */
  74456. particleSystem: ParticleSystem;
  74457. private static _Count;
  74458. /**
  74459. * Unique ID of the particle
  74460. */
  74461. id: number;
  74462. /**
  74463. * The world position of the particle in the scene.
  74464. */
  74465. position: Vector3;
  74466. /**
  74467. * The world direction of the particle in the scene.
  74468. */
  74469. direction: Vector3;
  74470. /**
  74471. * The color of the particle.
  74472. */
  74473. color: Color4;
  74474. /**
  74475. * The color change of the particle per step.
  74476. */
  74477. colorStep: Color4;
  74478. /**
  74479. * Defines how long will the life of the particle be.
  74480. */
  74481. lifeTime: number;
  74482. /**
  74483. * The current age of the particle.
  74484. */
  74485. age: number;
  74486. /**
  74487. * The current size of the particle.
  74488. */
  74489. size: number;
  74490. /**
  74491. * The current scale of the particle.
  74492. */
  74493. scale: Vector2;
  74494. /**
  74495. * The current angle of the particle.
  74496. */
  74497. angle: number;
  74498. /**
  74499. * Defines how fast is the angle changing.
  74500. */
  74501. angularSpeed: number;
  74502. /**
  74503. * Defines the cell index used by the particle to be rendered from a sprite.
  74504. */
  74505. cellIndex: number;
  74506. /**
  74507. * The information required to support color remapping
  74508. */
  74509. remapData: Vector4;
  74510. /** @hidden */
  74511. _randomCellOffset?: number;
  74512. /** @hidden */
  74513. _initialDirection: Nullable<Vector3>;
  74514. /** @hidden */
  74515. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  74516. /** @hidden */
  74517. _initialStartSpriteCellID: number;
  74518. /** @hidden */
  74519. _initialEndSpriteCellID: number;
  74520. /** @hidden */
  74521. _currentColorGradient: Nullable<ColorGradient>;
  74522. /** @hidden */
  74523. _currentColor1: Color4;
  74524. /** @hidden */
  74525. _currentColor2: Color4;
  74526. /** @hidden */
  74527. _currentSizeGradient: Nullable<FactorGradient>;
  74528. /** @hidden */
  74529. _currentSize1: number;
  74530. /** @hidden */
  74531. _currentSize2: number;
  74532. /** @hidden */
  74533. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  74534. /** @hidden */
  74535. _currentAngularSpeed1: number;
  74536. /** @hidden */
  74537. _currentAngularSpeed2: number;
  74538. /** @hidden */
  74539. _currentVelocityGradient: Nullable<FactorGradient>;
  74540. /** @hidden */
  74541. _currentVelocity1: number;
  74542. /** @hidden */
  74543. _currentVelocity2: number;
  74544. /** @hidden */
  74545. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  74546. /** @hidden */
  74547. _currentLimitVelocity1: number;
  74548. /** @hidden */
  74549. _currentLimitVelocity2: number;
  74550. /** @hidden */
  74551. _currentDragGradient: Nullable<FactorGradient>;
  74552. /** @hidden */
  74553. _currentDrag1: number;
  74554. /** @hidden */
  74555. _currentDrag2: number;
  74556. /** @hidden */
  74557. _randomNoiseCoordinates1: Vector3;
  74558. /** @hidden */
  74559. _randomNoiseCoordinates2: Vector3;
  74560. /**
  74561. * Creates a new instance Particle
  74562. * @param particleSystem the particle system the particle belongs to
  74563. */
  74564. constructor(
  74565. /**
  74566. * The particle system the particle belongs to.
  74567. */
  74568. particleSystem: ParticleSystem);
  74569. private updateCellInfoFromSystem;
  74570. /**
  74571. * Defines how the sprite cell index is updated for the particle
  74572. */
  74573. updateCellIndex(): void;
  74574. /** @hidden */
  74575. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  74576. /** @hidden */
  74577. _inheritParticleInfoToSubEmitters(): void;
  74578. /** @hidden */
  74579. _reset(): void;
  74580. /**
  74581. * Copy the properties of particle to another one.
  74582. * @param other the particle to copy the information to.
  74583. */
  74584. copyTo(other: Particle): void;
  74585. }
  74586. }
  74587. declare module BABYLON {
  74588. /**
  74589. * Particle emitter represents a volume emitting particles.
  74590. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  74591. */
  74592. export interface IParticleEmitterType {
  74593. /**
  74594. * Called by the particle System when the direction is computed for the created particle.
  74595. * @param worldMatrix is the world matrix of the particle system
  74596. * @param directionToUpdate is the direction vector to update with the result
  74597. * @param particle is the particle we are computed the direction for
  74598. */
  74599. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  74600. /**
  74601. * Called by the particle System when the position is computed for the created particle.
  74602. * @param worldMatrix is the world matrix of the particle system
  74603. * @param positionToUpdate is the position vector to update with the result
  74604. * @param particle is the particle we are computed the position for
  74605. */
  74606. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  74607. /**
  74608. * Clones the current emitter and returns a copy of it
  74609. * @returns the new emitter
  74610. */
  74611. clone(): IParticleEmitterType;
  74612. /**
  74613. * Called by the GPUParticleSystem to setup the update shader
  74614. * @param effect defines the update shader
  74615. */
  74616. applyToShader(effect: Effect): void;
  74617. /**
  74618. * Returns a string to use to update the GPU particles update shader
  74619. * @returns the effect defines string
  74620. */
  74621. getEffectDefines(): string;
  74622. /**
  74623. * Returns a string representing the class name
  74624. * @returns a string containing the class name
  74625. */
  74626. getClassName(): string;
  74627. /**
  74628. * Serializes the particle system to a JSON object.
  74629. * @returns the JSON object
  74630. */
  74631. serialize(): any;
  74632. /**
  74633. * Parse properties from a JSON object
  74634. * @param serializationObject defines the JSON object
  74635. */
  74636. parse(serializationObject: any): void;
  74637. }
  74638. }
  74639. declare module BABYLON {
  74640. /**
  74641. * Particle emitter emitting particles from the inside of a box.
  74642. * It emits the particles randomly between 2 given directions.
  74643. */
  74644. export class BoxParticleEmitter implements IParticleEmitterType {
  74645. /**
  74646. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  74647. */
  74648. direction1: Vector3;
  74649. /**
  74650. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  74651. */
  74652. direction2: Vector3;
  74653. /**
  74654. * 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.
  74655. */
  74656. minEmitBox: Vector3;
  74657. /**
  74658. * 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.
  74659. */
  74660. maxEmitBox: Vector3;
  74661. /**
  74662. * Creates a new instance BoxParticleEmitter
  74663. */
  74664. constructor();
  74665. /**
  74666. * Called by the particle System when the direction is computed for the created particle.
  74667. * @param worldMatrix is the world matrix of the particle system
  74668. * @param directionToUpdate is the direction vector to update with the result
  74669. * @param particle is the particle we are computed the direction for
  74670. */
  74671. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  74672. /**
  74673. * Called by the particle System when the position is computed for the created particle.
  74674. * @param worldMatrix is the world matrix of the particle system
  74675. * @param positionToUpdate is the position vector to update with the result
  74676. * @param particle is the particle we are computed the position for
  74677. */
  74678. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  74679. /**
  74680. * Clones the current emitter and returns a copy of it
  74681. * @returns the new emitter
  74682. */
  74683. clone(): BoxParticleEmitter;
  74684. /**
  74685. * Called by the GPUParticleSystem to setup the update shader
  74686. * @param effect defines the update shader
  74687. */
  74688. applyToShader(effect: Effect): void;
  74689. /**
  74690. * Returns a string to use to update the GPU particles update shader
  74691. * @returns a string containng the defines string
  74692. */
  74693. getEffectDefines(): string;
  74694. /**
  74695. * Returns the string "BoxParticleEmitter"
  74696. * @returns a string containing the class name
  74697. */
  74698. getClassName(): string;
  74699. /**
  74700. * Serializes the particle system to a JSON object.
  74701. * @returns the JSON object
  74702. */
  74703. serialize(): any;
  74704. /**
  74705. * Parse properties from a JSON object
  74706. * @param serializationObject defines the JSON object
  74707. */
  74708. parse(serializationObject: any): void;
  74709. }
  74710. }
  74711. declare module BABYLON {
  74712. /**
  74713. * Particle emitter emitting particles from the inside of a cone.
  74714. * It emits the particles alongside the cone volume from the base to the particle.
  74715. * The emission direction might be randomized.
  74716. */
  74717. export class ConeParticleEmitter implements IParticleEmitterType {
  74718. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  74719. directionRandomizer: number;
  74720. private _radius;
  74721. private _angle;
  74722. private _height;
  74723. /**
  74724. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  74725. */
  74726. radiusRange: number;
  74727. /**
  74728. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  74729. */
  74730. heightRange: number;
  74731. /**
  74732. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  74733. */
  74734. emitFromSpawnPointOnly: boolean;
  74735. /**
  74736. * Gets or sets the radius of the emission cone
  74737. */
  74738. radius: number;
  74739. /**
  74740. * Gets or sets the angle of the emission cone
  74741. */
  74742. angle: number;
  74743. private _buildHeight;
  74744. /**
  74745. * Creates a new instance ConeParticleEmitter
  74746. * @param radius the radius of the emission cone (1 by default)
  74747. * @param angle the cone base angle (PI by default)
  74748. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  74749. */
  74750. constructor(radius?: number, angle?: number,
  74751. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  74752. directionRandomizer?: number);
  74753. /**
  74754. * Called by the particle System when the direction is computed for the created particle.
  74755. * @param worldMatrix is the world matrix of the particle system
  74756. * @param directionToUpdate is the direction vector to update with the result
  74757. * @param particle is the particle we are computed the direction for
  74758. */
  74759. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  74760. /**
  74761. * Called by the particle System when the position is computed for the created particle.
  74762. * @param worldMatrix is the world matrix of the particle system
  74763. * @param positionToUpdate is the position vector to update with the result
  74764. * @param particle is the particle we are computed the position for
  74765. */
  74766. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  74767. /**
  74768. * Clones the current emitter and returns a copy of it
  74769. * @returns the new emitter
  74770. */
  74771. clone(): ConeParticleEmitter;
  74772. /**
  74773. * Called by the GPUParticleSystem to setup the update shader
  74774. * @param effect defines the update shader
  74775. */
  74776. applyToShader(effect: Effect): void;
  74777. /**
  74778. * Returns a string to use to update the GPU particles update shader
  74779. * @returns a string containng the defines string
  74780. */
  74781. getEffectDefines(): string;
  74782. /**
  74783. * Returns the string "ConeParticleEmitter"
  74784. * @returns a string containing the class name
  74785. */
  74786. getClassName(): string;
  74787. /**
  74788. * Serializes the particle system to a JSON object.
  74789. * @returns the JSON object
  74790. */
  74791. serialize(): any;
  74792. /**
  74793. * Parse properties from a JSON object
  74794. * @param serializationObject defines the JSON object
  74795. */
  74796. parse(serializationObject: any): void;
  74797. }
  74798. }
  74799. declare module BABYLON {
  74800. /**
  74801. * Particle emitter emitting particles from the inside of a cylinder.
  74802. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  74803. */
  74804. export class CylinderParticleEmitter implements IParticleEmitterType {
  74805. /**
  74806. * The radius of the emission cylinder.
  74807. */
  74808. radius: number;
  74809. /**
  74810. * The height of the emission cylinder.
  74811. */
  74812. height: number;
  74813. /**
  74814. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  74815. */
  74816. radiusRange: number;
  74817. /**
  74818. * How much to randomize the particle direction [0-1].
  74819. */
  74820. directionRandomizer: number;
  74821. /**
  74822. * Creates a new instance CylinderParticleEmitter
  74823. * @param radius the radius of the emission cylinder (1 by default)
  74824. * @param height the height of the emission cylinder (1 by default)
  74825. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  74826. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  74827. */
  74828. constructor(
  74829. /**
  74830. * The radius of the emission cylinder.
  74831. */
  74832. radius?: number,
  74833. /**
  74834. * The height of the emission cylinder.
  74835. */
  74836. height?: number,
  74837. /**
  74838. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  74839. */
  74840. radiusRange?: number,
  74841. /**
  74842. * How much to randomize the particle direction [0-1].
  74843. */
  74844. directionRandomizer?: number);
  74845. /**
  74846. * Called by the particle System when the direction is computed for the created particle.
  74847. * @param worldMatrix is the world matrix of the particle system
  74848. * @param directionToUpdate is the direction vector to update with the result
  74849. * @param particle is the particle we are computed the direction for
  74850. */
  74851. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  74852. /**
  74853. * Called by the particle System when the position is computed for the created particle.
  74854. * @param worldMatrix is the world matrix of the particle system
  74855. * @param positionToUpdate is the position vector to update with the result
  74856. * @param particle is the particle we are computed the position for
  74857. */
  74858. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  74859. /**
  74860. * Clones the current emitter and returns a copy of it
  74861. * @returns the new emitter
  74862. */
  74863. clone(): CylinderParticleEmitter;
  74864. /**
  74865. * Called by the GPUParticleSystem to setup the update shader
  74866. * @param effect defines the update shader
  74867. */
  74868. applyToShader(effect: Effect): void;
  74869. /**
  74870. * Returns a string to use to update the GPU particles update shader
  74871. * @returns a string containng the defines string
  74872. */
  74873. getEffectDefines(): string;
  74874. /**
  74875. * Returns the string "CylinderParticleEmitter"
  74876. * @returns a string containing the class name
  74877. */
  74878. getClassName(): string;
  74879. /**
  74880. * Serializes the particle system to a JSON object.
  74881. * @returns the JSON object
  74882. */
  74883. serialize(): any;
  74884. /**
  74885. * Parse properties from a JSON object
  74886. * @param serializationObject defines the JSON object
  74887. */
  74888. parse(serializationObject: any): void;
  74889. }
  74890. /**
  74891. * Particle emitter emitting particles from the inside of a cylinder.
  74892. * It emits the particles randomly between two vectors.
  74893. */
  74894. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  74895. /**
  74896. * The min limit of the emission direction.
  74897. */
  74898. direction1: Vector3;
  74899. /**
  74900. * The max limit of the emission direction.
  74901. */
  74902. direction2: Vector3;
  74903. /**
  74904. * Creates a new instance CylinderDirectedParticleEmitter
  74905. * @param radius the radius of the emission cylinder (1 by default)
  74906. * @param height the height of the emission cylinder (1 by default)
  74907. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  74908. * @param direction1 the min limit of the emission direction (up vector by default)
  74909. * @param direction2 the max limit of the emission direction (up vector by default)
  74910. */
  74911. constructor(radius?: number, height?: number, radiusRange?: number,
  74912. /**
  74913. * The min limit of the emission direction.
  74914. */
  74915. direction1?: Vector3,
  74916. /**
  74917. * The max limit of the emission direction.
  74918. */
  74919. direction2?: Vector3);
  74920. /**
  74921. * Called by the particle System when the direction is computed for the created particle.
  74922. * @param worldMatrix is the world matrix of the particle system
  74923. * @param directionToUpdate is the direction vector to update with the result
  74924. * @param particle is the particle we are computed the direction for
  74925. */
  74926. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  74927. /**
  74928. * Clones the current emitter and returns a copy of it
  74929. * @returns the new emitter
  74930. */
  74931. clone(): CylinderDirectedParticleEmitter;
  74932. /**
  74933. * Called by the GPUParticleSystem to setup the update shader
  74934. * @param effect defines the update shader
  74935. */
  74936. applyToShader(effect: Effect): void;
  74937. /**
  74938. * Returns a string to use to update the GPU particles update shader
  74939. * @returns a string containng the defines string
  74940. */
  74941. getEffectDefines(): string;
  74942. /**
  74943. * Returns the string "CylinderDirectedParticleEmitter"
  74944. * @returns a string containing the class name
  74945. */
  74946. getClassName(): string;
  74947. /**
  74948. * Serializes the particle system to a JSON object.
  74949. * @returns the JSON object
  74950. */
  74951. serialize(): any;
  74952. /**
  74953. * Parse properties from a JSON object
  74954. * @param serializationObject defines the JSON object
  74955. */
  74956. parse(serializationObject: any): void;
  74957. }
  74958. }
  74959. declare module BABYLON {
  74960. /**
  74961. * Particle emitter emitting particles from the inside of a hemisphere.
  74962. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  74963. */
  74964. export class HemisphericParticleEmitter implements IParticleEmitterType {
  74965. /**
  74966. * The radius of the emission hemisphere.
  74967. */
  74968. radius: number;
  74969. /**
  74970. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  74971. */
  74972. radiusRange: number;
  74973. /**
  74974. * How much to randomize the particle direction [0-1].
  74975. */
  74976. directionRandomizer: number;
  74977. /**
  74978. * Creates a new instance HemisphericParticleEmitter
  74979. * @param radius the radius of the emission hemisphere (1 by default)
  74980. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  74981. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  74982. */
  74983. constructor(
  74984. /**
  74985. * The radius of the emission hemisphere.
  74986. */
  74987. radius?: number,
  74988. /**
  74989. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  74990. */
  74991. radiusRange?: number,
  74992. /**
  74993. * How much to randomize the particle direction [0-1].
  74994. */
  74995. directionRandomizer?: number);
  74996. /**
  74997. * Called by the particle System when the direction is computed for the created particle.
  74998. * @param worldMatrix is the world matrix of the particle system
  74999. * @param directionToUpdate is the direction vector to update with the result
  75000. * @param particle is the particle we are computed the direction for
  75001. */
  75002. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  75003. /**
  75004. * Called by the particle System when the position is computed for the created particle.
  75005. * @param worldMatrix is the world matrix of the particle system
  75006. * @param positionToUpdate is the position vector to update with the result
  75007. * @param particle is the particle we are computed the position for
  75008. */
  75009. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  75010. /**
  75011. * Clones the current emitter and returns a copy of it
  75012. * @returns the new emitter
  75013. */
  75014. clone(): HemisphericParticleEmitter;
  75015. /**
  75016. * Called by the GPUParticleSystem to setup the update shader
  75017. * @param effect defines the update shader
  75018. */
  75019. applyToShader(effect: Effect): void;
  75020. /**
  75021. * Returns a string to use to update the GPU particles update shader
  75022. * @returns a string containng the defines string
  75023. */
  75024. getEffectDefines(): string;
  75025. /**
  75026. * Returns the string "HemisphericParticleEmitter"
  75027. * @returns a string containing the class name
  75028. */
  75029. getClassName(): string;
  75030. /**
  75031. * Serializes the particle system to a JSON object.
  75032. * @returns the JSON object
  75033. */
  75034. serialize(): any;
  75035. /**
  75036. * Parse properties from a JSON object
  75037. * @param serializationObject defines the JSON object
  75038. */
  75039. parse(serializationObject: any): void;
  75040. }
  75041. }
  75042. declare module BABYLON {
  75043. /**
  75044. * Particle emitter emitting particles from a point.
  75045. * It emits the particles randomly between 2 given directions.
  75046. */
  75047. export class PointParticleEmitter implements IParticleEmitterType {
  75048. /**
  75049. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  75050. */
  75051. direction1: Vector3;
  75052. /**
  75053. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  75054. */
  75055. direction2: Vector3;
  75056. /**
  75057. * Creates a new instance PointParticleEmitter
  75058. */
  75059. constructor();
  75060. /**
  75061. * Called by the particle System when the direction is computed for the created particle.
  75062. * @param worldMatrix is the world matrix of the particle system
  75063. * @param directionToUpdate is the direction vector to update with the result
  75064. * @param particle is the particle we are computed the direction for
  75065. */
  75066. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  75067. /**
  75068. * Called by the particle System when the position is computed for the created particle.
  75069. * @param worldMatrix is the world matrix of the particle system
  75070. * @param positionToUpdate is the position vector to update with the result
  75071. * @param particle is the particle we are computed the position for
  75072. */
  75073. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  75074. /**
  75075. * Clones the current emitter and returns a copy of it
  75076. * @returns the new emitter
  75077. */
  75078. clone(): PointParticleEmitter;
  75079. /**
  75080. * Called by the GPUParticleSystem to setup the update shader
  75081. * @param effect defines the update shader
  75082. */
  75083. applyToShader(effect: Effect): void;
  75084. /**
  75085. * Returns a string to use to update the GPU particles update shader
  75086. * @returns a string containng the defines string
  75087. */
  75088. getEffectDefines(): string;
  75089. /**
  75090. * Returns the string "PointParticleEmitter"
  75091. * @returns a string containing the class name
  75092. */
  75093. getClassName(): string;
  75094. /**
  75095. * Serializes the particle system to a JSON object.
  75096. * @returns the JSON object
  75097. */
  75098. serialize(): any;
  75099. /**
  75100. * Parse properties from a JSON object
  75101. * @param serializationObject defines the JSON object
  75102. */
  75103. parse(serializationObject: any): void;
  75104. }
  75105. }
  75106. declare module BABYLON {
  75107. /**
  75108. * Particle emitter emitting particles from the inside of a sphere.
  75109. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  75110. */
  75111. export class SphereParticleEmitter implements IParticleEmitterType {
  75112. /**
  75113. * The radius of the emission sphere.
  75114. */
  75115. radius: number;
  75116. /**
  75117. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  75118. */
  75119. radiusRange: number;
  75120. /**
  75121. * How much to randomize the particle direction [0-1].
  75122. */
  75123. directionRandomizer: number;
  75124. /**
  75125. * Creates a new instance SphereParticleEmitter
  75126. * @param radius the radius of the emission sphere (1 by default)
  75127. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  75128. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  75129. */
  75130. constructor(
  75131. /**
  75132. * The radius of the emission sphere.
  75133. */
  75134. radius?: number,
  75135. /**
  75136. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  75137. */
  75138. radiusRange?: number,
  75139. /**
  75140. * How much to randomize the particle direction [0-1].
  75141. */
  75142. directionRandomizer?: number);
  75143. /**
  75144. * Called by the particle System when the direction is computed for the created particle.
  75145. * @param worldMatrix is the world matrix of the particle system
  75146. * @param directionToUpdate is the direction vector to update with the result
  75147. * @param particle is the particle we are computed the direction for
  75148. */
  75149. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  75150. /**
  75151. * Called by the particle System when the position is computed for the created particle.
  75152. * @param worldMatrix is the world matrix of the particle system
  75153. * @param positionToUpdate is the position vector to update with the result
  75154. * @param particle is the particle we are computed the position for
  75155. */
  75156. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  75157. /**
  75158. * Clones the current emitter and returns a copy of it
  75159. * @returns the new emitter
  75160. */
  75161. clone(): SphereParticleEmitter;
  75162. /**
  75163. * Called by the GPUParticleSystem to setup the update shader
  75164. * @param effect defines the update shader
  75165. */
  75166. applyToShader(effect: Effect): void;
  75167. /**
  75168. * Returns a string to use to update the GPU particles update shader
  75169. * @returns a string containng the defines string
  75170. */
  75171. getEffectDefines(): string;
  75172. /**
  75173. * Returns the string "SphereParticleEmitter"
  75174. * @returns a string containing the class name
  75175. */
  75176. getClassName(): string;
  75177. /**
  75178. * Serializes the particle system to a JSON object.
  75179. * @returns the JSON object
  75180. */
  75181. serialize(): any;
  75182. /**
  75183. * Parse properties from a JSON object
  75184. * @param serializationObject defines the JSON object
  75185. */
  75186. parse(serializationObject: any): void;
  75187. }
  75188. /**
  75189. * Particle emitter emitting particles from the inside of a sphere.
  75190. * It emits the particles randomly between two vectors.
  75191. */
  75192. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  75193. /**
  75194. * The min limit of the emission direction.
  75195. */
  75196. direction1: Vector3;
  75197. /**
  75198. * The max limit of the emission direction.
  75199. */
  75200. direction2: Vector3;
  75201. /**
  75202. * Creates a new instance SphereDirectedParticleEmitter
  75203. * @param radius the radius of the emission sphere (1 by default)
  75204. * @param direction1 the min limit of the emission direction (up vector by default)
  75205. * @param direction2 the max limit of the emission direction (up vector by default)
  75206. */
  75207. constructor(radius?: number,
  75208. /**
  75209. * The min limit of the emission direction.
  75210. */
  75211. direction1?: Vector3,
  75212. /**
  75213. * The max limit of the emission direction.
  75214. */
  75215. direction2?: Vector3);
  75216. /**
  75217. * Called by the particle System when the direction is computed for the created particle.
  75218. * @param worldMatrix is the world matrix of the particle system
  75219. * @param directionToUpdate is the direction vector to update with the result
  75220. * @param particle is the particle we are computed the direction for
  75221. */
  75222. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  75223. /**
  75224. * Clones the current emitter and returns a copy of it
  75225. * @returns the new emitter
  75226. */
  75227. clone(): SphereDirectedParticleEmitter;
  75228. /**
  75229. * Called by the GPUParticleSystem to setup the update shader
  75230. * @param effect defines the update shader
  75231. */
  75232. applyToShader(effect: Effect): void;
  75233. /**
  75234. * Returns a string to use to update the GPU particles update shader
  75235. * @returns a string containng the defines string
  75236. */
  75237. getEffectDefines(): string;
  75238. /**
  75239. * Returns the string "SphereDirectedParticleEmitter"
  75240. * @returns a string containing the class name
  75241. */
  75242. getClassName(): string;
  75243. /**
  75244. * Serializes the particle system to a JSON object.
  75245. * @returns the JSON object
  75246. */
  75247. serialize(): any;
  75248. /**
  75249. * Parse properties from a JSON object
  75250. * @param serializationObject defines the JSON object
  75251. */
  75252. parse(serializationObject: any): void;
  75253. }
  75254. }
  75255. declare module BABYLON {
  75256. /**
  75257. * Interface representing a particle system in Babylon.js.
  75258. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  75259. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  75260. */
  75261. export interface IParticleSystem {
  75262. /**
  75263. * List of animations used by the particle system.
  75264. */
  75265. animations: Animation[];
  75266. /**
  75267. * The id of the Particle system.
  75268. */
  75269. id: string;
  75270. /**
  75271. * The name of the Particle system.
  75272. */
  75273. name: string;
  75274. /**
  75275. * The emitter represents the Mesh or position we are attaching the particle system to.
  75276. */
  75277. emitter: Nullable<AbstractMesh | Vector3>;
  75278. /**
  75279. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  75280. */
  75281. isBillboardBased: boolean;
  75282. /**
  75283. * The rendering group used by the Particle system to chose when to render.
  75284. */
  75285. renderingGroupId: number;
  75286. /**
  75287. * The layer mask we are rendering the particles through.
  75288. */
  75289. layerMask: number;
  75290. /**
  75291. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  75292. */
  75293. updateSpeed: number;
  75294. /**
  75295. * The amount of time the particle system is running (depends of the overall update speed).
  75296. */
  75297. targetStopDuration: number;
  75298. /**
  75299. * The texture used to render each particle. (this can be a spritesheet)
  75300. */
  75301. particleTexture: Nullable<Texture>;
  75302. /**
  75303. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  75304. */
  75305. blendMode: number;
  75306. /**
  75307. * Minimum life time of emitting particles.
  75308. */
  75309. minLifeTime: number;
  75310. /**
  75311. * Maximum life time of emitting particles.
  75312. */
  75313. maxLifeTime: number;
  75314. /**
  75315. * Minimum Size of emitting particles.
  75316. */
  75317. minSize: number;
  75318. /**
  75319. * Maximum Size of emitting particles.
  75320. */
  75321. maxSize: number;
  75322. /**
  75323. * Minimum scale of emitting particles on X axis.
  75324. */
  75325. minScaleX: number;
  75326. /**
  75327. * Maximum scale of emitting particles on X axis.
  75328. */
  75329. maxScaleX: number;
  75330. /**
  75331. * Minimum scale of emitting particles on Y axis.
  75332. */
  75333. minScaleY: number;
  75334. /**
  75335. * Maximum scale of emitting particles on Y axis.
  75336. */
  75337. maxScaleY: number;
  75338. /**
  75339. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  75340. */
  75341. color1: Color4;
  75342. /**
  75343. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  75344. */
  75345. color2: Color4;
  75346. /**
  75347. * Color the particle will have at the end of its lifetime.
  75348. */
  75349. colorDead: Color4;
  75350. /**
  75351. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  75352. */
  75353. emitRate: number;
  75354. /**
  75355. * You can use gravity if you want to give an orientation to your particles.
  75356. */
  75357. gravity: Vector3;
  75358. /**
  75359. * Minimum power of emitting particles.
  75360. */
  75361. minEmitPower: number;
  75362. /**
  75363. * Maximum power of emitting particles.
  75364. */
  75365. maxEmitPower: number;
  75366. /**
  75367. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  75368. */
  75369. minAngularSpeed: number;
  75370. /**
  75371. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  75372. */
  75373. maxAngularSpeed: number;
  75374. /**
  75375. * Gets or sets the minimal initial rotation in radians.
  75376. */
  75377. minInitialRotation: number;
  75378. /**
  75379. * Gets or sets the maximal initial rotation in radians.
  75380. */
  75381. maxInitialRotation: number;
  75382. /**
  75383. * The particle emitter type defines the emitter used by the particle system.
  75384. * It can be for example box, sphere, or cone...
  75385. */
  75386. particleEmitterType: Nullable<IParticleEmitterType>;
  75387. /**
  75388. * Defines the delay in milliseconds before starting the system (0 by default)
  75389. */
  75390. startDelay: number;
  75391. /**
  75392. * 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
  75393. */
  75394. preWarmCycles: number;
  75395. /**
  75396. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  75397. */
  75398. preWarmStepOffset: number;
  75399. /**
  75400. * 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)
  75401. */
  75402. spriteCellChangeSpeed: number;
  75403. /**
  75404. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  75405. */
  75406. startSpriteCellID: number;
  75407. /**
  75408. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  75409. */
  75410. endSpriteCellID: number;
  75411. /**
  75412. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  75413. */
  75414. spriteCellWidth: number;
  75415. /**
  75416. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  75417. */
  75418. spriteCellHeight: number;
  75419. /**
  75420. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  75421. */
  75422. spriteRandomStartCell: boolean;
  75423. /**
  75424. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  75425. */
  75426. isAnimationSheetEnabled: boolean;
  75427. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  75428. translationPivot: Vector2;
  75429. /**
  75430. * Gets or sets a texture used to add random noise to particle positions
  75431. */
  75432. noiseTexture: Nullable<BaseTexture>;
  75433. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  75434. noiseStrength: Vector3;
  75435. /**
  75436. * Gets or sets the billboard mode to use when isBillboardBased = true.
  75437. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  75438. */
  75439. billboardMode: number;
  75440. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  75441. limitVelocityDamping: number;
  75442. /**
  75443. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  75444. */
  75445. beginAnimationOnStart: boolean;
  75446. /**
  75447. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  75448. */
  75449. beginAnimationFrom: number;
  75450. /**
  75451. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  75452. */
  75453. beginAnimationTo: number;
  75454. /**
  75455. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  75456. */
  75457. beginAnimationLoop: boolean;
  75458. /**
  75459. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  75460. */
  75461. disposeOnStop: boolean;
  75462. /**
  75463. * Gets the maximum number of particles active at the same time.
  75464. * @returns The max number of active particles.
  75465. */
  75466. getCapacity(): number;
  75467. /**
  75468. * Gets if the system has been started. (Note: this will still be true after stop is called)
  75469. * @returns True if it has been started, otherwise false.
  75470. */
  75471. isStarted(): boolean;
  75472. /**
  75473. * Animates the particle system for this frame.
  75474. */
  75475. animate(): void;
  75476. /**
  75477. * Renders the particle system in its current state.
  75478. * @returns the current number of particles
  75479. */
  75480. render(): number;
  75481. /**
  75482. * Dispose the particle system and frees its associated resources.
  75483. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  75484. */
  75485. dispose(disposeTexture?: boolean): void;
  75486. /**
  75487. * Clones the particle system.
  75488. * @param name The name of the cloned object
  75489. * @param newEmitter The new emitter to use
  75490. * @returns the cloned particle system
  75491. */
  75492. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  75493. /**
  75494. * Serializes the particle system to a JSON object.
  75495. * @returns the JSON object
  75496. */
  75497. serialize(): any;
  75498. /**
  75499. * Rebuild the particle system
  75500. */
  75501. rebuild(): void;
  75502. /**
  75503. * Starts the particle system and begins to emit
  75504. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  75505. */
  75506. start(delay?: number): void;
  75507. /**
  75508. * Stops the particle system.
  75509. */
  75510. stop(): void;
  75511. /**
  75512. * Remove all active particles
  75513. */
  75514. reset(): void;
  75515. /**
  75516. * Is this system ready to be used/rendered
  75517. * @return true if the system is ready
  75518. */
  75519. isReady(): boolean;
  75520. /**
  75521. * Adds a new color gradient
  75522. * @param gradient defines the gradient to use (between 0 and 1)
  75523. * @param color1 defines the color to affect to the specified gradient
  75524. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  75525. * @returns the current particle system
  75526. */
  75527. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  75528. /**
  75529. * Remove a specific color gradient
  75530. * @param gradient defines the gradient to remove
  75531. * @returns the current particle system
  75532. */
  75533. removeColorGradient(gradient: number): IParticleSystem;
  75534. /**
  75535. * Adds a new size gradient
  75536. * @param gradient defines the gradient to use (between 0 and 1)
  75537. * @param factor defines the size factor to affect to the specified gradient
  75538. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  75539. * @returns the current particle system
  75540. */
  75541. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  75542. /**
  75543. * Remove a specific size gradient
  75544. * @param gradient defines the gradient to remove
  75545. * @returns the current particle system
  75546. */
  75547. removeSizeGradient(gradient: number): IParticleSystem;
  75548. /**
  75549. * Gets the current list of color gradients.
  75550. * You must use addColorGradient and removeColorGradient to udpate this list
  75551. * @returns the list of color gradients
  75552. */
  75553. getColorGradients(): Nullable<Array<ColorGradient>>;
  75554. /**
  75555. * Gets the current list of size gradients.
  75556. * You must use addSizeGradient and removeSizeGradient to udpate this list
  75557. * @returns the list of size gradients
  75558. */
  75559. getSizeGradients(): Nullable<Array<FactorGradient>>;
  75560. /**
  75561. * Gets the current list of angular speed gradients.
  75562. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  75563. * @returns the list of angular speed gradients
  75564. */
  75565. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  75566. /**
  75567. * Adds a new angular speed gradient
  75568. * @param gradient defines the gradient to use (between 0 and 1)
  75569. * @param factor defines the angular speed to affect to the specified gradient
  75570. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  75571. * @returns the current particle system
  75572. */
  75573. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  75574. /**
  75575. * Remove a specific angular speed gradient
  75576. * @param gradient defines the gradient to remove
  75577. * @returns the current particle system
  75578. */
  75579. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  75580. /**
  75581. * Gets the current list of velocity gradients.
  75582. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  75583. * @returns the list of velocity gradients
  75584. */
  75585. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  75586. /**
  75587. * Adds a new velocity gradient
  75588. * @param gradient defines the gradient to use (between 0 and 1)
  75589. * @param factor defines the velocity to affect to the specified gradient
  75590. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  75591. * @returns the current particle system
  75592. */
  75593. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  75594. /**
  75595. * Remove a specific velocity gradient
  75596. * @param gradient defines the gradient to remove
  75597. * @returns the current particle system
  75598. */
  75599. removeVelocityGradient(gradient: number): IParticleSystem;
  75600. /**
  75601. * Gets the current list of limit velocity gradients.
  75602. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  75603. * @returns the list of limit velocity gradients
  75604. */
  75605. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  75606. /**
  75607. * Adds a new limit velocity gradient
  75608. * @param gradient defines the gradient to use (between 0 and 1)
  75609. * @param factor defines the limit velocity to affect to the specified gradient
  75610. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  75611. * @returns the current particle system
  75612. */
  75613. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  75614. /**
  75615. * Remove a specific limit velocity gradient
  75616. * @param gradient defines the gradient to remove
  75617. * @returns the current particle system
  75618. */
  75619. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  75620. /**
  75621. * Adds a new drag gradient
  75622. * @param gradient defines the gradient to use (between 0 and 1)
  75623. * @param factor defines the drag to affect to the specified gradient
  75624. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  75625. * @returns the current particle system
  75626. */
  75627. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  75628. /**
  75629. * Remove a specific drag gradient
  75630. * @param gradient defines the gradient to remove
  75631. * @returns the current particle system
  75632. */
  75633. removeDragGradient(gradient: number): IParticleSystem;
  75634. /**
  75635. * Gets the current list of drag gradients.
  75636. * You must use addDragGradient and removeDragGradient to udpate this list
  75637. * @returns the list of drag gradients
  75638. */
  75639. getDragGradients(): Nullable<Array<FactorGradient>>;
  75640. /**
  75641. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  75642. * @param gradient defines the gradient to use (between 0 and 1)
  75643. * @param factor defines the emit rate to affect to the specified gradient
  75644. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  75645. * @returns the current particle system
  75646. */
  75647. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  75648. /**
  75649. * Remove a specific emit rate gradient
  75650. * @param gradient defines the gradient to remove
  75651. * @returns the current particle system
  75652. */
  75653. removeEmitRateGradient(gradient: number): IParticleSystem;
  75654. /**
  75655. * Gets the current list of emit rate gradients.
  75656. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  75657. * @returns the list of emit rate gradients
  75658. */
  75659. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  75660. /**
  75661. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  75662. * @param gradient defines the gradient to use (between 0 and 1)
  75663. * @param factor defines the start size to affect to the specified gradient
  75664. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  75665. * @returns the current particle system
  75666. */
  75667. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  75668. /**
  75669. * Remove a specific start size gradient
  75670. * @param gradient defines the gradient to remove
  75671. * @returns the current particle system
  75672. */
  75673. removeStartSizeGradient(gradient: number): IParticleSystem;
  75674. /**
  75675. * Gets the current list of start size gradients.
  75676. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  75677. * @returns the list of start size gradients
  75678. */
  75679. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  75680. /**
  75681. * Adds a new life time gradient
  75682. * @param gradient defines the gradient to use (between 0 and 1)
  75683. * @param factor defines the life time factor to affect to the specified gradient
  75684. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  75685. * @returns the current particle system
  75686. */
  75687. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  75688. /**
  75689. * Remove a specific life time gradient
  75690. * @param gradient defines the gradient to remove
  75691. * @returns the current particle system
  75692. */
  75693. removeLifeTimeGradient(gradient: number): IParticleSystem;
  75694. /**
  75695. * Gets the current list of life time gradients.
  75696. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  75697. * @returns the list of life time gradients
  75698. */
  75699. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  75700. /**
  75701. * Gets the current list of color gradients.
  75702. * You must use addColorGradient and removeColorGradient to udpate this list
  75703. * @returns the list of color gradients
  75704. */
  75705. getColorGradients(): Nullable<Array<ColorGradient>>;
  75706. /**
  75707. * Adds a new ramp gradient used to remap particle colors
  75708. * @param gradient defines the gradient to use (between 0 and 1)
  75709. * @param color defines the color to affect to the specified gradient
  75710. * @returns the current particle system
  75711. */
  75712. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  75713. /**
  75714. * Gets the current list of ramp gradients.
  75715. * You must use addRampGradient and removeRampGradient to udpate this list
  75716. * @returns the list of ramp gradients
  75717. */
  75718. getRampGradients(): Nullable<Array<Color3Gradient>>;
  75719. /** Gets or sets a boolean indicating that ramp gradients must be used
  75720. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  75721. */
  75722. useRampGradients: boolean;
  75723. /**
  75724. * Adds a new color remap gradient
  75725. * @param gradient defines the gradient to use (between 0 and 1)
  75726. * @param min defines the color remap minimal range
  75727. * @param max defines the color remap maximal range
  75728. * @returns the current particle system
  75729. */
  75730. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  75731. /**
  75732. * Gets the current list of color remap gradients.
  75733. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  75734. * @returns the list of color remap gradients
  75735. */
  75736. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  75737. /**
  75738. * Adds a new alpha remap gradient
  75739. * @param gradient defines the gradient to use (between 0 and 1)
  75740. * @param min defines the alpha remap minimal range
  75741. * @param max defines the alpha remap maximal range
  75742. * @returns the current particle system
  75743. */
  75744. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  75745. /**
  75746. * Gets the current list of alpha remap gradients.
  75747. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  75748. * @returns the list of alpha remap gradients
  75749. */
  75750. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  75751. /**
  75752. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  75753. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  75754. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  75755. * @returns the emitter
  75756. */
  75757. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  75758. /**
  75759. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  75760. * @param radius The radius of the hemisphere to emit from
  75761. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  75762. * @returns the emitter
  75763. */
  75764. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  75765. /**
  75766. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  75767. * @param radius The radius of the sphere to emit from
  75768. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  75769. * @returns the emitter
  75770. */
  75771. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  75772. /**
  75773. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  75774. * @param radius The radius of the sphere to emit from
  75775. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  75776. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  75777. * @returns the emitter
  75778. */
  75779. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  75780. /**
  75781. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  75782. * @param radius The radius of the emission cylinder
  75783. * @param height The height of the emission cylinder
  75784. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  75785. * @param directionRandomizer How much to randomize the particle direction [0-1]
  75786. * @returns the emitter
  75787. */
  75788. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  75789. /**
  75790. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  75791. * @param radius The radius of the cylinder to emit from
  75792. * @param height The height of the emission cylinder
  75793. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  75794. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  75795. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  75796. * @returns the emitter
  75797. */
  75798. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  75799. /**
  75800. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  75801. * @param radius The radius of the cone to emit from
  75802. * @param angle The base angle of the cone
  75803. * @returns the emitter
  75804. */
  75805. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  75806. /**
  75807. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  75808. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  75809. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  75810. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  75811. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  75812. * @returns the emitter
  75813. */
  75814. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  75815. /**
  75816. * Get hosting scene
  75817. * @returns the scene
  75818. */
  75819. getScene(): Scene;
  75820. }
  75821. }
  75822. declare module BABYLON {
  75823. /**
  75824. * Creates an instance based on a source mesh.
  75825. */
  75826. export class InstancedMesh extends AbstractMesh {
  75827. private _sourceMesh;
  75828. private _currentLOD;
  75829. /** @hidden */
  75830. _indexInSourceMeshInstanceArray: number;
  75831. constructor(name: string, source: Mesh);
  75832. /**
  75833. * Returns the string "InstancedMesh".
  75834. */
  75835. getClassName(): string;
  75836. /**
  75837. * If the source mesh receives shadows
  75838. */
  75839. readonly receiveShadows: boolean;
  75840. /**
  75841. * The material of the source mesh
  75842. */
  75843. readonly material: Nullable<Material>;
  75844. /**
  75845. * Visibility of the source mesh
  75846. */
  75847. readonly visibility: number;
  75848. /**
  75849. * Skeleton of the source mesh
  75850. */
  75851. readonly skeleton: Nullable<Skeleton>;
  75852. /**
  75853. * Rendering ground id of the source mesh
  75854. */
  75855. renderingGroupId: number;
  75856. /**
  75857. * Returns the total number of vertices (integer).
  75858. */
  75859. getTotalVertices(): number;
  75860. /**
  75861. * Returns a positive integer : the total number of indices in this mesh geometry.
  75862. * @returns the numner of indices or zero if the mesh has no geometry.
  75863. */
  75864. getTotalIndices(): number;
  75865. /**
  75866. * The source mesh of the instance
  75867. */
  75868. readonly sourceMesh: Mesh;
  75869. /**
  75870. * Is this node ready to be used/rendered
  75871. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  75872. * @return {boolean} is it ready
  75873. */
  75874. isReady(completeCheck?: boolean): boolean;
  75875. /**
  75876. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  75877. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  75878. * @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.
  75879. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  75880. */
  75881. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  75882. /**
  75883. * Sets the vertex data of the mesh geometry for the requested `kind`.
  75884. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  75885. * The `data` are either a numeric array either a Float32Array.
  75886. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  75887. * 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).
  75888. * Note that a new underlying VertexBuffer object is created each call.
  75889. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  75890. *
  75891. * Possible `kind` values :
  75892. * - VertexBuffer.PositionKind
  75893. * - VertexBuffer.UVKind
  75894. * - VertexBuffer.UV2Kind
  75895. * - VertexBuffer.UV3Kind
  75896. * - VertexBuffer.UV4Kind
  75897. * - VertexBuffer.UV5Kind
  75898. * - VertexBuffer.UV6Kind
  75899. * - VertexBuffer.ColorKind
  75900. * - VertexBuffer.MatricesIndicesKind
  75901. * - VertexBuffer.MatricesIndicesExtraKind
  75902. * - VertexBuffer.MatricesWeightsKind
  75903. * - VertexBuffer.MatricesWeightsExtraKind
  75904. *
  75905. * Returns the Mesh.
  75906. */
  75907. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  75908. /**
  75909. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  75910. * If the mesh has no geometry, it is simply returned as it is.
  75911. * The `data` are either a numeric array either a Float32Array.
  75912. * No new underlying VertexBuffer object is created.
  75913. * 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.
  75914. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  75915. *
  75916. * Possible `kind` values :
  75917. * - VertexBuffer.PositionKind
  75918. * - VertexBuffer.UVKind
  75919. * - VertexBuffer.UV2Kind
  75920. * - VertexBuffer.UV3Kind
  75921. * - VertexBuffer.UV4Kind
  75922. * - VertexBuffer.UV5Kind
  75923. * - VertexBuffer.UV6Kind
  75924. * - VertexBuffer.ColorKind
  75925. * - VertexBuffer.MatricesIndicesKind
  75926. * - VertexBuffer.MatricesIndicesExtraKind
  75927. * - VertexBuffer.MatricesWeightsKind
  75928. * - VertexBuffer.MatricesWeightsExtraKind
  75929. *
  75930. * Returns the Mesh.
  75931. */
  75932. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  75933. /**
  75934. * Sets the mesh indices.
  75935. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  75936. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  75937. * This method creates a new index buffer each call.
  75938. * Returns the Mesh.
  75939. */
  75940. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  75941. /**
  75942. * Boolean : True if the mesh owns the requested kind of data.
  75943. */
  75944. isVerticesDataPresent(kind: string): boolean;
  75945. /**
  75946. * Returns an array of indices (IndicesArray).
  75947. */
  75948. getIndices(): Nullable<IndicesArray>;
  75949. readonly _positions: Nullable<Vector3[]>;
  75950. /**
  75951. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  75952. * This means the mesh underlying bounding box and sphere are recomputed.
  75953. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  75954. * @returns the current mesh
  75955. */
  75956. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  75957. /** @hidden */
  75958. _preActivate(): InstancedMesh;
  75959. /** @hidden */
  75960. _activate(renderId: number): InstancedMesh;
  75961. /**
  75962. * Returns the current associated LOD AbstractMesh.
  75963. */
  75964. getLOD(camera: Camera): AbstractMesh;
  75965. /** @hidden */
  75966. _syncSubMeshes(): InstancedMesh;
  75967. /** @hidden */
  75968. _generatePointsArray(): boolean;
  75969. /**
  75970. * Creates a new InstancedMesh from the current mesh.
  75971. * - name (string) : the cloned mesh name
  75972. * - newParent (optional Node) : the optional Node to parent the clone to.
  75973. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  75974. *
  75975. * Returns the clone.
  75976. */
  75977. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  75978. /**
  75979. * Disposes the InstancedMesh.
  75980. * Returns nothing.
  75981. */
  75982. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  75983. }
  75984. }
  75985. declare module BABYLON {
  75986. /**
  75987. * Defines the options associated with the creation of a shader material.
  75988. */
  75989. export interface IShaderMaterialOptions {
  75990. /**
  75991. * Does the material work in alpha blend mode
  75992. */
  75993. needAlphaBlending: boolean;
  75994. /**
  75995. * Does the material work in alpha test mode
  75996. */
  75997. needAlphaTesting: boolean;
  75998. /**
  75999. * The list of attribute names used in the shader
  76000. */
  76001. attributes: string[];
  76002. /**
  76003. * The list of unifrom names used in the shader
  76004. */
  76005. uniforms: string[];
  76006. /**
  76007. * The list of UBO names used in the shader
  76008. */
  76009. uniformBuffers: string[];
  76010. /**
  76011. * The list of sampler names used in the shader
  76012. */
  76013. samplers: string[];
  76014. /**
  76015. * The list of defines used in the shader
  76016. */
  76017. defines: string[];
  76018. }
  76019. /**
  76020. * 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.
  76021. *
  76022. * This returned material effects how the mesh will look based on the code in the shaders.
  76023. *
  76024. * @see http://doc.babylonjs.com/how_to/shader_material
  76025. */
  76026. export class ShaderMaterial extends Material {
  76027. private _shaderPath;
  76028. private _options;
  76029. private _textures;
  76030. private _textureArrays;
  76031. private _floats;
  76032. private _ints;
  76033. private _floatsArrays;
  76034. private _colors3;
  76035. private _colors3Arrays;
  76036. private _colors4;
  76037. private _vectors2;
  76038. private _vectors3;
  76039. private _vectors4;
  76040. private _matrices;
  76041. private _matrices3x3;
  76042. private _matrices2x2;
  76043. private _vectors2Arrays;
  76044. private _vectors3Arrays;
  76045. private _cachedWorldViewMatrix;
  76046. private _renderId;
  76047. /**
  76048. * Instantiate a new shader material.
  76049. * 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.
  76050. * This returned material effects how the mesh will look based on the code in the shaders.
  76051. * @see http://doc.babylonjs.com/how_to/shader_material
  76052. * @param name Define the name of the material in the scene
  76053. * @param scene Define the scene the material belongs to
  76054. * @param shaderPath Defines the route to the shader code in one of three ways:
  76055. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  76056. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  76057. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  76058. * @param options Define the options used to create the shader
  76059. */
  76060. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  76061. /**
  76062. * Gets the options used to compile the shader.
  76063. * They can be modified to trigger a new compilation
  76064. */
  76065. readonly options: IShaderMaterialOptions;
  76066. /**
  76067. * Gets the current class name of the material e.g. "ShaderMaterial"
  76068. * Mainly use in serialization.
  76069. * @returns the class name
  76070. */
  76071. getClassName(): string;
  76072. /**
  76073. * Specifies if the material will require alpha blending
  76074. * @returns a boolean specifying if alpha blending is needed
  76075. */
  76076. needAlphaBlending(): boolean;
  76077. /**
  76078. * Specifies if this material should be rendered in alpha test mode
  76079. * @returns a boolean specifying if an alpha test is needed.
  76080. */
  76081. needAlphaTesting(): boolean;
  76082. private _checkUniform;
  76083. /**
  76084. * Set a texture in the shader.
  76085. * @param name Define the name of the uniform samplers as defined in the shader
  76086. * @param texture Define the texture to bind to this sampler
  76087. * @return the material itself allowing "fluent" like uniform updates
  76088. */
  76089. setTexture(name: string, texture: Texture): ShaderMaterial;
  76090. /**
  76091. * Set a texture array in the shader.
  76092. * @param name Define the name of the uniform sampler array as defined in the shader
  76093. * @param textures Define the list of textures to bind to this sampler
  76094. * @return the material itself allowing "fluent" like uniform updates
  76095. */
  76096. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  76097. /**
  76098. * Set a float in the shader.
  76099. * @param name Define the name of the uniform as defined in the shader
  76100. * @param value Define the value to give to the uniform
  76101. * @return the material itself allowing "fluent" like uniform updates
  76102. */
  76103. setFloat(name: string, value: number): ShaderMaterial;
  76104. /**
  76105. * Set a int in the shader.
  76106. * @param name Define the name of the uniform as defined in the shader
  76107. * @param value Define the value to give to the uniform
  76108. * @return the material itself allowing "fluent" like uniform updates
  76109. */
  76110. setInt(name: string, value: number): ShaderMaterial;
  76111. /**
  76112. * Set an array of floats in the shader.
  76113. * @param name Define the name of the uniform as defined in the shader
  76114. * @param value Define the value to give to the uniform
  76115. * @return the material itself allowing "fluent" like uniform updates
  76116. */
  76117. setFloats(name: string, value: number[]): ShaderMaterial;
  76118. /**
  76119. * Set a vec3 in the shader from a Color3.
  76120. * @param name Define the name of the uniform as defined in the shader
  76121. * @param value Define the value to give to the uniform
  76122. * @return the material itself allowing "fluent" like uniform updates
  76123. */
  76124. setColor3(name: string, value: Color3): ShaderMaterial;
  76125. /**
  76126. * Set a vec3 array in the shader from a Color3 array.
  76127. * @param name Define the name of the uniform as defined in the shader
  76128. * @param value Define the value to give to the uniform
  76129. * @return the material itself allowing "fluent" like uniform updates
  76130. */
  76131. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  76132. /**
  76133. * Set a vec4 in the shader from a Color4.
  76134. * @param name Define the name of the uniform as defined in the shader
  76135. * @param value Define the value to give to the uniform
  76136. * @return the material itself allowing "fluent" like uniform updates
  76137. */
  76138. setColor4(name: string, value: Color4): ShaderMaterial;
  76139. /**
  76140. * Set a vec2 in the shader from a Vector2.
  76141. * @param name Define the name of the uniform as defined in the shader
  76142. * @param value Define the value to give to the uniform
  76143. * @return the material itself allowing "fluent" like uniform updates
  76144. */
  76145. setVector2(name: string, value: Vector2): ShaderMaterial;
  76146. /**
  76147. * Set a vec3 in the shader from a Vector3.
  76148. * @param name Define the name of the uniform as defined in the shader
  76149. * @param value Define the value to give to the uniform
  76150. * @return the material itself allowing "fluent" like uniform updates
  76151. */
  76152. setVector3(name: string, value: Vector3): ShaderMaterial;
  76153. /**
  76154. * Set a vec4 in the shader from a Vector4.
  76155. * @param name Define the name of the uniform as defined in the shader
  76156. * @param value Define the value to give to the uniform
  76157. * @return the material itself allowing "fluent" like uniform updates
  76158. */
  76159. setVector4(name: string, value: Vector4): ShaderMaterial;
  76160. /**
  76161. * Set a mat4 in the shader from a Matrix.
  76162. * @param name Define the name of the uniform as defined in the shader
  76163. * @param value Define the value to give to the uniform
  76164. * @return the material itself allowing "fluent" like uniform updates
  76165. */
  76166. setMatrix(name: string, value: Matrix): ShaderMaterial;
  76167. /**
  76168. * Set a mat3 in the shader from a Float32Array.
  76169. * @param name Define the name of the uniform as defined in the shader
  76170. * @param value Define the value to give to the uniform
  76171. * @return the material itself allowing "fluent" like uniform updates
  76172. */
  76173. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  76174. /**
  76175. * Set a mat2 in the shader from a Float32Array.
  76176. * @param name Define the name of the uniform as defined in the shader
  76177. * @param value Define the value to give to the uniform
  76178. * @return the material itself allowing "fluent" like uniform updates
  76179. */
  76180. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  76181. /**
  76182. * Set a vec2 array in the shader from a number array.
  76183. * @param name Define the name of the uniform as defined in the shader
  76184. * @param value Define the value to give to the uniform
  76185. * @return the material itself allowing "fluent" like uniform updates
  76186. */
  76187. setArray2(name: string, value: number[]): ShaderMaterial;
  76188. /**
  76189. * Set a vec3 array in the shader from a number array.
  76190. * @param name Define the name of the uniform as defined in the shader
  76191. * @param value Define the value to give to the uniform
  76192. * @return the material itself allowing "fluent" like uniform updates
  76193. */
  76194. setArray3(name: string, value: number[]): ShaderMaterial;
  76195. private _checkCache;
  76196. /**
  76197. * Specifies that the submesh is ready to be used
  76198. * @param mesh defines the mesh to check
  76199. * @param subMesh defines which submesh to check
  76200. * @param useInstances specifies that instances should be used
  76201. * @returns a boolean indicating that the submesh is ready or not
  76202. */
  76203. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  76204. /**
  76205. * Checks if the material is ready to render the requested mesh
  76206. * @param mesh Define the mesh to render
  76207. * @param useInstances Define whether or not the material is used with instances
  76208. * @returns true if ready, otherwise false
  76209. */
  76210. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  76211. /**
  76212. * Binds the world matrix to the material
  76213. * @param world defines the world transformation matrix
  76214. */
  76215. bindOnlyWorldMatrix(world: Matrix): void;
  76216. /**
  76217. * Binds the material to the mesh
  76218. * @param world defines the world transformation matrix
  76219. * @param mesh defines the mesh to bind the material to
  76220. */
  76221. bind(world: Matrix, mesh?: Mesh): void;
  76222. /**
  76223. * Gets the active textures from the material
  76224. * @returns an array of textures
  76225. */
  76226. getActiveTextures(): BaseTexture[];
  76227. /**
  76228. * Specifies if the material uses a texture
  76229. * @param texture defines the texture to check against the material
  76230. * @returns a boolean specifying if the material uses the texture
  76231. */
  76232. hasTexture(texture: BaseTexture): boolean;
  76233. /**
  76234. * Makes a duplicate of the material, and gives it a new name
  76235. * @param name defines the new name for the duplicated material
  76236. * @returns the cloned material
  76237. */
  76238. clone(name: string): ShaderMaterial;
  76239. /**
  76240. * Disposes the material
  76241. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  76242. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  76243. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  76244. */
  76245. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  76246. /**
  76247. * Serializes this material in a JSON representation
  76248. * @returns the serialized material object
  76249. */
  76250. serialize(): any;
  76251. /**
  76252. * Creates a shader material from parsed shader material data
  76253. * @param source defines the JSON represnetation of the material
  76254. * @param scene defines the hosting scene
  76255. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  76256. * @returns a new material
  76257. */
  76258. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  76259. }
  76260. }
  76261. declare module BABYLON {
  76262. /** @hidden */
  76263. export var colorPixelShader: {
  76264. name: string;
  76265. shader: string;
  76266. };
  76267. }
  76268. declare module BABYLON {
  76269. /** @hidden */
  76270. export var colorVertexShader: {
  76271. name: string;
  76272. shader: string;
  76273. };
  76274. }
  76275. declare module BABYLON {
  76276. /**
  76277. * Line mesh
  76278. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  76279. */
  76280. export class LinesMesh extends Mesh {
  76281. /**
  76282. * If vertex color should be applied to the mesh
  76283. */
  76284. useVertexColor?: boolean | undefined;
  76285. /**
  76286. * If vertex alpha should be applied to the mesh
  76287. */
  76288. useVertexAlpha?: boolean | undefined;
  76289. /**
  76290. * Color of the line (Default: White)
  76291. */
  76292. color: Color3;
  76293. /**
  76294. * Alpha of the line (Default: 1)
  76295. */
  76296. alpha: number;
  76297. /**
  76298. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  76299. * This margin is expressed in world space coordinates, so its value may vary.
  76300. * Default value is 0.1
  76301. */
  76302. intersectionThreshold: number;
  76303. private _colorShader;
  76304. /**
  76305. * Creates a new LinesMesh
  76306. * @param name defines the name
  76307. * @param scene defines the hosting scene
  76308. * @param parent defines the parent mesh if any
  76309. * @param source defines the optional source LinesMesh used to clone data from
  76310. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  76311. * When false, achieved by calling a clone(), also passing False.
  76312. * This will make creation of children, recursive.
  76313. * @param useVertexColor defines if this LinesMesh supports vertex color
  76314. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  76315. */
  76316. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  76317. /**
  76318. * If vertex color should be applied to the mesh
  76319. */
  76320. useVertexColor?: boolean | undefined,
  76321. /**
  76322. * If vertex alpha should be applied to the mesh
  76323. */
  76324. useVertexAlpha?: boolean | undefined);
  76325. private _addClipPlaneDefine;
  76326. private _removeClipPlaneDefine;
  76327. isReady(): boolean;
  76328. /**
  76329. * Returns the string "LineMesh"
  76330. */
  76331. getClassName(): string;
  76332. /**
  76333. * @hidden
  76334. */
  76335. /**
  76336. * @hidden
  76337. */
  76338. material: Material;
  76339. /**
  76340. * @hidden
  76341. */
  76342. readonly checkCollisions: boolean;
  76343. /** @hidden */
  76344. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  76345. /** @hidden */
  76346. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  76347. /**
  76348. * Disposes of the line mesh
  76349. * @param doNotRecurse If children should be disposed
  76350. */
  76351. dispose(doNotRecurse?: boolean): void;
  76352. /**
  76353. * Returns a new LineMesh object cloned from the current one.
  76354. */
  76355. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  76356. /**
  76357. * Creates a new InstancedLinesMesh object from the mesh model.
  76358. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  76359. * @param name defines the name of the new instance
  76360. * @returns a new InstancedLinesMesh
  76361. */
  76362. createInstance(name: string): InstancedLinesMesh;
  76363. }
  76364. /**
  76365. * Creates an instance based on a source LinesMesh
  76366. */
  76367. export class InstancedLinesMesh extends InstancedMesh {
  76368. /**
  76369. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  76370. * This margin is expressed in world space coordinates, so its value may vary.
  76371. * Initilized with the intersectionThreshold value of the source LinesMesh
  76372. */
  76373. intersectionThreshold: number;
  76374. constructor(name: string, source: LinesMesh);
  76375. /**
  76376. * Returns the string "InstancedLinesMesh".
  76377. */
  76378. getClassName(): string;
  76379. }
  76380. }
  76381. declare module BABYLON {
  76382. /** @hidden */
  76383. export var linePixelShader: {
  76384. name: string;
  76385. shader: string;
  76386. };
  76387. }
  76388. declare module BABYLON {
  76389. /** @hidden */
  76390. export var lineVertexShader: {
  76391. name: string;
  76392. shader: string;
  76393. };
  76394. }
  76395. declare module BABYLON {
  76396. interface AbstractMesh {
  76397. /**
  76398. * Disables the mesh edge rendering mode
  76399. * @returns the currentAbstractMesh
  76400. */
  76401. disableEdgesRendering(): AbstractMesh;
  76402. /**
  76403. * Enables the edge rendering mode on the mesh.
  76404. * This mode makes the mesh edges visible
  76405. * @param epsilon defines the maximal distance between two angles to detect a face
  76406. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  76407. * @returns the currentAbstractMesh
  76408. * @see https://www.babylonjs-playground.com/#19O9TU#0
  76409. */
  76410. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  76411. /**
  76412. * Gets the edgesRenderer associated with the mesh
  76413. */
  76414. edgesRenderer: Nullable<EdgesRenderer>;
  76415. }
  76416. interface LinesMesh {
  76417. /**
  76418. * Enables the edge rendering mode on the mesh.
  76419. * This mode makes the mesh edges visible
  76420. * @param epsilon defines the maximal distance between two angles to detect a face
  76421. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  76422. * @returns the currentAbstractMesh
  76423. * @see https://www.babylonjs-playground.com/#19O9TU#0
  76424. */
  76425. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  76426. }
  76427. interface InstancedLinesMesh {
  76428. /**
  76429. * Enables the edge rendering mode on the mesh.
  76430. * This mode makes the mesh edges visible
  76431. * @param epsilon defines the maximal distance between two angles to detect a face
  76432. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  76433. * @returns the current InstancedLinesMesh
  76434. * @see https://www.babylonjs-playground.com/#19O9TU#0
  76435. */
  76436. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  76437. }
  76438. /**
  76439. * Defines the minimum contract an Edges renderer should follow.
  76440. */
  76441. export interface IEdgesRenderer extends IDisposable {
  76442. /**
  76443. * Gets or sets a boolean indicating if the edgesRenderer is active
  76444. */
  76445. isEnabled: boolean;
  76446. /**
  76447. * Renders the edges of the attached mesh,
  76448. */
  76449. render(): void;
  76450. /**
  76451. * Checks wether or not the edges renderer is ready to render.
  76452. * @return true if ready, otherwise false.
  76453. */
  76454. isReady(): boolean;
  76455. }
  76456. /**
  76457. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  76458. */
  76459. export class EdgesRenderer implements IEdgesRenderer {
  76460. /**
  76461. * Define the size of the edges with an orthographic camera
  76462. */
  76463. edgesWidthScalerForOrthographic: number;
  76464. /**
  76465. * Define the size of the edges with a perspective camera
  76466. */
  76467. edgesWidthScalerForPerspective: number;
  76468. protected _source: AbstractMesh;
  76469. protected _linesPositions: number[];
  76470. protected _linesNormals: number[];
  76471. protected _linesIndices: number[];
  76472. protected _epsilon: number;
  76473. protected _indicesCount: number;
  76474. protected _lineShader: ShaderMaterial;
  76475. protected _ib: WebGLBuffer;
  76476. protected _buffers: {
  76477. [key: string]: Nullable<VertexBuffer>;
  76478. };
  76479. protected _checkVerticesInsteadOfIndices: boolean;
  76480. private _meshRebuildObserver;
  76481. private _meshDisposeObserver;
  76482. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  76483. isEnabled: boolean;
  76484. /**
  76485. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  76486. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  76487. * @param source Mesh used to create edges
  76488. * @param epsilon sum of angles in adjacency to check for edge
  76489. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  76490. * @param generateEdgesLines - should generate Lines or only prepare resources.
  76491. */
  76492. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  76493. protected _prepareRessources(): void;
  76494. /** @hidden */
  76495. _rebuild(): void;
  76496. /**
  76497. * Releases the required resources for the edges renderer
  76498. */
  76499. dispose(): void;
  76500. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  76501. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  76502. /**
  76503. * Checks if the pair of p0 and p1 is en edge
  76504. * @param faceIndex
  76505. * @param edge
  76506. * @param faceNormals
  76507. * @param p0
  76508. * @param p1
  76509. * @private
  76510. */
  76511. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  76512. /**
  76513. * push line into the position, normal and index buffer
  76514. * @protected
  76515. */
  76516. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  76517. /**
  76518. * Generates lines edges from adjacencjes
  76519. * @private
  76520. */
  76521. _generateEdgesLines(): void;
  76522. /**
  76523. * Checks wether or not the edges renderer is ready to render.
  76524. * @return true if ready, otherwise false.
  76525. */
  76526. isReady(): boolean;
  76527. /**
  76528. * Renders the edges of the attached mesh,
  76529. */
  76530. render(): void;
  76531. }
  76532. /**
  76533. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  76534. */
  76535. export class LineEdgesRenderer extends EdgesRenderer {
  76536. /**
  76537. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  76538. * @param source LineMesh used to generate edges
  76539. * @param epsilon not important (specified angle for edge detection)
  76540. * @param checkVerticesInsteadOfIndices not important for LineMesh
  76541. */
  76542. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  76543. /**
  76544. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  76545. */
  76546. _generateEdgesLines(): void;
  76547. }
  76548. }
  76549. declare module BABYLON {
  76550. /**
  76551. * This represents the object necessary to create a rendering group.
  76552. * This is exclusively used and created by the rendering manager.
  76553. * To modify the behavior, you use the available helpers in your scene or meshes.
  76554. * @hidden
  76555. */
  76556. export class RenderingGroup {
  76557. index: number;
  76558. private _scene;
  76559. private _opaqueSubMeshes;
  76560. private _transparentSubMeshes;
  76561. private _alphaTestSubMeshes;
  76562. private _depthOnlySubMeshes;
  76563. private _particleSystems;
  76564. private _spriteManagers;
  76565. private _opaqueSortCompareFn;
  76566. private _alphaTestSortCompareFn;
  76567. private _transparentSortCompareFn;
  76568. private _renderOpaque;
  76569. private _renderAlphaTest;
  76570. private _renderTransparent;
  76571. private _edgesRenderers;
  76572. onBeforeTransparentRendering: () => void;
  76573. /**
  76574. * Set the opaque sort comparison function.
  76575. * If null the sub meshes will be render in the order they were created
  76576. */
  76577. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  76578. /**
  76579. * Set the alpha test sort comparison function.
  76580. * If null the sub meshes will be render in the order they were created
  76581. */
  76582. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  76583. /**
  76584. * Set the transparent sort comparison function.
  76585. * If null the sub meshes will be render in the order they were created
  76586. */
  76587. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  76588. /**
  76589. * Creates a new rendering group.
  76590. * @param index The rendering group index
  76591. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  76592. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  76593. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  76594. */
  76595. 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>);
  76596. /**
  76597. * Render all the sub meshes contained in the group.
  76598. * @param customRenderFunction Used to override the default render behaviour of the group.
  76599. * @returns true if rendered some submeshes.
  76600. */
  76601. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  76602. /**
  76603. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  76604. * @param subMeshes The submeshes to render
  76605. */
  76606. private renderOpaqueSorted;
  76607. /**
  76608. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  76609. * @param subMeshes The submeshes to render
  76610. */
  76611. private renderAlphaTestSorted;
  76612. /**
  76613. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  76614. * @param subMeshes The submeshes to render
  76615. */
  76616. private renderTransparentSorted;
  76617. /**
  76618. * Renders the submeshes in a specified order.
  76619. * @param subMeshes The submeshes to sort before render
  76620. * @param sortCompareFn The comparison function use to sort
  76621. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  76622. * @param transparent Specifies to activate blending if true
  76623. */
  76624. private static renderSorted;
  76625. /**
  76626. * Renders the submeshes in the order they were dispatched (no sort applied).
  76627. * @param subMeshes The submeshes to render
  76628. */
  76629. private static renderUnsorted;
  76630. /**
  76631. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  76632. * are rendered back to front if in the same alpha index.
  76633. *
  76634. * @param a The first submesh
  76635. * @param b The second submesh
  76636. * @returns The result of the comparison
  76637. */
  76638. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  76639. /**
  76640. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  76641. * are rendered back to front.
  76642. *
  76643. * @param a The first submesh
  76644. * @param b The second submesh
  76645. * @returns The result of the comparison
  76646. */
  76647. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  76648. /**
  76649. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  76650. * are rendered front to back (prevent overdraw).
  76651. *
  76652. * @param a The first submesh
  76653. * @param b The second submesh
  76654. * @returns The result of the comparison
  76655. */
  76656. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  76657. /**
  76658. * Resets the different lists of submeshes to prepare a new frame.
  76659. */
  76660. prepare(): void;
  76661. dispose(): void;
  76662. /**
  76663. * Inserts the submesh in its correct queue depending on its material.
  76664. * @param subMesh The submesh to dispatch
  76665. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  76666. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  76667. */
  76668. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  76669. dispatchSprites(spriteManager: ISpriteManager): void;
  76670. dispatchParticles(particleSystem: IParticleSystem): void;
  76671. private _renderParticles;
  76672. private _renderSprites;
  76673. }
  76674. }
  76675. declare module BABYLON {
  76676. /**
  76677. * Interface describing the different options available in the rendering manager
  76678. * regarding Auto Clear between groups.
  76679. */
  76680. export interface IRenderingManagerAutoClearSetup {
  76681. /**
  76682. * Defines whether or not autoclear is enable.
  76683. */
  76684. autoClear: boolean;
  76685. /**
  76686. * Defines whether or not to autoclear the depth buffer.
  76687. */
  76688. depth: boolean;
  76689. /**
  76690. * Defines whether or not to autoclear the stencil buffer.
  76691. */
  76692. stencil: boolean;
  76693. }
  76694. /**
  76695. * This class is used by the onRenderingGroupObservable
  76696. */
  76697. export class RenderingGroupInfo {
  76698. /**
  76699. * The Scene that being rendered
  76700. */
  76701. scene: Scene;
  76702. /**
  76703. * The camera currently used for the rendering pass
  76704. */
  76705. camera: Nullable<Camera>;
  76706. /**
  76707. * The ID of the renderingGroup being processed
  76708. */
  76709. renderingGroupId: number;
  76710. }
  76711. /**
  76712. * This is the manager responsible of all the rendering for meshes sprites and particles.
  76713. * It is enable to manage the different groups as well as the different necessary sort functions.
  76714. * This should not be used directly aside of the few static configurations
  76715. */
  76716. export class RenderingManager {
  76717. /**
  76718. * The max id used for rendering groups (not included)
  76719. */
  76720. static MAX_RENDERINGGROUPS: number;
  76721. /**
  76722. * The min id used for rendering groups (included)
  76723. */
  76724. static MIN_RENDERINGGROUPS: number;
  76725. /**
  76726. * Used to globally prevent autoclearing scenes.
  76727. */
  76728. static AUTOCLEAR: boolean;
  76729. /**
  76730. * @hidden
  76731. */
  76732. _useSceneAutoClearSetup: boolean;
  76733. private _scene;
  76734. private _renderingGroups;
  76735. private _depthStencilBufferAlreadyCleaned;
  76736. private _autoClearDepthStencil;
  76737. private _customOpaqueSortCompareFn;
  76738. private _customAlphaTestSortCompareFn;
  76739. private _customTransparentSortCompareFn;
  76740. private _renderingGroupInfo;
  76741. /**
  76742. * Instantiates a new rendering group for a particular scene
  76743. * @param scene Defines the scene the groups belongs to
  76744. */
  76745. constructor(scene: Scene);
  76746. private _clearDepthStencilBuffer;
  76747. /**
  76748. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  76749. * @hidden
  76750. */
  76751. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  76752. /**
  76753. * Resets the different information of the group to prepare a new frame
  76754. * @hidden
  76755. */
  76756. reset(): void;
  76757. /**
  76758. * Dispose and release the group and its associated resources.
  76759. * @hidden
  76760. */
  76761. dispose(): void;
  76762. /**
  76763. * Clear the info related to rendering groups preventing retention points during dispose.
  76764. */
  76765. freeRenderingGroups(): void;
  76766. private _prepareRenderingGroup;
  76767. /**
  76768. * Add a sprite manager to the rendering manager in order to render it this frame.
  76769. * @param spriteManager Define the sprite manager to render
  76770. */
  76771. dispatchSprites(spriteManager: ISpriteManager): void;
  76772. /**
  76773. * Add a particle system to the rendering manager in order to render it this frame.
  76774. * @param particleSystem Define the particle system to render
  76775. */
  76776. dispatchParticles(particleSystem: IParticleSystem): void;
  76777. /**
  76778. * Add a submesh to the manager in order to render it this frame
  76779. * @param subMesh The submesh to dispatch
  76780. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  76781. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  76782. */
  76783. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  76784. /**
  76785. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  76786. * This allowed control for front to back rendering or reversly depending of the special needs.
  76787. *
  76788. * @param renderingGroupId The rendering group id corresponding to its index
  76789. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  76790. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  76791. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  76792. */
  76793. 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;
  76794. /**
  76795. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  76796. *
  76797. * @param renderingGroupId The rendering group id corresponding to its index
  76798. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  76799. * @param depth Automatically clears depth between groups if true and autoClear is true.
  76800. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  76801. */
  76802. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  76803. /**
  76804. * Gets the current auto clear configuration for one rendering group of the rendering
  76805. * manager.
  76806. * @param index the rendering group index to get the information for
  76807. * @returns The auto clear setup for the requested rendering group
  76808. */
  76809. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  76810. }
  76811. }
  76812. declare module BABYLON {
  76813. /**
  76814. * This Helps creating a texture that will be created from a camera in your scene.
  76815. * It is basically a dynamic texture that could be used to create special effects for instance.
  76816. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  76817. */
  76818. export class RenderTargetTexture extends Texture {
  76819. isCube: boolean;
  76820. /**
  76821. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  76822. */
  76823. static readonly REFRESHRATE_RENDER_ONCE: number;
  76824. /**
  76825. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  76826. */
  76827. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  76828. /**
  76829. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  76830. * the central point of your effect and can save a lot of performances.
  76831. */
  76832. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  76833. /**
  76834. * Use this predicate to dynamically define the list of mesh you want to render.
  76835. * If set, the renderList property will be overwritten.
  76836. */
  76837. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  76838. private _renderList;
  76839. /**
  76840. * Use this list to define the list of mesh you want to render.
  76841. */
  76842. renderList: Nullable<Array<AbstractMesh>>;
  76843. private _hookArray;
  76844. /**
  76845. * Define if particles should be rendered in your texture.
  76846. */
  76847. renderParticles: boolean;
  76848. /**
  76849. * Define if sprites should be rendered in your texture.
  76850. */
  76851. renderSprites: boolean;
  76852. /**
  76853. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  76854. */
  76855. coordinatesMode: number;
  76856. /**
  76857. * Define the camera used to render the texture.
  76858. */
  76859. activeCamera: Nullable<Camera>;
  76860. /**
  76861. * Override the render function of the texture with your own one.
  76862. */
  76863. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  76864. /**
  76865. * Define if camera post processes should be use while rendering the texture.
  76866. */
  76867. useCameraPostProcesses: boolean;
  76868. /**
  76869. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  76870. */
  76871. ignoreCameraViewport: boolean;
  76872. private _postProcessManager;
  76873. private _postProcesses;
  76874. private _resizeObserver;
  76875. /**
  76876. * An event triggered when the texture is unbind.
  76877. */
  76878. onBeforeBindObservable: Observable<RenderTargetTexture>;
  76879. /**
  76880. * An event triggered when the texture is unbind.
  76881. */
  76882. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  76883. private _onAfterUnbindObserver;
  76884. /**
  76885. * Set a after unbind callback in the texture.
  76886. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  76887. */
  76888. onAfterUnbind: () => void;
  76889. /**
  76890. * An event triggered before rendering the texture
  76891. */
  76892. onBeforeRenderObservable: Observable<number>;
  76893. private _onBeforeRenderObserver;
  76894. /**
  76895. * Set a before render callback in the texture.
  76896. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  76897. */
  76898. onBeforeRender: (faceIndex: number) => void;
  76899. /**
  76900. * An event triggered after rendering the texture
  76901. */
  76902. onAfterRenderObservable: Observable<number>;
  76903. private _onAfterRenderObserver;
  76904. /**
  76905. * Set a after render callback in the texture.
  76906. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  76907. */
  76908. onAfterRender: (faceIndex: number) => void;
  76909. /**
  76910. * An event triggered after the texture clear
  76911. */
  76912. onClearObservable: Observable<Engine>;
  76913. private _onClearObserver;
  76914. /**
  76915. * Set a clear callback in the texture.
  76916. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  76917. */
  76918. onClear: (Engine: Engine) => void;
  76919. /**
  76920. * Define the clear color of the Render Target if it should be different from the scene.
  76921. */
  76922. clearColor: Color4;
  76923. protected _size: number | {
  76924. width: number;
  76925. height: number;
  76926. };
  76927. protected _initialSizeParameter: number | {
  76928. width: number;
  76929. height: number;
  76930. } | {
  76931. ratio: number;
  76932. };
  76933. protected _sizeRatio: Nullable<number>;
  76934. /** @hidden */
  76935. _generateMipMaps: boolean;
  76936. protected _renderingManager: RenderingManager;
  76937. /** @hidden */
  76938. _waitingRenderList: string[];
  76939. protected _doNotChangeAspectRatio: boolean;
  76940. protected _currentRefreshId: number;
  76941. protected _refreshRate: number;
  76942. protected _textureMatrix: Matrix;
  76943. protected _samples: number;
  76944. protected _renderTargetOptions: RenderTargetCreationOptions;
  76945. /**
  76946. * Gets render target creation options that were used.
  76947. */
  76948. readonly renderTargetOptions: RenderTargetCreationOptions;
  76949. protected _engine: Engine;
  76950. protected _onRatioRescale(): void;
  76951. /**
  76952. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  76953. * It must define where the camera used to render the texture is set
  76954. */
  76955. boundingBoxPosition: Vector3;
  76956. private _boundingBoxSize;
  76957. /**
  76958. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  76959. * When defined, the cubemap will switch to local mode
  76960. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  76961. * @example https://www.babylonjs-playground.com/#RNASML
  76962. */
  76963. boundingBoxSize: Vector3;
  76964. /**
  76965. * In case the RTT has been created with a depth texture, get the associated
  76966. * depth texture.
  76967. * Otherwise, return null.
  76968. */
  76969. depthStencilTexture: Nullable<InternalTexture>;
  76970. /**
  76971. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  76972. * or used a shadow, depth texture...
  76973. * @param name The friendly name of the texture
  76974. * @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)
  76975. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  76976. * @param generateMipMaps True if mip maps need to be generated after render.
  76977. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  76978. * @param type The type of the buffer in the RTT (int, half float, float...)
  76979. * @param isCube True if a cube texture needs to be created
  76980. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  76981. * @param generateDepthBuffer True to generate a depth buffer
  76982. * @param generateStencilBuffer True to generate a stencil buffer
  76983. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  76984. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  76985. * @param delayAllocation if the texture allocation should be delayed (default: false)
  76986. */
  76987. constructor(name: string, size: number | {
  76988. width: number;
  76989. height: number;
  76990. } | {
  76991. ratio: number;
  76992. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  76993. /**
  76994. * Creates a depth stencil texture.
  76995. * This is only available in WebGL 2 or with the depth texture extension available.
  76996. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  76997. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  76998. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  76999. */
  77000. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  77001. private _processSizeParameter;
  77002. /**
  77003. * Define the number of samples to use in case of MSAA.
  77004. * It defaults to one meaning no MSAA has been enabled.
  77005. */
  77006. samples: number;
  77007. /**
  77008. * Resets the refresh counter of the texture and start bak from scratch.
  77009. * Could be useful to regenerate the texture if it is setup to render only once.
  77010. */
  77011. resetRefreshCounter(): void;
  77012. /**
  77013. * Define the refresh rate of the texture or the rendering frequency.
  77014. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  77015. */
  77016. refreshRate: number;
  77017. /**
  77018. * Adds a post process to the render target rendering passes.
  77019. * @param postProcess define the post process to add
  77020. */
  77021. addPostProcess(postProcess: PostProcess): void;
  77022. /**
  77023. * Clear all the post processes attached to the render target
  77024. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  77025. */
  77026. clearPostProcesses(dispose?: boolean): void;
  77027. /**
  77028. * Remove one of the post process from the list of attached post processes to the texture
  77029. * @param postProcess define the post process to remove from the list
  77030. */
  77031. removePostProcess(postProcess: PostProcess): void;
  77032. /** @hidden */
  77033. _shouldRender(): boolean;
  77034. /**
  77035. * Gets the actual render size of the texture.
  77036. * @returns the width of the render size
  77037. */
  77038. getRenderSize(): number;
  77039. /**
  77040. * Gets the actual render width of the texture.
  77041. * @returns the width of the render size
  77042. */
  77043. getRenderWidth(): number;
  77044. /**
  77045. * Gets the actual render height of the texture.
  77046. * @returns the height of the render size
  77047. */
  77048. getRenderHeight(): number;
  77049. /**
  77050. * Get if the texture can be rescaled or not.
  77051. */
  77052. readonly canRescale: boolean;
  77053. /**
  77054. * Resize the texture using a ratio.
  77055. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  77056. */
  77057. scale(ratio: number): void;
  77058. /**
  77059. * Get the texture reflection matrix used to rotate/transform the reflection.
  77060. * @returns the reflection matrix
  77061. */
  77062. getReflectionTextureMatrix(): Matrix;
  77063. /**
  77064. * Resize the texture to a new desired size.
  77065. * Be carrefull as it will recreate all the data in the new texture.
  77066. * @param size Define the new size. It can be:
  77067. * - a number for squared texture,
  77068. * - an object containing { width: number, height: number }
  77069. * - or an object containing a ratio { ratio: number }
  77070. */
  77071. resize(size: number | {
  77072. width: number;
  77073. height: number;
  77074. } | {
  77075. ratio: number;
  77076. }): void;
  77077. /**
  77078. * Renders all the objects from the render list into the texture.
  77079. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  77080. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  77081. */
  77082. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  77083. private _bestReflectionRenderTargetDimension;
  77084. /**
  77085. * @hidden
  77086. * @param faceIndex face index to bind to if this is a cubetexture
  77087. */
  77088. _bindFrameBuffer(faceIndex?: number): void;
  77089. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  77090. private renderToTarget;
  77091. /**
  77092. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  77093. * This allowed control for front to back rendering or reversly depending of the special needs.
  77094. *
  77095. * @param renderingGroupId The rendering group id corresponding to its index
  77096. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  77097. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  77098. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  77099. */
  77100. 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;
  77101. /**
  77102. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  77103. *
  77104. * @param renderingGroupId The rendering group id corresponding to its index
  77105. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  77106. */
  77107. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  77108. /**
  77109. * Clones the texture.
  77110. * @returns the cloned texture
  77111. */
  77112. clone(): RenderTargetTexture;
  77113. /**
  77114. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  77115. * @returns The JSON representation of the texture
  77116. */
  77117. serialize(): any;
  77118. /**
  77119. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  77120. */
  77121. disposeFramebufferObjects(): void;
  77122. /**
  77123. * Dispose the texture and release its associated resources.
  77124. */
  77125. dispose(): void;
  77126. /** @hidden */
  77127. _rebuild(): void;
  77128. /**
  77129. * Clear the info related to rendering groups preventing retention point in material dispose.
  77130. */
  77131. freeRenderingGroups(): void;
  77132. /**
  77133. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  77134. * @returns the view count
  77135. */
  77136. getViewCount(): number;
  77137. }
  77138. }
  77139. declare module BABYLON {
  77140. /**
  77141. * Mirror texture can be used to simulate the view from a mirror in a scene.
  77142. * It will dynamically be rendered every frame to adapt to the camera point of view.
  77143. * You can then easily use it as a reflectionTexture on a flat surface.
  77144. * In case the surface is not a plane, please consider relying on reflection probes.
  77145. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  77146. */
  77147. export class MirrorTexture extends RenderTargetTexture {
  77148. private scene;
  77149. /**
  77150. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  77151. * 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.
  77152. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  77153. */
  77154. mirrorPlane: Plane;
  77155. /**
  77156. * Define the blur ratio used to blur the reflection if needed.
  77157. */
  77158. blurRatio: number;
  77159. /**
  77160. * Define the adaptive blur kernel used to blur the reflection if needed.
  77161. * This will autocompute the closest best match for the `blurKernel`
  77162. */
  77163. adaptiveBlurKernel: number;
  77164. /**
  77165. * Define the blur kernel used to blur the reflection if needed.
  77166. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  77167. */
  77168. blurKernel: number;
  77169. /**
  77170. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  77171. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  77172. */
  77173. blurKernelX: number;
  77174. /**
  77175. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  77176. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  77177. */
  77178. blurKernelY: number;
  77179. private _autoComputeBlurKernel;
  77180. protected _onRatioRescale(): void;
  77181. private _updateGammaSpace;
  77182. private _imageProcessingConfigChangeObserver;
  77183. private _transformMatrix;
  77184. private _mirrorMatrix;
  77185. private _savedViewMatrix;
  77186. private _blurX;
  77187. private _blurY;
  77188. private _adaptiveBlurKernel;
  77189. private _blurKernelX;
  77190. private _blurKernelY;
  77191. private _blurRatio;
  77192. /**
  77193. * Instantiates a Mirror Texture.
  77194. * Mirror texture can be used to simulate the view from a mirror in a scene.
  77195. * It will dynamically be rendered every frame to adapt to the camera point of view.
  77196. * You can then easily use it as a reflectionTexture on a flat surface.
  77197. * In case the surface is not a plane, please consider relying on reflection probes.
  77198. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  77199. * @param name
  77200. * @param size
  77201. * @param scene
  77202. * @param generateMipMaps
  77203. * @param type
  77204. * @param samplingMode
  77205. * @param generateDepthBuffer
  77206. */
  77207. constructor(name: string, size: number | {
  77208. width: number;
  77209. height: number;
  77210. } | {
  77211. ratio: number;
  77212. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  77213. private _preparePostProcesses;
  77214. /**
  77215. * Clone the mirror texture.
  77216. * @returns the cloned texture
  77217. */
  77218. clone(): MirrorTexture;
  77219. /**
  77220. * Serialize the texture to a JSON representation you could use in Parse later on
  77221. * @returns the serialized JSON representation
  77222. */
  77223. serialize(): any;
  77224. /**
  77225. * Dispose the texture and release its associated resources.
  77226. */
  77227. dispose(): void;
  77228. }
  77229. }
  77230. declare module BABYLON {
  77231. /**
  77232. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  77233. * @see http://doc.babylonjs.com/babylon101/materials#texture
  77234. */
  77235. export class Texture extends BaseTexture {
  77236. /** @hidden */
  77237. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  77238. /** @hidden */
  77239. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  77240. /** @hidden */
  77241. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  77242. /** nearest is mag = nearest and min = nearest and mip = linear */
  77243. static readonly NEAREST_SAMPLINGMODE: number;
  77244. /** nearest is mag = nearest and min = nearest and mip = linear */
  77245. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  77246. /** Bilinear is mag = linear and min = linear and mip = nearest */
  77247. static readonly BILINEAR_SAMPLINGMODE: number;
  77248. /** Bilinear is mag = linear and min = linear and mip = nearest */
  77249. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  77250. /** Trilinear is mag = linear and min = linear and mip = linear */
  77251. static readonly TRILINEAR_SAMPLINGMODE: number;
  77252. /** Trilinear is mag = linear and min = linear and mip = linear */
  77253. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  77254. /** mag = nearest and min = nearest and mip = nearest */
  77255. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  77256. /** mag = nearest and min = linear and mip = nearest */
  77257. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  77258. /** mag = nearest and min = linear and mip = linear */
  77259. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  77260. /** mag = nearest and min = linear and mip = none */
  77261. static readonly NEAREST_LINEAR: number;
  77262. /** mag = nearest and min = nearest and mip = none */
  77263. static readonly NEAREST_NEAREST: number;
  77264. /** mag = linear and min = nearest and mip = nearest */
  77265. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  77266. /** mag = linear and min = nearest and mip = linear */
  77267. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  77268. /** mag = linear and min = linear and mip = none */
  77269. static readonly LINEAR_LINEAR: number;
  77270. /** mag = linear and min = nearest and mip = none */
  77271. static readonly LINEAR_NEAREST: number;
  77272. /** Explicit coordinates mode */
  77273. static readonly EXPLICIT_MODE: number;
  77274. /** Spherical coordinates mode */
  77275. static readonly SPHERICAL_MODE: number;
  77276. /** Planar coordinates mode */
  77277. static readonly PLANAR_MODE: number;
  77278. /** Cubic coordinates mode */
  77279. static readonly CUBIC_MODE: number;
  77280. /** Projection coordinates mode */
  77281. static readonly PROJECTION_MODE: number;
  77282. /** Inverse Cubic coordinates mode */
  77283. static readonly SKYBOX_MODE: number;
  77284. /** Inverse Cubic coordinates mode */
  77285. static readonly INVCUBIC_MODE: number;
  77286. /** Equirectangular coordinates mode */
  77287. static readonly EQUIRECTANGULAR_MODE: number;
  77288. /** Equirectangular Fixed coordinates mode */
  77289. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  77290. /** Equirectangular Fixed Mirrored coordinates mode */
  77291. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  77292. /** Texture is not repeating outside of 0..1 UVs */
  77293. static readonly CLAMP_ADDRESSMODE: number;
  77294. /** Texture is repeating outside of 0..1 UVs */
  77295. static readonly WRAP_ADDRESSMODE: number;
  77296. /** Texture is repeating and mirrored */
  77297. static readonly MIRROR_ADDRESSMODE: number;
  77298. /**
  77299. * 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
  77300. */
  77301. static UseSerializedUrlIfAny: boolean;
  77302. /**
  77303. * Define the url of the texture.
  77304. */
  77305. url: Nullable<string>;
  77306. /**
  77307. * Define an offset on the texture to offset the u coordinates of the UVs
  77308. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  77309. */
  77310. uOffset: number;
  77311. /**
  77312. * Define an offset on the texture to offset the v coordinates of the UVs
  77313. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  77314. */
  77315. vOffset: number;
  77316. /**
  77317. * Define an offset on the texture to scale the u coordinates of the UVs
  77318. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  77319. */
  77320. uScale: number;
  77321. /**
  77322. * Define an offset on the texture to scale the v coordinates of the UVs
  77323. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  77324. */
  77325. vScale: number;
  77326. /**
  77327. * Define an offset on the texture to rotate around the u coordinates of the UVs
  77328. * @see http://doc.babylonjs.com/how_to/more_materials
  77329. */
  77330. uAng: number;
  77331. /**
  77332. * Define an offset on the texture to rotate around the v coordinates of the UVs
  77333. * @see http://doc.babylonjs.com/how_to/more_materials
  77334. */
  77335. vAng: number;
  77336. /**
  77337. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  77338. * @see http://doc.babylonjs.com/how_to/more_materials
  77339. */
  77340. wAng: number;
  77341. /**
  77342. * Defines the center of rotation (U)
  77343. */
  77344. uRotationCenter: number;
  77345. /**
  77346. * Defines the center of rotation (V)
  77347. */
  77348. vRotationCenter: number;
  77349. /**
  77350. * Defines the center of rotation (W)
  77351. */
  77352. wRotationCenter: number;
  77353. /**
  77354. * Are mip maps generated for this texture or not.
  77355. */
  77356. readonly noMipmap: boolean;
  77357. /**
  77358. * List of inspectable custom properties (used by the Inspector)
  77359. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  77360. */
  77361. inspectableCustomProperties: IInspectable[];
  77362. private _noMipmap;
  77363. /** @hidden */
  77364. _invertY: boolean;
  77365. private _rowGenerationMatrix;
  77366. private _cachedTextureMatrix;
  77367. private _projectionModeMatrix;
  77368. private _t0;
  77369. private _t1;
  77370. private _t2;
  77371. private _cachedUOffset;
  77372. private _cachedVOffset;
  77373. private _cachedUScale;
  77374. private _cachedVScale;
  77375. private _cachedUAng;
  77376. private _cachedVAng;
  77377. private _cachedWAng;
  77378. private _cachedProjectionMatrixId;
  77379. private _cachedCoordinatesMode;
  77380. /** @hidden */
  77381. protected _initialSamplingMode: number;
  77382. /** @hidden */
  77383. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  77384. private _deleteBuffer;
  77385. protected _format: Nullable<number>;
  77386. private _delayedOnLoad;
  77387. private _delayedOnError;
  77388. /**
  77389. * Observable triggered once the texture has been loaded.
  77390. */
  77391. onLoadObservable: Observable<Texture>;
  77392. protected _isBlocking: boolean;
  77393. /**
  77394. * Is the texture preventing material to render while loading.
  77395. * If false, a default texture will be used instead of the loading one during the preparation step.
  77396. */
  77397. isBlocking: boolean;
  77398. /**
  77399. * Get the current sampling mode associated with the texture.
  77400. */
  77401. readonly samplingMode: number;
  77402. /**
  77403. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  77404. */
  77405. readonly invertY: boolean;
  77406. /**
  77407. * Instantiates a new texture.
  77408. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  77409. * @see http://doc.babylonjs.com/babylon101/materials#texture
  77410. * @param url define the url of the picture to load as a texture
  77411. * @param scene define the scene the texture will belong to
  77412. * @param noMipmap define if the texture will require mip maps or not
  77413. * @param invertY define if the texture needs to be inverted on the y axis during loading
  77414. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  77415. * @param onLoad define a callback triggered when the texture has been loaded
  77416. * @param onError define a callback triggered when an error occurred during the loading session
  77417. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  77418. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  77419. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  77420. */
  77421. 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);
  77422. /**
  77423. * Update the url (and optional buffer) of this texture if url was null during construction.
  77424. * @param url the url of the texture
  77425. * @param buffer the buffer of the texture (defaults to null)
  77426. * @param onLoad callback called when the texture is loaded (defaults to null)
  77427. */
  77428. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  77429. /**
  77430. * Finish the loading sequence of a texture flagged as delayed load.
  77431. * @hidden
  77432. */
  77433. delayLoad(): void;
  77434. private _prepareRowForTextureGeneration;
  77435. /**
  77436. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  77437. * @returns the transform matrix of the texture.
  77438. */
  77439. getTextureMatrix(): Matrix;
  77440. /**
  77441. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  77442. * @returns The reflection texture transform
  77443. */
  77444. getReflectionTextureMatrix(): Matrix;
  77445. /**
  77446. * Clones the texture.
  77447. * @returns the cloned texture
  77448. */
  77449. clone(): Texture;
  77450. /**
  77451. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  77452. * @returns The JSON representation of the texture
  77453. */
  77454. serialize(): any;
  77455. /**
  77456. * Get the current class name of the texture useful for serialization or dynamic coding.
  77457. * @returns "Texture"
  77458. */
  77459. getClassName(): string;
  77460. /**
  77461. * Dispose the texture and release its associated resources.
  77462. */
  77463. dispose(): void;
  77464. /**
  77465. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  77466. * @param parsedTexture Define the JSON representation of the texture
  77467. * @param scene Define the scene the parsed texture should be instantiated in
  77468. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  77469. * @returns The parsed texture if successful
  77470. */
  77471. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  77472. /**
  77473. * Creates a texture from its base 64 representation.
  77474. * @param data Define the base64 payload without the data: prefix
  77475. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  77476. * @param scene Define the scene the texture should belong to
  77477. * @param noMipmap Forces the texture to not create mip map information if true
  77478. * @param invertY define if the texture needs to be inverted on the y axis during loading
  77479. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  77480. * @param onLoad define a callback triggered when the texture has been loaded
  77481. * @param onError define a callback triggered when an error occurred during the loading session
  77482. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  77483. * @returns the created texture
  77484. */
  77485. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  77486. /**
  77487. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  77488. * @param data Define the base64 payload without the data: prefix
  77489. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  77490. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  77491. * @param scene Define the scene the texture should belong to
  77492. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  77493. * @param noMipmap Forces the texture to not create mip map information if true
  77494. * @param invertY define if the texture needs to be inverted on the y axis during loading
  77495. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  77496. * @param onLoad define a callback triggered when the texture has been loaded
  77497. * @param onError define a callback triggered when an error occurred during the loading session
  77498. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  77499. * @returns the created texture
  77500. */
  77501. 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;
  77502. }
  77503. }
  77504. declare module BABYLON {
  77505. /**
  77506. * Raw texture can help creating a texture directly from an array of data.
  77507. * This can be super useful if you either get the data from an uncompressed source or
  77508. * if you wish to create your texture pixel by pixel.
  77509. */
  77510. export class RawTexture extends Texture {
  77511. /**
  77512. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  77513. */
  77514. format: number;
  77515. private _engine;
  77516. /**
  77517. * Instantiates a new RawTexture.
  77518. * Raw texture can help creating a texture directly from an array of data.
  77519. * This can be super useful if you either get the data from an uncompressed source or
  77520. * if you wish to create your texture pixel by pixel.
  77521. * @param data define the array of data to use to create the texture
  77522. * @param width define the width of the texture
  77523. * @param height define the height of the texture
  77524. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  77525. * @param scene define the scene the texture belongs to
  77526. * @param generateMipMaps define whether mip maps should be generated or not
  77527. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  77528. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  77529. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  77530. */
  77531. constructor(data: ArrayBufferView, width: number, height: number,
  77532. /**
  77533. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  77534. */
  77535. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  77536. /**
  77537. * Updates the texture underlying data.
  77538. * @param data Define the new data of the texture
  77539. */
  77540. update(data: ArrayBufferView): void;
  77541. /**
  77542. * Creates a luminance texture from some data.
  77543. * @param data Define the texture data
  77544. * @param width Define the width of the texture
  77545. * @param height Define the height of the texture
  77546. * @param scene Define the scene the texture belongs to
  77547. * @param generateMipMaps Define whether or not to create mip maps for the texture
  77548. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  77549. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  77550. * @returns the luminance texture
  77551. */
  77552. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  77553. /**
  77554. * Creates a luminance alpha texture from some data.
  77555. * @param data Define the texture data
  77556. * @param width Define the width of the texture
  77557. * @param height Define the height of the texture
  77558. * @param scene Define the scene the texture belongs to
  77559. * @param generateMipMaps Define whether or not to create mip maps for the texture
  77560. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  77561. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  77562. * @returns the luminance alpha texture
  77563. */
  77564. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  77565. /**
  77566. * Creates an alpha texture from some data.
  77567. * @param data Define the texture data
  77568. * @param width Define the width of the texture
  77569. * @param height Define the height of the texture
  77570. * @param scene Define the scene the texture belongs to
  77571. * @param generateMipMaps Define whether or not to create mip maps for the texture
  77572. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  77573. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  77574. * @returns the alpha texture
  77575. */
  77576. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  77577. /**
  77578. * Creates a RGB texture from some data.
  77579. * @param data Define the texture data
  77580. * @param width Define the width of the texture
  77581. * @param height Define the height of the texture
  77582. * @param scene Define the scene the texture belongs to
  77583. * @param generateMipMaps Define whether or not to create mip maps for the texture
  77584. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  77585. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  77586. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  77587. * @returns the RGB alpha texture
  77588. */
  77589. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  77590. /**
  77591. * Creates a RGBA texture from some data.
  77592. * @param data Define the texture data
  77593. * @param width Define the width of the texture
  77594. * @param height Define the height of the texture
  77595. * @param scene Define the scene the texture belongs to
  77596. * @param generateMipMaps Define whether or not to create mip maps for the texture
  77597. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  77598. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  77599. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  77600. * @returns the RGBA texture
  77601. */
  77602. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  77603. /**
  77604. * Creates a R texture from some data.
  77605. * @param data Define the texture data
  77606. * @param width Define the width of the texture
  77607. * @param height Define the height of the texture
  77608. * @param scene Define the scene the texture belongs to
  77609. * @param generateMipMaps Define whether or not to create mip maps for the texture
  77610. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  77611. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  77612. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  77613. * @returns the R texture
  77614. */
  77615. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  77616. }
  77617. }
  77618. declare module BABYLON {
  77619. /**
  77620. * Defines a runtime animation
  77621. */
  77622. export class RuntimeAnimation {
  77623. private _events;
  77624. /**
  77625. * The current frame of the runtime animation
  77626. */
  77627. private _currentFrame;
  77628. /**
  77629. * The animation used by the runtime animation
  77630. */
  77631. private _animation;
  77632. /**
  77633. * The target of the runtime animation
  77634. */
  77635. private _target;
  77636. /**
  77637. * The initiating animatable
  77638. */
  77639. private _host;
  77640. /**
  77641. * The original value of the runtime animation
  77642. */
  77643. private _originalValue;
  77644. /**
  77645. * The original blend value of the runtime animation
  77646. */
  77647. private _originalBlendValue;
  77648. /**
  77649. * The offsets cache of the runtime animation
  77650. */
  77651. private _offsetsCache;
  77652. /**
  77653. * The high limits cache of the runtime animation
  77654. */
  77655. private _highLimitsCache;
  77656. /**
  77657. * Specifies if the runtime animation has been stopped
  77658. */
  77659. private _stopped;
  77660. /**
  77661. * The blending factor of the runtime animation
  77662. */
  77663. private _blendingFactor;
  77664. /**
  77665. * The BabylonJS scene
  77666. */
  77667. private _scene;
  77668. /**
  77669. * The current value of the runtime animation
  77670. */
  77671. private _currentValue;
  77672. /** @hidden */
  77673. _workValue: any;
  77674. /**
  77675. * The active target of the runtime animation
  77676. */
  77677. private _activeTarget;
  77678. /**
  77679. * The target path of the runtime animation
  77680. */
  77681. private _targetPath;
  77682. /**
  77683. * The weight of the runtime animation
  77684. */
  77685. private _weight;
  77686. /**
  77687. * The ratio offset of the runtime animation
  77688. */
  77689. private _ratioOffset;
  77690. /**
  77691. * The previous delay of the runtime animation
  77692. */
  77693. private _previousDelay;
  77694. /**
  77695. * The previous ratio of the runtime animation
  77696. */
  77697. private _previousRatio;
  77698. private _enableBlending;
  77699. private _correctLoopMode;
  77700. /**
  77701. * Gets the current frame of the runtime animation
  77702. */
  77703. readonly currentFrame: number;
  77704. /**
  77705. * Gets the weight of the runtime animation
  77706. */
  77707. readonly weight: number;
  77708. /**
  77709. * Gets the current value of the runtime animation
  77710. */
  77711. readonly currentValue: any;
  77712. /**
  77713. * Gets the target path of the runtime animation
  77714. */
  77715. readonly targetPath: string;
  77716. /**
  77717. * Gets the actual target of the runtime animation
  77718. */
  77719. readonly target: any;
  77720. /**
  77721. * Create a new RuntimeAnimation object
  77722. * @param target defines the target of the animation
  77723. * @param animation defines the source animation object
  77724. * @param scene defines the hosting scene
  77725. * @param host defines the initiating Animatable
  77726. */
  77727. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  77728. /**
  77729. * Gets the animation from the runtime animation
  77730. */
  77731. readonly animation: Animation;
  77732. /**
  77733. * Resets the runtime animation to the beginning
  77734. * @param restoreOriginal defines whether to restore the target property to the original value
  77735. */
  77736. reset(restoreOriginal?: boolean): void;
  77737. /**
  77738. * Specifies if the runtime animation is stopped
  77739. * @returns Boolean specifying if the runtime animation is stopped
  77740. */
  77741. isStopped(): boolean;
  77742. /**
  77743. * Disposes of the runtime animation
  77744. */
  77745. dispose(): void;
  77746. /**
  77747. * Interpolates the animation from the current frame
  77748. * @param currentFrame The frame to interpolate the animation to
  77749. * @param repeatCount The number of times that the animation should loop
  77750. * @param loopMode The type of looping mode to use
  77751. * @param offsetValue Animation offset value
  77752. * @param highLimitValue The high limit value
  77753. * @returns The interpolated value
  77754. */
  77755. private _interpolate;
  77756. /**
  77757. * Apply the interpolated value to the target
  77758. * @param currentValue defines the value computed by the animation
  77759. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  77760. */
  77761. setValue(currentValue: any, weight?: number): void;
  77762. private _setValue;
  77763. /**
  77764. * Gets the loop pmode of the runtime animation
  77765. * @returns Loop Mode
  77766. */
  77767. private _getCorrectLoopMode;
  77768. /**
  77769. * Move the current animation to a given frame
  77770. * @param frame defines the frame to move to
  77771. */
  77772. goToFrame(frame: number): void;
  77773. /**
  77774. * @hidden Internal use only
  77775. */
  77776. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  77777. /**
  77778. * Execute the current animation
  77779. * @param delay defines the delay to add to the current frame
  77780. * @param from defines the lower bound of the animation range
  77781. * @param to defines the upper bound of the animation range
  77782. * @param loop defines if the current animation must loop
  77783. * @param speedRatio defines the current speed ratio
  77784. * @param weight defines the weight of the animation (default is -1 so no weight)
  77785. * @param onLoop optional callback called when animation loops
  77786. * @returns a boolean indicating if the animation is running
  77787. */
  77788. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number, onLoop?: () => void): boolean;
  77789. }
  77790. }
  77791. declare module BABYLON {
  77792. /**
  77793. * Class used to store an actual running animation
  77794. */
  77795. export class Animatable {
  77796. /** defines the target object */
  77797. target: any;
  77798. /** defines the starting frame number (default is 0) */
  77799. fromFrame: number;
  77800. /** defines the ending frame number (default is 100) */
  77801. toFrame: number;
  77802. /** defines if the animation must loop (default is false) */
  77803. loopAnimation: boolean;
  77804. /** defines a callback to call when animation ends if it is not looping */
  77805. onAnimationEnd?: (() => void) | null | undefined;
  77806. /** defines a callback to call when animation loops */
  77807. onAnimationLoop?: (() => void) | null | undefined;
  77808. private _localDelayOffset;
  77809. private _pausedDelay;
  77810. private _runtimeAnimations;
  77811. private _paused;
  77812. private _scene;
  77813. private _speedRatio;
  77814. private _weight;
  77815. private _syncRoot;
  77816. /**
  77817. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  77818. * This will only apply for non looping animation (default is true)
  77819. */
  77820. disposeOnEnd: boolean;
  77821. /**
  77822. * Gets a boolean indicating if the animation has started
  77823. */
  77824. animationStarted: boolean;
  77825. /**
  77826. * Observer raised when the animation ends
  77827. */
  77828. onAnimationEndObservable: Observable<Animatable>;
  77829. /**
  77830. * Observer raised when the animation loops
  77831. */
  77832. onAnimationLoopObservable: Observable<Animatable>;
  77833. /**
  77834. * Gets the root Animatable used to synchronize and normalize animations
  77835. */
  77836. readonly syncRoot: Animatable;
  77837. /**
  77838. * Gets the current frame of the first RuntimeAnimation
  77839. * Used to synchronize Animatables
  77840. */
  77841. readonly masterFrame: number;
  77842. /**
  77843. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  77844. */
  77845. weight: number;
  77846. /**
  77847. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  77848. */
  77849. speedRatio: number;
  77850. /**
  77851. * Creates a new Animatable
  77852. * @param scene defines the hosting scene
  77853. * @param target defines the target object
  77854. * @param fromFrame defines the starting frame number (default is 0)
  77855. * @param toFrame defines the ending frame number (default is 100)
  77856. * @param loopAnimation defines if the animation must loop (default is false)
  77857. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  77858. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  77859. * @param animations defines a group of animation to add to the new Animatable
  77860. * @param onAnimationLoop defines a callback to call when animation loops
  77861. */
  77862. constructor(scene: Scene,
  77863. /** defines the target object */
  77864. target: any,
  77865. /** defines the starting frame number (default is 0) */
  77866. fromFrame?: number,
  77867. /** defines the ending frame number (default is 100) */
  77868. toFrame?: number,
  77869. /** defines if the animation must loop (default is false) */
  77870. loopAnimation?: boolean, speedRatio?: number,
  77871. /** defines a callback to call when animation ends if it is not looping */
  77872. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  77873. /** defines a callback to call when animation loops */
  77874. onAnimationLoop?: (() => void) | null | undefined);
  77875. /**
  77876. * Synchronize and normalize current Animatable with a source Animatable
  77877. * This is useful when using animation weights and when animations are not of the same length
  77878. * @param root defines the root Animatable to synchronize with
  77879. * @returns the current Animatable
  77880. */
  77881. syncWith(root: Animatable): Animatable;
  77882. /**
  77883. * Gets the list of runtime animations
  77884. * @returns an array of RuntimeAnimation
  77885. */
  77886. getAnimations(): RuntimeAnimation[];
  77887. /**
  77888. * Adds more animations to the current animatable
  77889. * @param target defines the target of the animations
  77890. * @param animations defines the new animations to add
  77891. */
  77892. appendAnimations(target: any, animations: Animation[]): void;
  77893. /**
  77894. * Gets the source animation for a specific property
  77895. * @param property defines the propertyu to look for
  77896. * @returns null or the source animation for the given property
  77897. */
  77898. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  77899. /**
  77900. * Gets the runtime animation for a specific property
  77901. * @param property defines the propertyu to look for
  77902. * @returns null or the runtime animation for the given property
  77903. */
  77904. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  77905. /**
  77906. * Resets the animatable to its original state
  77907. */
  77908. reset(): void;
  77909. /**
  77910. * Allows the animatable to blend with current running animations
  77911. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  77912. * @param blendingSpeed defines the blending speed to use
  77913. */
  77914. enableBlending(blendingSpeed: number): void;
  77915. /**
  77916. * Disable animation blending
  77917. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  77918. */
  77919. disableBlending(): void;
  77920. /**
  77921. * Jump directly to a given frame
  77922. * @param frame defines the frame to jump to
  77923. */
  77924. goToFrame(frame: number): void;
  77925. /**
  77926. * Pause the animation
  77927. */
  77928. pause(): void;
  77929. /**
  77930. * Restart the animation
  77931. */
  77932. restart(): void;
  77933. private _raiseOnAnimationEnd;
  77934. /**
  77935. * Stop and delete the current animation
  77936. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  77937. * @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)
  77938. */
  77939. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  77940. /**
  77941. * Wait asynchronously for the animation to end
  77942. * @returns a promise which will be fullfilled when the animation ends
  77943. */
  77944. waitAsync(): Promise<Animatable>;
  77945. /** @hidden */
  77946. _animate(delay: number): boolean;
  77947. }
  77948. interface Scene {
  77949. /** @hidden */
  77950. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  77951. /** @hidden */
  77952. _processLateAnimationBindingsForMatrices(holder: {
  77953. totalWeight: number;
  77954. animations: RuntimeAnimation[];
  77955. originalValue: Matrix;
  77956. }): any;
  77957. /** @hidden */
  77958. _processLateAnimationBindingsForQuaternions(holder: {
  77959. totalWeight: number;
  77960. animations: RuntimeAnimation[];
  77961. originalValue: Quaternion;
  77962. }, refQuaternion: Quaternion): Quaternion;
  77963. /** @hidden */
  77964. _processLateAnimationBindings(): void;
  77965. /**
  77966. * Will start the animation sequence of a given target
  77967. * @param target defines the target
  77968. * @param from defines from which frame should animation start
  77969. * @param to defines until which frame should animation run.
  77970. * @param weight defines the weight to apply to the animation (1.0 by default)
  77971. * @param loop defines if the animation loops
  77972. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  77973. * @param onAnimationEnd defines the function to be executed when the animation ends
  77974. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  77975. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  77976. * @param onAnimationLoop defines the callback to call when an animation loops
  77977. * @returns the animatable object created for this animation
  77978. */
  77979. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  77980. /**
  77981. * Will start the animation sequence of a given target
  77982. * @param target defines the target
  77983. * @param from defines from which frame should animation start
  77984. * @param to defines until which frame should animation run.
  77985. * @param loop defines if the animation loops
  77986. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  77987. * @param onAnimationEnd defines the function to be executed when the animation ends
  77988. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  77989. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  77990. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  77991. * @param onAnimationLoop defines the callback to call when an animation loops
  77992. * @returns the animatable object created for this animation
  77993. */
  77994. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  77995. /**
  77996. * Will start the animation sequence of a given target and its hierarchy
  77997. * @param target defines the target
  77998. * @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.
  77999. * @param from defines from which frame should animation start
  78000. * @param to defines until which frame should animation run.
  78001. * @param loop defines if the animation loops
  78002. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  78003. * @param onAnimationEnd defines the function to be executed when the animation ends
  78004. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  78005. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  78006. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  78007. * @param onAnimationLoop defines the callback to call when an animation loops
  78008. * @returns the list of created animatables
  78009. */
  78010. 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[];
  78011. /**
  78012. * Begin a new animation on a given node
  78013. * @param target defines the target where the animation will take place
  78014. * @param animations defines the list of animations to start
  78015. * @param from defines the initial value
  78016. * @param to defines the final value
  78017. * @param loop defines if you want animation to loop (off by default)
  78018. * @param speedRatio defines the speed ratio to apply to all animations
  78019. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  78020. * @param onAnimationLoop defines the callback to call when an animation loops
  78021. * @returns the list of created animatables
  78022. */
  78023. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  78024. /**
  78025. * Begin a new animation on a given node and its hierarchy
  78026. * @param target defines the root node where the animation will take place
  78027. * @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.
  78028. * @param animations defines the list of animations to start
  78029. * @param from defines the initial value
  78030. * @param to defines the final value
  78031. * @param loop defines if you want animation to loop (off by default)
  78032. * @param speedRatio defines the speed ratio to apply to all animations
  78033. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  78034. * @param onAnimationLoop defines the callback to call when an animation loops
  78035. * @returns the list of animatables created for all nodes
  78036. */
  78037. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  78038. /**
  78039. * Gets the animatable associated with a specific target
  78040. * @param target defines the target of the animatable
  78041. * @returns the required animatable if found
  78042. */
  78043. getAnimatableByTarget(target: any): Nullable<Animatable>;
  78044. /**
  78045. * Gets all animatables associated with a given target
  78046. * @param target defines the target to look animatables for
  78047. * @returns an array of Animatables
  78048. */
  78049. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  78050. /**
  78051. * Will stop the animation of the given target
  78052. * @param target - the target
  78053. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  78054. * @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)
  78055. */
  78056. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  78057. /**
  78058. * Stops and removes all animations that have been applied to the scene
  78059. */
  78060. stopAllAnimations(): void;
  78061. }
  78062. interface Bone {
  78063. /**
  78064. * Copy an animation range from another bone
  78065. * @param source defines the source bone
  78066. * @param rangeName defines the range name to copy
  78067. * @param frameOffset defines the frame offset
  78068. * @param rescaleAsRequired defines if rescaling must be applied if required
  78069. * @param skelDimensionsRatio defines the scaling ratio
  78070. * @returns true if operation was successful
  78071. */
  78072. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  78073. }
  78074. }
  78075. declare module BABYLON {
  78076. /**
  78077. * Class used to handle skinning animations
  78078. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  78079. */
  78080. export class Skeleton implements IAnimatable {
  78081. /** defines the skeleton name */
  78082. name: string;
  78083. /** defines the skeleton Id */
  78084. id: string;
  78085. /**
  78086. * Defines the list of child bones
  78087. */
  78088. bones: Bone[];
  78089. /**
  78090. * Defines an estimate of the dimension of the skeleton at rest
  78091. */
  78092. dimensionsAtRest: Vector3;
  78093. /**
  78094. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  78095. */
  78096. needInitialSkinMatrix: boolean;
  78097. /**
  78098. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  78099. */
  78100. overrideMesh: Nullable<AbstractMesh>;
  78101. /**
  78102. * Gets the list of animations attached to this skeleton
  78103. */
  78104. animations: Array<Animation>;
  78105. private _scene;
  78106. private _isDirty;
  78107. private _transformMatrices;
  78108. private _transformMatrixTexture;
  78109. private _meshesWithPoseMatrix;
  78110. private _animatables;
  78111. private _identity;
  78112. private _synchronizedWithMesh;
  78113. private _ranges;
  78114. private _lastAbsoluteTransformsUpdateId;
  78115. private _canUseTextureForBones;
  78116. private _uniqueId;
  78117. /** @hidden */
  78118. _numBonesWithLinkedTransformNode: number;
  78119. /**
  78120. * Specifies if the skeleton should be serialized
  78121. */
  78122. doNotSerialize: boolean;
  78123. private _useTextureToStoreBoneMatrices;
  78124. /**
  78125. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  78126. * Please note that this option is not available when needInitialSkinMatrix === true or if the hardware does not support it
  78127. */
  78128. useTextureToStoreBoneMatrices: boolean;
  78129. private _animationPropertiesOverride;
  78130. /**
  78131. * Gets or sets the animation properties override
  78132. */
  78133. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  78134. /**
  78135. * List of inspectable custom properties (used by the Inspector)
  78136. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  78137. */
  78138. inspectableCustomProperties: IInspectable[];
  78139. /**
  78140. * An observable triggered before computing the skeleton's matrices
  78141. */
  78142. onBeforeComputeObservable: Observable<Skeleton>;
  78143. /**
  78144. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  78145. */
  78146. readonly isUsingTextureForMatrices: boolean;
  78147. /**
  78148. * Gets the unique ID of this skeleton
  78149. */
  78150. readonly uniqueId: number;
  78151. /**
  78152. * Creates a new skeleton
  78153. * @param name defines the skeleton name
  78154. * @param id defines the skeleton Id
  78155. * @param scene defines the hosting scene
  78156. */
  78157. constructor(
  78158. /** defines the skeleton name */
  78159. name: string,
  78160. /** defines the skeleton Id */
  78161. id: string, scene: Scene);
  78162. /**
  78163. * Gets the current object class name.
  78164. * @return the class name
  78165. */
  78166. getClassName(): string;
  78167. /**
  78168. * Returns an array containing the root bones
  78169. * @returns an array containing the root bones
  78170. */
  78171. getChildren(): Array<Bone>;
  78172. /**
  78173. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  78174. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  78175. * @returns a Float32Array containing matrices data
  78176. */
  78177. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  78178. /**
  78179. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  78180. * @returns a raw texture containing the data
  78181. */
  78182. getTransformMatrixTexture(): Nullable<RawTexture>;
  78183. /**
  78184. * Gets the current hosting scene
  78185. * @returns a scene object
  78186. */
  78187. getScene(): Scene;
  78188. /**
  78189. * Gets a string representing the current skeleton data
  78190. * @param fullDetails defines a boolean indicating if we want a verbose version
  78191. * @returns a string representing the current skeleton data
  78192. */
  78193. toString(fullDetails?: boolean): string;
  78194. /**
  78195. * Get bone's index searching by name
  78196. * @param name defines bone's name to search for
  78197. * @return the indice of the bone. Returns -1 if not found
  78198. */
  78199. getBoneIndexByName(name: string): number;
  78200. /**
  78201. * Creater a new animation range
  78202. * @param name defines the name of the range
  78203. * @param from defines the start key
  78204. * @param to defines the end key
  78205. */
  78206. createAnimationRange(name: string, from: number, to: number): void;
  78207. /**
  78208. * Delete a specific animation range
  78209. * @param name defines the name of the range
  78210. * @param deleteFrames defines if frames must be removed as well
  78211. */
  78212. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  78213. /**
  78214. * Gets a specific animation range
  78215. * @param name defines the name of the range to look for
  78216. * @returns the requested animation range or null if not found
  78217. */
  78218. getAnimationRange(name: string): Nullable<AnimationRange>;
  78219. /**
  78220. * Gets the list of all animation ranges defined on this skeleton
  78221. * @returns an array
  78222. */
  78223. getAnimationRanges(): Nullable<AnimationRange>[];
  78224. /**
  78225. * Copy animation range from a source skeleton.
  78226. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  78227. * @param source defines the source skeleton
  78228. * @param name defines the name of the range to copy
  78229. * @param rescaleAsRequired defines if rescaling must be applied if required
  78230. * @returns true if operation was successful
  78231. */
  78232. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  78233. /**
  78234. * Forces the skeleton to go to rest pose
  78235. */
  78236. returnToRest(): void;
  78237. private _getHighestAnimationFrame;
  78238. /**
  78239. * Begin a specific animation range
  78240. * @param name defines the name of the range to start
  78241. * @param loop defines if looping must be turned on (false by default)
  78242. * @param speedRatio defines the speed ratio to apply (1 by default)
  78243. * @param onAnimationEnd defines a callback which will be called when animation will end
  78244. * @returns a new animatable
  78245. */
  78246. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  78247. /** @hidden */
  78248. _markAsDirty(): void;
  78249. /** @hidden */
  78250. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  78251. /** @hidden */
  78252. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  78253. private _computeTransformMatrices;
  78254. /**
  78255. * Build all resources required to render a skeleton
  78256. */
  78257. prepare(): void;
  78258. /**
  78259. * Gets the list of animatables currently running for this skeleton
  78260. * @returns an array of animatables
  78261. */
  78262. getAnimatables(): IAnimatable[];
  78263. /**
  78264. * Clone the current skeleton
  78265. * @param name defines the name of the new skeleton
  78266. * @param id defines the id of the enw skeleton
  78267. * @returns the new skeleton
  78268. */
  78269. clone(name: string, id: string): Skeleton;
  78270. /**
  78271. * Enable animation blending for this skeleton
  78272. * @param blendingSpeed defines the blending speed to apply
  78273. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  78274. */
  78275. enableBlending(blendingSpeed?: number): void;
  78276. /**
  78277. * Releases all resources associated with the current skeleton
  78278. */
  78279. dispose(): void;
  78280. /**
  78281. * Serialize the skeleton in a JSON object
  78282. * @returns a JSON object
  78283. */
  78284. serialize(): any;
  78285. /**
  78286. * Creates a new skeleton from serialized data
  78287. * @param parsedSkeleton defines the serialized data
  78288. * @param scene defines the hosting scene
  78289. * @returns a new skeleton
  78290. */
  78291. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  78292. /**
  78293. * Compute all node absolute transforms
  78294. * @param forceUpdate defines if computation must be done even if cache is up to date
  78295. */
  78296. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  78297. /**
  78298. * Gets the root pose matrix
  78299. * @returns a matrix
  78300. */
  78301. getPoseMatrix(): Nullable<Matrix>;
  78302. /**
  78303. * Sorts bones per internal index
  78304. */
  78305. sortBones(): void;
  78306. private _sortBones;
  78307. }
  78308. }
  78309. declare module BABYLON {
  78310. /**
  78311. * Defines a target to use with MorphTargetManager
  78312. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  78313. */
  78314. export class MorphTarget implements IAnimatable {
  78315. /** defines the name of the target */
  78316. name: string;
  78317. /**
  78318. * Gets or sets the list of animations
  78319. */
  78320. animations: Animation[];
  78321. private _scene;
  78322. private _positions;
  78323. private _normals;
  78324. private _tangents;
  78325. private _influence;
  78326. /**
  78327. * Observable raised when the influence changes
  78328. */
  78329. onInfluenceChanged: Observable<boolean>;
  78330. /** @hidden */
  78331. _onDataLayoutChanged: Observable<void>;
  78332. /**
  78333. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  78334. */
  78335. influence: number;
  78336. /**
  78337. * Gets or sets the id of the morph Target
  78338. */
  78339. id: string;
  78340. private _animationPropertiesOverride;
  78341. /**
  78342. * Gets or sets the animation properties override
  78343. */
  78344. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  78345. /**
  78346. * Creates a new MorphTarget
  78347. * @param name defines the name of the target
  78348. * @param influence defines the influence to use
  78349. * @param scene defines the scene the morphtarget belongs to
  78350. */
  78351. constructor(
  78352. /** defines the name of the target */
  78353. name: string, influence?: number, scene?: Nullable<Scene>);
  78354. /**
  78355. * Gets a boolean defining if the target contains position data
  78356. */
  78357. readonly hasPositions: boolean;
  78358. /**
  78359. * Gets a boolean defining if the target contains normal data
  78360. */
  78361. readonly hasNormals: boolean;
  78362. /**
  78363. * Gets a boolean defining if the target contains tangent data
  78364. */
  78365. readonly hasTangents: boolean;
  78366. /**
  78367. * Affects position data to this target
  78368. * @param data defines the position data to use
  78369. */
  78370. setPositions(data: Nullable<FloatArray>): void;
  78371. /**
  78372. * Gets the position data stored in this target
  78373. * @returns a FloatArray containing the position data (or null if not present)
  78374. */
  78375. getPositions(): Nullable<FloatArray>;
  78376. /**
  78377. * Affects normal data to this target
  78378. * @param data defines the normal data to use
  78379. */
  78380. setNormals(data: Nullable<FloatArray>): void;
  78381. /**
  78382. * Gets the normal data stored in this target
  78383. * @returns a FloatArray containing the normal data (or null if not present)
  78384. */
  78385. getNormals(): Nullable<FloatArray>;
  78386. /**
  78387. * Affects tangent data to this target
  78388. * @param data defines the tangent data to use
  78389. */
  78390. setTangents(data: Nullable<FloatArray>): void;
  78391. /**
  78392. * Gets the tangent data stored in this target
  78393. * @returns a FloatArray containing the tangent data (or null if not present)
  78394. */
  78395. getTangents(): Nullable<FloatArray>;
  78396. /**
  78397. * Serializes the current target into a Serialization object
  78398. * @returns the serialized object
  78399. */
  78400. serialize(): any;
  78401. /**
  78402. * Returns the string "MorphTarget"
  78403. * @returns "MorphTarget"
  78404. */
  78405. getClassName(): string;
  78406. /**
  78407. * Creates a new target from serialized data
  78408. * @param serializationObject defines the serialized data to use
  78409. * @returns a new MorphTarget
  78410. */
  78411. static Parse(serializationObject: any): MorphTarget;
  78412. /**
  78413. * Creates a MorphTarget from mesh data
  78414. * @param mesh defines the source mesh
  78415. * @param name defines the name to use for the new target
  78416. * @param influence defines the influence to attach to the target
  78417. * @returns a new MorphTarget
  78418. */
  78419. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  78420. }
  78421. }
  78422. declare module BABYLON {
  78423. /**
  78424. * This class is used to deform meshes using morphing between different targets
  78425. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  78426. */
  78427. export class MorphTargetManager {
  78428. private _targets;
  78429. private _targetInfluenceChangedObservers;
  78430. private _targetDataLayoutChangedObservers;
  78431. private _activeTargets;
  78432. private _scene;
  78433. private _influences;
  78434. private _supportsNormals;
  78435. private _supportsTangents;
  78436. private _vertexCount;
  78437. private _uniqueId;
  78438. private _tempInfluences;
  78439. /**
  78440. * Creates a new MorphTargetManager
  78441. * @param scene defines the current scene
  78442. */
  78443. constructor(scene?: Nullable<Scene>);
  78444. /**
  78445. * Gets the unique ID of this manager
  78446. */
  78447. readonly uniqueId: number;
  78448. /**
  78449. * Gets the number of vertices handled by this manager
  78450. */
  78451. readonly vertexCount: number;
  78452. /**
  78453. * Gets a boolean indicating if this manager supports morphing of normals
  78454. */
  78455. readonly supportsNormals: boolean;
  78456. /**
  78457. * Gets a boolean indicating if this manager supports morphing of tangents
  78458. */
  78459. readonly supportsTangents: boolean;
  78460. /**
  78461. * Gets the number of targets stored in this manager
  78462. */
  78463. readonly numTargets: number;
  78464. /**
  78465. * Gets the number of influencers (ie. the number of targets with influences > 0)
  78466. */
  78467. readonly numInfluencers: number;
  78468. /**
  78469. * Gets the list of influences (one per target)
  78470. */
  78471. readonly influences: Float32Array;
  78472. /**
  78473. * Gets the active target at specified index. An active target is a target with an influence > 0
  78474. * @param index defines the index to check
  78475. * @returns the requested target
  78476. */
  78477. getActiveTarget(index: number): MorphTarget;
  78478. /**
  78479. * Gets the target at specified index
  78480. * @param index defines the index to check
  78481. * @returns the requested target
  78482. */
  78483. getTarget(index: number): MorphTarget;
  78484. /**
  78485. * Add a new target to this manager
  78486. * @param target defines the target to add
  78487. */
  78488. addTarget(target: MorphTarget): void;
  78489. /**
  78490. * Removes a target from the manager
  78491. * @param target defines the target to remove
  78492. */
  78493. removeTarget(target: MorphTarget): void;
  78494. /**
  78495. * Serializes the current manager into a Serialization object
  78496. * @returns the serialized object
  78497. */
  78498. serialize(): any;
  78499. private _syncActiveTargets;
  78500. /**
  78501. * Syncrhonize the targets with all the meshes using this morph target manager
  78502. */
  78503. synchronize(): void;
  78504. /**
  78505. * Creates a new MorphTargetManager from serialized data
  78506. * @param serializationObject defines the serialized data
  78507. * @param scene defines the hosting scene
  78508. * @returns the new MorphTargetManager
  78509. */
  78510. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  78511. }
  78512. }
  78513. declare module BABYLON {
  78514. /**
  78515. * Mesh representing the gorund
  78516. */
  78517. export class GroundMesh extends Mesh {
  78518. /** If octree should be generated */
  78519. generateOctree: boolean;
  78520. private _heightQuads;
  78521. /** @hidden */
  78522. _subdivisionsX: number;
  78523. /** @hidden */
  78524. _subdivisionsY: number;
  78525. /** @hidden */
  78526. _width: number;
  78527. /** @hidden */
  78528. _height: number;
  78529. /** @hidden */
  78530. _minX: number;
  78531. /** @hidden */
  78532. _maxX: number;
  78533. /** @hidden */
  78534. _minZ: number;
  78535. /** @hidden */
  78536. _maxZ: number;
  78537. constructor(name: string, scene: Scene);
  78538. /**
  78539. * "GroundMesh"
  78540. * @returns "GroundMesh"
  78541. */
  78542. getClassName(): string;
  78543. /**
  78544. * The minimum of x and y subdivisions
  78545. */
  78546. readonly subdivisions: number;
  78547. /**
  78548. * X subdivisions
  78549. */
  78550. readonly subdivisionsX: number;
  78551. /**
  78552. * Y subdivisions
  78553. */
  78554. readonly subdivisionsY: number;
  78555. /**
  78556. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  78557. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  78558. * @param chunksCount the number of subdivisions for x and y
  78559. * @param octreeBlocksSize (Default: 32)
  78560. */
  78561. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  78562. /**
  78563. * Returns a height (y) value in the Worl system :
  78564. * the ground altitude at the coordinates (x, z) expressed in the World system.
  78565. * @param x x coordinate
  78566. * @param z z coordinate
  78567. * @returns the ground y position if (x, z) are outside the ground surface.
  78568. */
  78569. getHeightAtCoordinates(x: number, z: number): number;
  78570. /**
  78571. * Returns a normalized vector (Vector3) orthogonal to the ground
  78572. * at the ground coordinates (x, z) expressed in the World system.
  78573. * @param x x coordinate
  78574. * @param z z coordinate
  78575. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  78576. */
  78577. getNormalAtCoordinates(x: number, z: number): Vector3;
  78578. /**
  78579. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  78580. * at the ground coordinates (x, z) expressed in the World system.
  78581. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  78582. * @param x x coordinate
  78583. * @param z z coordinate
  78584. * @param ref vector to store the result
  78585. * @returns the GroundMesh.
  78586. */
  78587. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  78588. /**
  78589. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  78590. * if the ground has been updated.
  78591. * This can be used in the render loop.
  78592. * @returns the GroundMesh.
  78593. */
  78594. updateCoordinateHeights(): GroundMesh;
  78595. private _getFacetAt;
  78596. private _initHeightQuads;
  78597. private _computeHeightQuads;
  78598. /**
  78599. * Serializes this ground mesh
  78600. * @param serializationObject object to write serialization to
  78601. */
  78602. serialize(serializationObject: any): void;
  78603. /**
  78604. * Parses a serialized ground mesh
  78605. * @param parsedMesh the serialized mesh
  78606. * @param scene the scene to create the ground mesh in
  78607. * @returns the created ground mesh
  78608. */
  78609. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  78610. }
  78611. }
  78612. declare module BABYLON {
  78613. /**
  78614. * Interface for Physics-Joint data
  78615. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  78616. */
  78617. export interface PhysicsJointData {
  78618. /**
  78619. * The main pivot of the joint
  78620. */
  78621. mainPivot?: Vector3;
  78622. /**
  78623. * The connected pivot of the joint
  78624. */
  78625. connectedPivot?: Vector3;
  78626. /**
  78627. * The main axis of the joint
  78628. */
  78629. mainAxis?: Vector3;
  78630. /**
  78631. * The connected axis of the joint
  78632. */
  78633. connectedAxis?: Vector3;
  78634. /**
  78635. * The collision of the joint
  78636. */
  78637. collision?: boolean;
  78638. /**
  78639. * Native Oimo/Cannon/Energy data
  78640. */
  78641. nativeParams?: any;
  78642. }
  78643. /**
  78644. * This is a holder class for the physics joint created by the physics plugin
  78645. * It holds a set of functions to control the underlying joint
  78646. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  78647. */
  78648. export class PhysicsJoint {
  78649. /**
  78650. * The type of the physics joint
  78651. */
  78652. type: number;
  78653. /**
  78654. * The data for the physics joint
  78655. */
  78656. jointData: PhysicsJointData;
  78657. private _physicsJoint;
  78658. protected _physicsPlugin: IPhysicsEnginePlugin;
  78659. /**
  78660. * Initializes the physics joint
  78661. * @param type The type of the physics joint
  78662. * @param jointData The data for the physics joint
  78663. */
  78664. constructor(
  78665. /**
  78666. * The type of the physics joint
  78667. */
  78668. type: number,
  78669. /**
  78670. * The data for the physics joint
  78671. */
  78672. jointData: PhysicsJointData);
  78673. /**
  78674. * Gets the physics joint
  78675. */
  78676. /**
  78677. * Sets the physics joint
  78678. */
  78679. physicsJoint: any;
  78680. /**
  78681. * Sets the physics plugin
  78682. */
  78683. physicsPlugin: IPhysicsEnginePlugin;
  78684. /**
  78685. * Execute a function that is physics-plugin specific.
  78686. * @param {Function} func the function that will be executed.
  78687. * It accepts two parameters: the physics world and the physics joint
  78688. */
  78689. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  78690. /**
  78691. * Distance-Joint type
  78692. */
  78693. static DistanceJoint: number;
  78694. /**
  78695. * Hinge-Joint type
  78696. */
  78697. static HingeJoint: number;
  78698. /**
  78699. * Ball-and-Socket joint type
  78700. */
  78701. static BallAndSocketJoint: number;
  78702. /**
  78703. * Wheel-Joint type
  78704. */
  78705. static WheelJoint: number;
  78706. /**
  78707. * Slider-Joint type
  78708. */
  78709. static SliderJoint: number;
  78710. /**
  78711. * Prismatic-Joint type
  78712. */
  78713. static PrismaticJoint: number;
  78714. /**
  78715. * Universal-Joint type
  78716. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  78717. */
  78718. static UniversalJoint: number;
  78719. /**
  78720. * Hinge-Joint 2 type
  78721. */
  78722. static Hinge2Joint: number;
  78723. /**
  78724. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  78725. */
  78726. static PointToPointJoint: number;
  78727. /**
  78728. * Spring-Joint type
  78729. */
  78730. static SpringJoint: number;
  78731. /**
  78732. * Lock-Joint type
  78733. */
  78734. static LockJoint: number;
  78735. }
  78736. /**
  78737. * A class representing a physics distance joint
  78738. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  78739. */
  78740. export class DistanceJoint extends PhysicsJoint {
  78741. /**
  78742. *
  78743. * @param jointData The data for the Distance-Joint
  78744. */
  78745. constructor(jointData: DistanceJointData);
  78746. /**
  78747. * Update the predefined distance.
  78748. * @param maxDistance The maximum preferred distance
  78749. * @param minDistance The minimum preferred distance
  78750. */
  78751. updateDistance(maxDistance: number, minDistance?: number): void;
  78752. }
  78753. /**
  78754. * Represents a Motor-Enabled Joint
  78755. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  78756. */
  78757. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  78758. /**
  78759. * Initializes the Motor-Enabled Joint
  78760. * @param type The type of the joint
  78761. * @param jointData The physica joint data for the joint
  78762. */
  78763. constructor(type: number, jointData: PhysicsJointData);
  78764. /**
  78765. * Set the motor values.
  78766. * Attention, this function is plugin specific. Engines won't react 100% the same.
  78767. * @param force the force to apply
  78768. * @param maxForce max force for this motor.
  78769. */
  78770. setMotor(force?: number, maxForce?: number): void;
  78771. /**
  78772. * Set the motor's limits.
  78773. * Attention, this function is plugin specific. Engines won't react 100% the same.
  78774. * @param upperLimit The upper limit of the motor
  78775. * @param lowerLimit The lower limit of the motor
  78776. */
  78777. setLimit(upperLimit: number, lowerLimit?: number): void;
  78778. }
  78779. /**
  78780. * This class represents a single physics Hinge-Joint
  78781. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  78782. */
  78783. export class HingeJoint extends MotorEnabledJoint {
  78784. /**
  78785. * Initializes the Hinge-Joint
  78786. * @param jointData The joint data for the Hinge-Joint
  78787. */
  78788. constructor(jointData: PhysicsJointData);
  78789. /**
  78790. * Set the motor values.
  78791. * Attention, this function is plugin specific. Engines won't react 100% the same.
  78792. * @param {number} force the force to apply
  78793. * @param {number} maxForce max force for this motor.
  78794. */
  78795. setMotor(force?: number, maxForce?: number): void;
  78796. /**
  78797. * Set the motor's limits.
  78798. * Attention, this function is plugin specific. Engines won't react 100% the same.
  78799. * @param upperLimit The upper limit of the motor
  78800. * @param lowerLimit The lower limit of the motor
  78801. */
  78802. setLimit(upperLimit: number, lowerLimit?: number): void;
  78803. }
  78804. /**
  78805. * This class represents a dual hinge physics joint (same as wheel joint)
  78806. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  78807. */
  78808. export class Hinge2Joint extends MotorEnabledJoint {
  78809. /**
  78810. * Initializes the Hinge2-Joint
  78811. * @param jointData The joint data for the Hinge2-Joint
  78812. */
  78813. constructor(jointData: PhysicsJointData);
  78814. /**
  78815. * Set the motor values.
  78816. * Attention, this function is plugin specific. Engines won't react 100% the same.
  78817. * @param {number} targetSpeed the speed the motor is to reach
  78818. * @param {number} maxForce max force for this motor.
  78819. * @param {motorIndex} the motor's index, 0 or 1.
  78820. */
  78821. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  78822. /**
  78823. * Set the motor limits.
  78824. * Attention, this function is plugin specific. Engines won't react 100% the same.
  78825. * @param {number} upperLimit the upper limit
  78826. * @param {number} lowerLimit lower limit
  78827. * @param {motorIndex} the motor's index, 0 or 1.
  78828. */
  78829. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  78830. }
  78831. /**
  78832. * Interface for a motor enabled joint
  78833. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  78834. */
  78835. export interface IMotorEnabledJoint {
  78836. /**
  78837. * Physics joint
  78838. */
  78839. physicsJoint: any;
  78840. /**
  78841. * Sets the motor of the motor-enabled joint
  78842. * @param force The force of the motor
  78843. * @param maxForce The maximum force of the motor
  78844. * @param motorIndex The index of the motor
  78845. */
  78846. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  78847. /**
  78848. * Sets the limit of the motor
  78849. * @param upperLimit The upper limit of the motor
  78850. * @param lowerLimit The lower limit of the motor
  78851. * @param motorIndex The index of the motor
  78852. */
  78853. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  78854. }
  78855. /**
  78856. * Joint data for a Distance-Joint
  78857. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  78858. */
  78859. export interface DistanceJointData extends PhysicsJointData {
  78860. /**
  78861. * Max distance the 2 joint objects can be apart
  78862. */
  78863. maxDistance: number;
  78864. }
  78865. /**
  78866. * Joint data from a spring joint
  78867. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  78868. */
  78869. export interface SpringJointData extends PhysicsJointData {
  78870. /**
  78871. * Length of the spring
  78872. */
  78873. length: number;
  78874. /**
  78875. * Stiffness of the spring
  78876. */
  78877. stiffness: number;
  78878. /**
  78879. * Damping of the spring
  78880. */
  78881. damping: number;
  78882. /** this callback will be called when applying the force to the impostors. */
  78883. forceApplicationCallback: () => void;
  78884. }
  78885. }
  78886. declare module BABYLON {
  78887. /**
  78888. * Holds the data for the raycast result
  78889. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  78890. */
  78891. export class PhysicsRaycastResult {
  78892. private _hasHit;
  78893. private _hitDistance;
  78894. private _hitNormalWorld;
  78895. private _hitPointWorld;
  78896. private _rayFromWorld;
  78897. private _rayToWorld;
  78898. /**
  78899. * Gets if there was a hit
  78900. */
  78901. readonly hasHit: boolean;
  78902. /**
  78903. * Gets the distance from the hit
  78904. */
  78905. readonly hitDistance: number;
  78906. /**
  78907. * Gets the hit normal/direction in the world
  78908. */
  78909. readonly hitNormalWorld: Vector3;
  78910. /**
  78911. * Gets the hit point in the world
  78912. */
  78913. readonly hitPointWorld: Vector3;
  78914. /**
  78915. * Gets the ray "start point" of the ray in the world
  78916. */
  78917. readonly rayFromWorld: Vector3;
  78918. /**
  78919. * Gets the ray "end point" of the ray in the world
  78920. */
  78921. readonly rayToWorld: Vector3;
  78922. /**
  78923. * Sets the hit data (normal & point in world space)
  78924. * @param hitNormalWorld defines the normal in world space
  78925. * @param hitPointWorld defines the point in world space
  78926. */
  78927. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  78928. /**
  78929. * Sets the distance from the start point to the hit point
  78930. * @param distance
  78931. */
  78932. setHitDistance(distance: number): void;
  78933. /**
  78934. * Calculates the distance manually
  78935. */
  78936. calculateHitDistance(): void;
  78937. /**
  78938. * Resets all the values to default
  78939. * @param from The from point on world space
  78940. * @param to The to point on world space
  78941. */
  78942. reset(from?: Vector3, to?: Vector3): void;
  78943. }
  78944. /**
  78945. * Interface for the size containing width and height
  78946. */
  78947. interface IXYZ {
  78948. /**
  78949. * X
  78950. */
  78951. x: number;
  78952. /**
  78953. * Y
  78954. */
  78955. y: number;
  78956. /**
  78957. * Z
  78958. */
  78959. z: number;
  78960. }
  78961. }
  78962. declare module BABYLON {
  78963. /**
  78964. * Interface used to describe a physics joint
  78965. */
  78966. export interface PhysicsImpostorJoint {
  78967. /** Defines the main impostor to which the joint is linked */
  78968. mainImpostor: PhysicsImpostor;
  78969. /** Defines the impostor that is connected to the main impostor using this joint */
  78970. connectedImpostor: PhysicsImpostor;
  78971. /** Defines the joint itself */
  78972. joint: PhysicsJoint;
  78973. }
  78974. /** @hidden */
  78975. export interface IPhysicsEnginePlugin {
  78976. world: any;
  78977. name: string;
  78978. setGravity(gravity: Vector3): void;
  78979. setTimeStep(timeStep: number): void;
  78980. getTimeStep(): number;
  78981. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  78982. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  78983. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  78984. generatePhysicsBody(impostor: PhysicsImpostor): void;
  78985. removePhysicsBody(impostor: PhysicsImpostor): void;
  78986. generateJoint(joint: PhysicsImpostorJoint): void;
  78987. removeJoint(joint: PhysicsImpostorJoint): void;
  78988. isSupported(): boolean;
  78989. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  78990. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  78991. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  78992. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  78993. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  78994. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  78995. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  78996. getBodyMass(impostor: PhysicsImpostor): number;
  78997. getBodyFriction(impostor: PhysicsImpostor): number;
  78998. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  78999. getBodyRestitution(impostor: PhysicsImpostor): number;
  79000. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  79001. getBodyPressure?(impostor: PhysicsImpostor): number;
  79002. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  79003. getBodyStiffness?(impostor: PhysicsImpostor): number;
  79004. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  79005. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  79006. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  79007. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  79008. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  79009. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  79010. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  79011. sleepBody(impostor: PhysicsImpostor): void;
  79012. wakeUpBody(impostor: PhysicsImpostor): void;
  79013. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  79014. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  79015. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  79016. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  79017. getRadius(impostor: PhysicsImpostor): number;
  79018. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  79019. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  79020. dispose(): void;
  79021. }
  79022. /**
  79023. * Interface used to define a physics engine
  79024. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  79025. */
  79026. export interface IPhysicsEngine {
  79027. /**
  79028. * Gets the gravity vector used by the simulation
  79029. */
  79030. gravity: Vector3;
  79031. /**
  79032. * Sets the gravity vector used by the simulation
  79033. * @param gravity defines the gravity vector to use
  79034. */
  79035. setGravity(gravity: Vector3): void;
  79036. /**
  79037. * Set the time step of the physics engine.
  79038. * Default is 1/60.
  79039. * To slow it down, enter 1/600 for example.
  79040. * To speed it up, 1/30
  79041. * @param newTimeStep the new timestep to apply to this world.
  79042. */
  79043. setTimeStep(newTimeStep: number): void;
  79044. /**
  79045. * Get the time step of the physics engine.
  79046. * @returns the current time step
  79047. */
  79048. getTimeStep(): number;
  79049. /**
  79050. * Release all resources
  79051. */
  79052. dispose(): void;
  79053. /**
  79054. * Gets the name of the current physics plugin
  79055. * @returns the name of the plugin
  79056. */
  79057. getPhysicsPluginName(): string;
  79058. /**
  79059. * Adding a new impostor for the impostor tracking.
  79060. * This will be done by the impostor itself.
  79061. * @param impostor the impostor to add
  79062. */
  79063. addImpostor(impostor: PhysicsImpostor): void;
  79064. /**
  79065. * Remove an impostor from the engine.
  79066. * This impostor and its mesh will not longer be updated by the physics engine.
  79067. * @param impostor the impostor to remove
  79068. */
  79069. removeImpostor(impostor: PhysicsImpostor): void;
  79070. /**
  79071. * Add a joint to the physics engine
  79072. * @param mainImpostor defines the main impostor to which the joint is added.
  79073. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  79074. * @param joint defines the joint that will connect both impostors.
  79075. */
  79076. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  79077. /**
  79078. * Removes a joint from the simulation
  79079. * @param mainImpostor defines the impostor used with the joint
  79080. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  79081. * @param joint defines the joint to remove
  79082. */
  79083. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  79084. /**
  79085. * Gets the current plugin used to run the simulation
  79086. * @returns current plugin
  79087. */
  79088. getPhysicsPlugin(): IPhysicsEnginePlugin;
  79089. /**
  79090. * Gets the list of physic impostors
  79091. * @returns an array of PhysicsImpostor
  79092. */
  79093. getImpostors(): Array<PhysicsImpostor>;
  79094. /**
  79095. * Gets the impostor for a physics enabled object
  79096. * @param object defines the object impersonated by the impostor
  79097. * @returns the PhysicsImpostor or null if not found
  79098. */
  79099. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  79100. /**
  79101. * Gets the impostor for a physics body object
  79102. * @param body defines physics body used by the impostor
  79103. * @returns the PhysicsImpostor or null if not found
  79104. */
  79105. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  79106. /**
  79107. * Does a raycast in the physics world
  79108. * @param from when should the ray start?
  79109. * @param to when should the ray end?
  79110. * @returns PhysicsRaycastResult
  79111. */
  79112. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  79113. /**
  79114. * Called by the scene. No need to call it.
  79115. * @param delta defines the timespam between frames
  79116. */
  79117. _step(delta: number): void;
  79118. }
  79119. }
  79120. declare module BABYLON {
  79121. /**
  79122. * The interface for the physics imposter parameters
  79123. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  79124. */
  79125. export interface PhysicsImpostorParameters {
  79126. /**
  79127. * The mass of the physics imposter
  79128. */
  79129. mass: number;
  79130. /**
  79131. * The friction of the physics imposter
  79132. */
  79133. friction?: number;
  79134. /**
  79135. * The coefficient of restitution of the physics imposter
  79136. */
  79137. restitution?: number;
  79138. /**
  79139. * The native options of the physics imposter
  79140. */
  79141. nativeOptions?: any;
  79142. /**
  79143. * Specifies if the parent should be ignored
  79144. */
  79145. ignoreParent?: boolean;
  79146. /**
  79147. * Specifies if bi-directional transformations should be disabled
  79148. */
  79149. disableBidirectionalTransformation?: boolean;
  79150. /**
  79151. * The pressure inside the physics imposter, soft object only
  79152. */
  79153. pressure?: number;
  79154. /**
  79155. * The stiffness the physics imposter, soft object only
  79156. */
  79157. stiffness?: number;
  79158. /**
  79159. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  79160. */
  79161. velocityIterations?: number;
  79162. /**
  79163. * The number of iterations used in maintaining consistent vertex positions, soft object only
  79164. */
  79165. positionIterations?: number;
  79166. /**
  79167. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  79168. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  79169. * Add to fix multiple points
  79170. */
  79171. fixedPoints?: number;
  79172. /**
  79173. * The collision margin around a soft object
  79174. */
  79175. margin?: number;
  79176. /**
  79177. * The collision margin around a soft object
  79178. */
  79179. damping?: number;
  79180. /**
  79181. * The path for a rope based on an extrusion
  79182. */
  79183. path?: any;
  79184. /**
  79185. * The shape of an extrusion used for a rope based on an extrusion
  79186. */
  79187. shape?: any;
  79188. }
  79189. /**
  79190. * Interface for a physics-enabled object
  79191. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  79192. */
  79193. export interface IPhysicsEnabledObject {
  79194. /**
  79195. * The position of the physics-enabled object
  79196. */
  79197. position: Vector3;
  79198. /**
  79199. * The rotation of the physics-enabled object
  79200. */
  79201. rotationQuaternion: Nullable<Quaternion>;
  79202. /**
  79203. * The scale of the physics-enabled object
  79204. */
  79205. scaling: Vector3;
  79206. /**
  79207. * The rotation of the physics-enabled object
  79208. */
  79209. rotation?: Vector3;
  79210. /**
  79211. * The parent of the physics-enabled object
  79212. */
  79213. parent?: any;
  79214. /**
  79215. * The bounding info of the physics-enabled object
  79216. * @returns The bounding info of the physics-enabled object
  79217. */
  79218. getBoundingInfo(): BoundingInfo;
  79219. /**
  79220. * Computes the world matrix
  79221. * @param force Specifies if the world matrix should be computed by force
  79222. * @returns A world matrix
  79223. */
  79224. computeWorldMatrix(force: boolean): Matrix;
  79225. /**
  79226. * Gets the world matrix
  79227. * @returns A world matrix
  79228. */
  79229. getWorldMatrix?(): Matrix;
  79230. /**
  79231. * Gets the child meshes
  79232. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  79233. * @returns An array of abstract meshes
  79234. */
  79235. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  79236. /**
  79237. * Gets the vertex data
  79238. * @param kind The type of vertex data
  79239. * @returns A nullable array of numbers, or a float32 array
  79240. */
  79241. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  79242. /**
  79243. * Gets the indices from the mesh
  79244. * @returns A nullable array of index arrays
  79245. */
  79246. getIndices?(): Nullable<IndicesArray>;
  79247. /**
  79248. * Gets the scene from the mesh
  79249. * @returns the indices array or null
  79250. */
  79251. getScene?(): Scene;
  79252. /**
  79253. * Gets the absolute position from the mesh
  79254. * @returns the absolute position
  79255. */
  79256. getAbsolutePosition(): Vector3;
  79257. /**
  79258. * Gets the absolute pivot point from the mesh
  79259. * @returns the absolute pivot point
  79260. */
  79261. getAbsolutePivotPoint(): Vector3;
  79262. /**
  79263. * Rotates the mesh
  79264. * @param axis The axis of rotation
  79265. * @param amount The amount of rotation
  79266. * @param space The space of the rotation
  79267. * @returns The rotation transform node
  79268. */
  79269. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  79270. /**
  79271. * Translates the mesh
  79272. * @param axis The axis of translation
  79273. * @param distance The distance of translation
  79274. * @param space The space of the translation
  79275. * @returns The transform node
  79276. */
  79277. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  79278. /**
  79279. * Sets the absolute position of the mesh
  79280. * @param absolutePosition The absolute position of the mesh
  79281. * @returns The transform node
  79282. */
  79283. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  79284. /**
  79285. * Gets the class name of the mesh
  79286. * @returns The class name
  79287. */
  79288. getClassName(): string;
  79289. }
  79290. /**
  79291. * Represents a physics imposter
  79292. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  79293. */
  79294. export class PhysicsImpostor {
  79295. /**
  79296. * The physics-enabled object used as the physics imposter
  79297. */
  79298. object: IPhysicsEnabledObject;
  79299. /**
  79300. * The type of the physics imposter
  79301. */
  79302. type: number;
  79303. private _options;
  79304. private _scene?;
  79305. /**
  79306. * The default object size of the imposter
  79307. */
  79308. static DEFAULT_OBJECT_SIZE: Vector3;
  79309. /**
  79310. * The identity quaternion of the imposter
  79311. */
  79312. static IDENTITY_QUATERNION: Quaternion;
  79313. /** @hidden */
  79314. _pluginData: any;
  79315. private _physicsEngine;
  79316. private _physicsBody;
  79317. private _bodyUpdateRequired;
  79318. private _onBeforePhysicsStepCallbacks;
  79319. private _onAfterPhysicsStepCallbacks;
  79320. /** @hidden */
  79321. _onPhysicsCollideCallbacks: Array<{
  79322. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  79323. otherImpostors: Array<PhysicsImpostor>;
  79324. }>;
  79325. private _deltaPosition;
  79326. private _deltaRotation;
  79327. private _deltaRotationConjugated;
  79328. /** hidden */
  79329. _isFromLine: boolean;
  79330. private _parent;
  79331. private _isDisposed;
  79332. private static _tmpVecs;
  79333. private static _tmpQuat;
  79334. /**
  79335. * Specifies if the physics imposter is disposed
  79336. */
  79337. readonly isDisposed: boolean;
  79338. /**
  79339. * Gets the mass of the physics imposter
  79340. */
  79341. mass: number;
  79342. /**
  79343. * Gets the coefficient of friction
  79344. */
  79345. /**
  79346. * Sets the coefficient of friction
  79347. */
  79348. friction: number;
  79349. /**
  79350. * Gets the coefficient of restitution
  79351. */
  79352. /**
  79353. * Sets the coefficient of restitution
  79354. */
  79355. restitution: number;
  79356. /**
  79357. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  79358. */
  79359. /**
  79360. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  79361. */
  79362. pressure: number;
  79363. /**
  79364. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  79365. */
  79366. /**
  79367. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  79368. */
  79369. stiffness: number;
  79370. /**
  79371. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  79372. */
  79373. /**
  79374. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  79375. */
  79376. velocityIterations: number;
  79377. /**
  79378. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  79379. */
  79380. /**
  79381. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  79382. */
  79383. positionIterations: number;
  79384. /**
  79385. * The unique id of the physics imposter
  79386. * set by the physics engine when adding this impostor to the array
  79387. */
  79388. uniqueId: number;
  79389. /**
  79390. * @hidden
  79391. */
  79392. soft: boolean;
  79393. /**
  79394. * @hidden
  79395. */
  79396. segments: number;
  79397. private _joints;
  79398. /**
  79399. * Initializes the physics imposter
  79400. * @param object The physics-enabled object used as the physics imposter
  79401. * @param type The type of the physics imposter
  79402. * @param _options The options for the physics imposter
  79403. * @param _scene The Babylon scene
  79404. */
  79405. constructor(
  79406. /**
  79407. * The physics-enabled object used as the physics imposter
  79408. */
  79409. object: IPhysicsEnabledObject,
  79410. /**
  79411. * The type of the physics imposter
  79412. */
  79413. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  79414. /**
  79415. * This function will completly initialize this impostor.
  79416. * It will create a new body - but only if this mesh has no parent.
  79417. * If it has, this impostor will not be used other than to define the impostor
  79418. * of the child mesh.
  79419. * @hidden
  79420. */
  79421. _init(): void;
  79422. private _getPhysicsParent;
  79423. /**
  79424. * Should a new body be generated.
  79425. * @returns boolean specifying if body initialization is required
  79426. */
  79427. isBodyInitRequired(): boolean;
  79428. /**
  79429. * Sets the updated scaling
  79430. * @param updated Specifies if the scaling is updated
  79431. */
  79432. setScalingUpdated(): void;
  79433. /**
  79434. * Force a regeneration of this or the parent's impostor's body.
  79435. * Use under cautious - This will remove all joints already implemented.
  79436. */
  79437. forceUpdate(): void;
  79438. /**
  79439. * Gets the body that holds this impostor. Either its own, or its parent.
  79440. */
  79441. /**
  79442. * Set the physics body. Used mainly by the physics engine/plugin
  79443. */
  79444. physicsBody: any;
  79445. /**
  79446. * Get the parent of the physics imposter
  79447. * @returns Physics imposter or null
  79448. */
  79449. /**
  79450. * Sets the parent of the physics imposter
  79451. */
  79452. parent: Nullable<PhysicsImpostor>;
  79453. /**
  79454. * Resets the update flags
  79455. */
  79456. resetUpdateFlags(): void;
  79457. /**
  79458. * Gets the object extend size
  79459. * @returns the object extend size
  79460. */
  79461. getObjectExtendSize(): Vector3;
  79462. /**
  79463. * Gets the object center
  79464. * @returns The object center
  79465. */
  79466. getObjectCenter(): Vector3;
  79467. /**
  79468. * Get a specific parametes from the options parameter
  79469. * @param paramName The object parameter name
  79470. * @returns The object parameter
  79471. */
  79472. getParam(paramName: string): any;
  79473. /**
  79474. * Sets a specific parameter in the options given to the physics plugin
  79475. * @param paramName The parameter name
  79476. * @param value The value of the parameter
  79477. */
  79478. setParam(paramName: string, value: number): void;
  79479. /**
  79480. * Specifically change the body's mass option. Won't recreate the physics body object
  79481. * @param mass The mass of the physics imposter
  79482. */
  79483. setMass(mass: number): void;
  79484. /**
  79485. * Gets the linear velocity
  79486. * @returns linear velocity or null
  79487. */
  79488. getLinearVelocity(): Nullable<Vector3>;
  79489. /**
  79490. * Sets the linear velocity
  79491. * @param velocity linear velocity or null
  79492. */
  79493. setLinearVelocity(velocity: Nullable<Vector3>): void;
  79494. /**
  79495. * Gets the angular velocity
  79496. * @returns angular velocity or null
  79497. */
  79498. getAngularVelocity(): Nullable<Vector3>;
  79499. /**
  79500. * Sets the angular velocity
  79501. * @param velocity The velocity or null
  79502. */
  79503. setAngularVelocity(velocity: Nullable<Vector3>): void;
  79504. /**
  79505. * Execute a function with the physics plugin native code
  79506. * Provide a function the will have two variables - the world object and the physics body object
  79507. * @param func The function to execute with the physics plugin native code
  79508. */
  79509. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  79510. /**
  79511. * Register a function that will be executed before the physics world is stepping forward
  79512. * @param func The function to execute before the physics world is stepped forward
  79513. */
  79514. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  79515. /**
  79516. * Unregister a function that will be executed before the physics world is stepping forward
  79517. * @param func The function to execute before the physics world is stepped forward
  79518. */
  79519. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  79520. /**
  79521. * Register a function that will be executed after the physics step
  79522. * @param func The function to execute after physics step
  79523. */
  79524. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  79525. /**
  79526. * Unregisters a function that will be executed after the physics step
  79527. * @param func The function to execute after physics step
  79528. */
  79529. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  79530. /**
  79531. * register a function that will be executed when this impostor collides against a different body
  79532. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  79533. * @param func Callback that is executed on collision
  79534. */
  79535. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  79536. /**
  79537. * Unregisters the physics imposter on contact
  79538. * @param collideAgainst The physics object to collide against
  79539. * @param func Callback to execute on collision
  79540. */
  79541. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  79542. private _tmpQuat;
  79543. private _tmpQuat2;
  79544. /**
  79545. * Get the parent rotation
  79546. * @returns The parent rotation
  79547. */
  79548. getParentsRotation(): Quaternion;
  79549. /**
  79550. * this function is executed by the physics engine.
  79551. */
  79552. beforeStep: () => void;
  79553. /**
  79554. * this function is executed by the physics engine
  79555. */
  79556. afterStep: () => void;
  79557. /**
  79558. * Legacy collision detection event support
  79559. */
  79560. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  79561. /**
  79562. * event and body object due to cannon's event-based architecture.
  79563. */
  79564. onCollide: (e: {
  79565. body: any;
  79566. }) => void;
  79567. /**
  79568. * Apply a force
  79569. * @param force The force to apply
  79570. * @param contactPoint The contact point for the force
  79571. * @returns The physics imposter
  79572. */
  79573. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  79574. /**
  79575. * Apply an impulse
  79576. * @param force The impulse force
  79577. * @param contactPoint The contact point for the impulse force
  79578. * @returns The physics imposter
  79579. */
  79580. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  79581. /**
  79582. * A help function to create a joint
  79583. * @param otherImpostor A physics imposter used to create a joint
  79584. * @param jointType The type of joint
  79585. * @param jointData The data for the joint
  79586. * @returns The physics imposter
  79587. */
  79588. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  79589. /**
  79590. * Add a joint to this impostor with a different impostor
  79591. * @param otherImpostor A physics imposter used to add a joint
  79592. * @param joint The joint to add
  79593. * @returns The physics imposter
  79594. */
  79595. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  79596. /**
  79597. * Add an anchor to a cloth impostor
  79598. * @param otherImpostor rigid impostor to anchor to
  79599. * @param width ratio across width from 0 to 1
  79600. * @param height ratio up height from 0 to 1
  79601. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  79602. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  79603. * @returns impostor the soft imposter
  79604. */
  79605. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  79606. /**
  79607. * Add a hook to a rope impostor
  79608. * @param otherImpostor rigid impostor to anchor to
  79609. * @param length ratio across rope from 0 to 1
  79610. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  79611. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  79612. * @returns impostor the rope imposter
  79613. */
  79614. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  79615. /**
  79616. * Will keep this body still, in a sleep mode.
  79617. * @returns the physics imposter
  79618. */
  79619. sleep(): PhysicsImpostor;
  79620. /**
  79621. * Wake the body up.
  79622. * @returns The physics imposter
  79623. */
  79624. wakeUp(): PhysicsImpostor;
  79625. /**
  79626. * Clones the physics imposter
  79627. * @param newObject The physics imposter clones to this physics-enabled object
  79628. * @returns A nullable physics imposter
  79629. */
  79630. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  79631. /**
  79632. * Disposes the physics imposter
  79633. */
  79634. dispose(): void;
  79635. /**
  79636. * Sets the delta position
  79637. * @param position The delta position amount
  79638. */
  79639. setDeltaPosition(position: Vector3): void;
  79640. /**
  79641. * Sets the delta rotation
  79642. * @param rotation The delta rotation amount
  79643. */
  79644. setDeltaRotation(rotation: Quaternion): void;
  79645. /**
  79646. * Gets the box size of the physics imposter and stores the result in the input parameter
  79647. * @param result Stores the box size
  79648. * @returns The physics imposter
  79649. */
  79650. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  79651. /**
  79652. * Gets the radius of the physics imposter
  79653. * @returns Radius of the physics imposter
  79654. */
  79655. getRadius(): number;
  79656. /**
  79657. * Sync a bone with this impostor
  79658. * @param bone The bone to sync to the impostor.
  79659. * @param boneMesh The mesh that the bone is influencing.
  79660. * @param jointPivot The pivot of the joint / bone in local space.
  79661. * @param distToJoint Optional distance from the impostor to the joint.
  79662. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  79663. */
  79664. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  79665. /**
  79666. * Sync impostor to a bone
  79667. * @param bone The bone that the impostor will be synced to.
  79668. * @param boneMesh The mesh that the bone is influencing.
  79669. * @param jointPivot The pivot of the joint / bone in local space.
  79670. * @param distToJoint Optional distance from the impostor to the joint.
  79671. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  79672. * @param boneAxis Optional vector3 axis the bone is aligned with
  79673. */
  79674. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  79675. /**
  79676. * No-Imposter type
  79677. */
  79678. static NoImpostor: number;
  79679. /**
  79680. * Sphere-Imposter type
  79681. */
  79682. static SphereImpostor: number;
  79683. /**
  79684. * Box-Imposter type
  79685. */
  79686. static BoxImpostor: number;
  79687. /**
  79688. * Plane-Imposter type
  79689. */
  79690. static PlaneImpostor: number;
  79691. /**
  79692. * Mesh-imposter type
  79693. */
  79694. static MeshImpostor: number;
  79695. /**
  79696. * Cylinder-Imposter type
  79697. */
  79698. static CylinderImpostor: number;
  79699. /**
  79700. * Particle-Imposter type
  79701. */
  79702. static ParticleImpostor: number;
  79703. /**
  79704. * Heightmap-Imposter type
  79705. */
  79706. static HeightmapImpostor: number;
  79707. /**
  79708. * ConvexHull-Impostor type (Ammo.js plugin only)
  79709. */
  79710. static ConvexHullImpostor: number;
  79711. /**
  79712. * Rope-Imposter type
  79713. */
  79714. static RopeImpostor: number;
  79715. /**
  79716. * Cloth-Imposter type
  79717. */
  79718. static ClothImpostor: number;
  79719. /**
  79720. * Softbody-Imposter type
  79721. */
  79722. static SoftbodyImpostor: number;
  79723. }
  79724. }
  79725. declare module BABYLON {
  79726. /**
  79727. * Class used to represent a specific level of detail of a mesh
  79728. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  79729. */
  79730. export class MeshLODLevel {
  79731. /** Defines the distance where this level should star being displayed */
  79732. distance: number;
  79733. /** Defines the mesh to use to render this level */
  79734. mesh: Nullable<Mesh>;
  79735. /**
  79736. * Creates a new LOD level
  79737. * @param distance defines the distance where this level should star being displayed
  79738. * @param mesh defines the mesh to use to render this level
  79739. */
  79740. constructor(
  79741. /** Defines the distance where this level should star being displayed */
  79742. distance: number,
  79743. /** Defines the mesh to use to render this level */
  79744. mesh: Nullable<Mesh>);
  79745. }
  79746. /**
  79747. * @hidden
  79748. **/
  79749. export class _CreationDataStorage {
  79750. closePath?: boolean;
  79751. closeArray?: boolean;
  79752. idx: number[];
  79753. dashSize: number;
  79754. gapSize: number;
  79755. path3D: Path3D;
  79756. pathArray: Vector3[][];
  79757. arc: number;
  79758. radius: number;
  79759. cap: number;
  79760. tessellation: number;
  79761. }
  79762. /**
  79763. * @hidden
  79764. **/
  79765. class _InstanceDataStorage {
  79766. visibleInstances: any;
  79767. renderIdForInstances: number[];
  79768. batchCache: _InstancesBatch;
  79769. instancesBufferSize: number;
  79770. instancesBuffer: Nullable<Buffer>;
  79771. instancesData: Float32Array;
  79772. overridenInstanceCount: number;
  79773. }
  79774. /**
  79775. * @hidden
  79776. **/
  79777. export class _InstancesBatch {
  79778. mustReturn: boolean;
  79779. visibleInstances: Nullable<InstancedMesh[]>[];
  79780. renderSelf: boolean[];
  79781. }
  79782. /**
  79783. * Class used to represent renderable models
  79784. */
  79785. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  79786. /**
  79787. * Mesh side orientation : usually the external or front surface
  79788. */
  79789. static readonly FRONTSIDE: number;
  79790. /**
  79791. * Mesh side orientation : usually the internal or back surface
  79792. */
  79793. static readonly BACKSIDE: number;
  79794. /**
  79795. * Mesh side orientation : both internal and external or front and back surfaces
  79796. */
  79797. static readonly DOUBLESIDE: number;
  79798. /**
  79799. * Mesh side orientation : by default, `FRONTSIDE`
  79800. */
  79801. static readonly DEFAULTSIDE: number;
  79802. /**
  79803. * Mesh cap setting : no cap
  79804. */
  79805. static readonly NO_CAP: number;
  79806. /**
  79807. * Mesh cap setting : one cap at the beginning of the mesh
  79808. */
  79809. static readonly CAP_START: number;
  79810. /**
  79811. * Mesh cap setting : one cap at the end of the mesh
  79812. */
  79813. static readonly CAP_END: number;
  79814. /**
  79815. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  79816. */
  79817. static readonly CAP_ALL: number;
  79818. /**
  79819. * Gets the default side orientation.
  79820. * @param orientation the orientation to value to attempt to get
  79821. * @returns the default orientation
  79822. * @hidden
  79823. */
  79824. static _GetDefaultSideOrientation(orientation?: number): number;
  79825. private _onBeforeRenderObservable;
  79826. private _onBeforeBindObservable;
  79827. private _onAfterRenderObservable;
  79828. private _onBeforeDrawObservable;
  79829. /**
  79830. * An event triggered before rendering the mesh
  79831. */
  79832. readonly onBeforeRenderObservable: Observable<Mesh>;
  79833. /**
  79834. * An event triggered before binding the mesh
  79835. */
  79836. readonly onBeforeBindObservable: Observable<Mesh>;
  79837. /**
  79838. * An event triggered after rendering the mesh
  79839. */
  79840. readonly onAfterRenderObservable: Observable<Mesh>;
  79841. /**
  79842. * An event triggered before drawing the mesh
  79843. */
  79844. readonly onBeforeDrawObservable: Observable<Mesh>;
  79845. private _onBeforeDrawObserver;
  79846. /**
  79847. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  79848. */
  79849. onBeforeDraw: () => void;
  79850. /**
  79851. * Gets the delay loading state of the mesh (when delay loading is turned on)
  79852. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  79853. */
  79854. delayLoadState: number;
  79855. /**
  79856. * Gets the list of instances created from this mesh
  79857. * it is not supposed to be modified manually.
  79858. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  79859. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  79860. */
  79861. instances: InstancedMesh[];
  79862. /**
  79863. * Gets the file containing delay loading data for this mesh
  79864. */
  79865. delayLoadingFile: string;
  79866. /** @hidden */
  79867. _binaryInfo: any;
  79868. private _LODLevels;
  79869. /**
  79870. * User defined function used to change how LOD level selection is done
  79871. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  79872. */
  79873. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  79874. private _morphTargetManager;
  79875. /**
  79876. * Gets or sets the morph target manager
  79877. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  79878. */
  79879. morphTargetManager: Nullable<MorphTargetManager>;
  79880. /** @hidden */
  79881. _creationDataStorage: Nullable<_CreationDataStorage>;
  79882. /** @hidden */
  79883. _geometry: Nullable<Geometry>;
  79884. /** @hidden */
  79885. _delayInfo: Array<string>;
  79886. /** @hidden */
  79887. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  79888. /** @hidden */
  79889. _instanceDataStorage: _InstanceDataStorage;
  79890. private _effectiveMaterial;
  79891. /** @hidden */
  79892. _shouldGenerateFlatShading: boolean;
  79893. private _preActivateId;
  79894. /** @hidden */
  79895. _originalBuilderSideOrientation: number;
  79896. /**
  79897. * Use this property to change the original side orientation defined at construction time
  79898. */
  79899. overrideMaterialSideOrientation: Nullable<number>;
  79900. private _areNormalsFrozen;
  79901. private _sourcePositions;
  79902. private _sourceNormals;
  79903. private _source;
  79904. private meshMap;
  79905. /**
  79906. * Gets the source mesh (the one used to clone this one from)
  79907. */
  79908. readonly source: Nullable<Mesh>;
  79909. /**
  79910. * Gets or sets a boolean indicating that this mesh does not use index buffer
  79911. */
  79912. isUnIndexed: boolean;
  79913. /**
  79914. * @constructor
  79915. * @param name The value used by scene.getMeshByName() to do a lookup.
  79916. * @param scene The scene to add this mesh to.
  79917. * @param parent The parent of this mesh, if it has one
  79918. * @param source An optional Mesh from which geometry is shared, cloned.
  79919. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  79920. * When false, achieved by calling a clone(), also passing False.
  79921. * This will make creation of children, recursive.
  79922. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  79923. */
  79924. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  79925. /**
  79926. * Gets the class name
  79927. * @returns the string "Mesh".
  79928. */
  79929. getClassName(): string;
  79930. /** @hidden */
  79931. readonly _isMesh: boolean;
  79932. /**
  79933. * Returns a description of this mesh
  79934. * @param fullDetails define if full details about this mesh must be used
  79935. * @returns a descriptive string representing this mesh
  79936. */
  79937. toString(fullDetails?: boolean): string;
  79938. /** @hidden */
  79939. _unBindEffect(): void;
  79940. /**
  79941. * Gets a boolean indicating if this mesh has LOD
  79942. */
  79943. readonly hasLODLevels: boolean;
  79944. /**
  79945. * Gets the list of MeshLODLevel associated with the current mesh
  79946. * @returns an array of MeshLODLevel
  79947. */
  79948. getLODLevels(): MeshLODLevel[];
  79949. private _sortLODLevels;
  79950. /**
  79951. * Add a mesh as LOD level triggered at the given distance.
  79952. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  79953. * @param distance The distance from the center of the object to show this level
  79954. * @param mesh The mesh to be added as LOD level (can be null)
  79955. * @return This mesh (for chaining)
  79956. */
  79957. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  79958. /**
  79959. * Returns the LOD level mesh at the passed distance or null if not found.
  79960. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  79961. * @param distance The distance from the center of the object to show this level
  79962. * @returns a Mesh or `null`
  79963. */
  79964. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  79965. /**
  79966. * Remove a mesh from the LOD array
  79967. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  79968. * @param mesh defines the mesh to be removed
  79969. * @return This mesh (for chaining)
  79970. */
  79971. removeLODLevel(mesh: Mesh): Mesh;
  79972. /**
  79973. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  79974. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  79975. * @param camera defines the camera to use to compute distance
  79976. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  79977. * @return This mesh (for chaining)
  79978. */
  79979. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  79980. /**
  79981. * Gets the mesh internal Geometry object
  79982. */
  79983. readonly geometry: Nullable<Geometry>;
  79984. /**
  79985. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  79986. * @returns the total number of vertices
  79987. */
  79988. getTotalVertices(): number;
  79989. /**
  79990. * Returns the content of an associated vertex buffer
  79991. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  79992. * - VertexBuffer.PositionKind
  79993. * - VertexBuffer.UVKind
  79994. * - VertexBuffer.UV2Kind
  79995. * - VertexBuffer.UV3Kind
  79996. * - VertexBuffer.UV4Kind
  79997. * - VertexBuffer.UV5Kind
  79998. * - VertexBuffer.UV6Kind
  79999. * - VertexBuffer.ColorKind
  80000. * - VertexBuffer.MatricesIndicesKind
  80001. * - VertexBuffer.MatricesIndicesExtraKind
  80002. * - VertexBuffer.MatricesWeightsKind
  80003. * - VertexBuffer.MatricesWeightsExtraKind
  80004. * @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
  80005. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  80006. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  80007. */
  80008. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  80009. /**
  80010. * Returns the mesh VertexBuffer object from the requested `kind`
  80011. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  80012. * - VertexBuffer.PositionKind
  80013. * - VertexBuffer.UVKind
  80014. * - VertexBuffer.UV2Kind
  80015. * - VertexBuffer.UV3Kind
  80016. * - VertexBuffer.UV4Kind
  80017. * - VertexBuffer.UV5Kind
  80018. * - VertexBuffer.UV6Kind
  80019. * - VertexBuffer.ColorKind
  80020. * - VertexBuffer.MatricesIndicesKind
  80021. * - VertexBuffer.MatricesIndicesExtraKind
  80022. * - VertexBuffer.MatricesWeightsKind
  80023. * - VertexBuffer.MatricesWeightsExtraKind
  80024. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  80025. */
  80026. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  80027. /**
  80028. * Tests if a specific vertex buffer is associated with this mesh
  80029. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  80030. * - VertexBuffer.PositionKind
  80031. * - VertexBuffer.UVKind
  80032. * - VertexBuffer.UV2Kind
  80033. * - VertexBuffer.UV3Kind
  80034. * - VertexBuffer.UV4Kind
  80035. * - VertexBuffer.UV5Kind
  80036. * - VertexBuffer.UV6Kind
  80037. * - VertexBuffer.ColorKind
  80038. * - VertexBuffer.MatricesIndicesKind
  80039. * - VertexBuffer.MatricesIndicesExtraKind
  80040. * - VertexBuffer.MatricesWeightsKind
  80041. * - VertexBuffer.MatricesWeightsExtraKind
  80042. * @returns a boolean
  80043. */
  80044. isVerticesDataPresent(kind: string): boolean;
  80045. /**
  80046. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  80047. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  80048. * - VertexBuffer.PositionKind
  80049. * - VertexBuffer.UVKind
  80050. * - VertexBuffer.UV2Kind
  80051. * - VertexBuffer.UV3Kind
  80052. * - VertexBuffer.UV4Kind
  80053. * - VertexBuffer.UV5Kind
  80054. * - VertexBuffer.UV6Kind
  80055. * - VertexBuffer.ColorKind
  80056. * - VertexBuffer.MatricesIndicesKind
  80057. * - VertexBuffer.MatricesIndicesExtraKind
  80058. * - VertexBuffer.MatricesWeightsKind
  80059. * - VertexBuffer.MatricesWeightsExtraKind
  80060. * @returns a boolean
  80061. */
  80062. isVertexBufferUpdatable(kind: string): boolean;
  80063. /**
  80064. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  80065. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  80066. * - VertexBuffer.PositionKind
  80067. * - VertexBuffer.UVKind
  80068. * - VertexBuffer.UV2Kind
  80069. * - VertexBuffer.UV3Kind
  80070. * - VertexBuffer.UV4Kind
  80071. * - VertexBuffer.UV5Kind
  80072. * - VertexBuffer.UV6Kind
  80073. * - VertexBuffer.ColorKind
  80074. * - VertexBuffer.MatricesIndicesKind
  80075. * - VertexBuffer.MatricesIndicesExtraKind
  80076. * - VertexBuffer.MatricesWeightsKind
  80077. * - VertexBuffer.MatricesWeightsExtraKind
  80078. * @returns an array of strings
  80079. */
  80080. getVerticesDataKinds(): string[];
  80081. /**
  80082. * Returns a positive integer : the total number of indices in this mesh geometry.
  80083. * @returns the numner of indices or zero if the mesh has no geometry.
  80084. */
  80085. getTotalIndices(): number;
  80086. /**
  80087. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  80088. * @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.
  80089. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  80090. * @returns the indices array or an empty array if the mesh has no geometry
  80091. */
  80092. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  80093. readonly isBlocked: boolean;
  80094. /**
  80095. * Determine if the current mesh is ready to be rendered
  80096. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  80097. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  80098. * @returns true if all associated assets are ready (material, textures, shaders)
  80099. */
  80100. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  80101. /**
  80102. * 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.
  80103. */
  80104. readonly areNormalsFrozen: boolean;
  80105. /**
  80106. * 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.
  80107. * @returns the current mesh
  80108. */
  80109. freezeNormals(): Mesh;
  80110. /**
  80111. * 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
  80112. * @returns the current mesh
  80113. */
  80114. unfreezeNormals(): Mesh;
  80115. /**
  80116. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  80117. */
  80118. overridenInstanceCount: number;
  80119. /** @hidden */
  80120. _preActivate(): Mesh;
  80121. /** @hidden */
  80122. _preActivateForIntermediateRendering(renderId: number): Mesh;
  80123. /** @hidden */
  80124. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  80125. /**
  80126. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  80127. * This means the mesh underlying bounding box and sphere are recomputed.
  80128. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  80129. * @returns the current mesh
  80130. */
  80131. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  80132. /** @hidden */
  80133. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  80134. /**
  80135. * This function will subdivide the mesh into multiple submeshes
  80136. * @param count defines the expected number of submeshes
  80137. */
  80138. subdivide(count: number): void;
  80139. /**
  80140. * Copy a FloatArray into a specific associated vertex buffer
  80141. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  80142. * - VertexBuffer.PositionKind
  80143. * - VertexBuffer.UVKind
  80144. * - VertexBuffer.UV2Kind
  80145. * - VertexBuffer.UV3Kind
  80146. * - VertexBuffer.UV4Kind
  80147. * - VertexBuffer.UV5Kind
  80148. * - VertexBuffer.UV6Kind
  80149. * - VertexBuffer.ColorKind
  80150. * - VertexBuffer.MatricesIndicesKind
  80151. * - VertexBuffer.MatricesIndicesExtraKind
  80152. * - VertexBuffer.MatricesWeightsKind
  80153. * - VertexBuffer.MatricesWeightsExtraKind
  80154. * @param data defines the data source
  80155. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  80156. * @param stride defines the data stride size (can be null)
  80157. * @returns the current mesh
  80158. */
  80159. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  80160. /**
  80161. * Flags an associated vertex buffer as updatable
  80162. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  80163. * - VertexBuffer.PositionKind
  80164. * - VertexBuffer.UVKind
  80165. * - VertexBuffer.UV2Kind
  80166. * - VertexBuffer.UV3Kind
  80167. * - VertexBuffer.UV4Kind
  80168. * - VertexBuffer.UV5Kind
  80169. * - VertexBuffer.UV6Kind
  80170. * - VertexBuffer.ColorKind
  80171. * - VertexBuffer.MatricesIndicesKind
  80172. * - VertexBuffer.MatricesIndicesExtraKind
  80173. * - VertexBuffer.MatricesWeightsKind
  80174. * - VertexBuffer.MatricesWeightsExtraKind
  80175. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  80176. */
  80177. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  80178. /**
  80179. * Sets the mesh global Vertex Buffer
  80180. * @param buffer defines the buffer to use
  80181. * @returns the current mesh
  80182. */
  80183. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  80184. /**
  80185. * Update a specific associated vertex buffer
  80186. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  80187. * - VertexBuffer.PositionKind
  80188. * - VertexBuffer.UVKind
  80189. * - VertexBuffer.UV2Kind
  80190. * - VertexBuffer.UV3Kind
  80191. * - VertexBuffer.UV4Kind
  80192. * - VertexBuffer.UV5Kind
  80193. * - VertexBuffer.UV6Kind
  80194. * - VertexBuffer.ColorKind
  80195. * - VertexBuffer.MatricesIndicesKind
  80196. * - VertexBuffer.MatricesIndicesExtraKind
  80197. * - VertexBuffer.MatricesWeightsKind
  80198. * - VertexBuffer.MatricesWeightsExtraKind
  80199. * @param data defines the data source
  80200. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  80201. * @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)
  80202. * @returns the current mesh
  80203. */
  80204. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  80205. /**
  80206. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  80207. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  80208. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  80209. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  80210. * @returns the current mesh
  80211. */
  80212. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  80213. /**
  80214. * Creates a un-shared specific occurence of the geometry for the mesh.
  80215. * @returns the current mesh
  80216. */
  80217. makeGeometryUnique(): Mesh;
  80218. /**
  80219. * Set the index buffer of this mesh
  80220. * @param indices defines the source data
  80221. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  80222. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  80223. * @returns the current mesh
  80224. */
  80225. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  80226. /**
  80227. * Update the current index buffer
  80228. * @param indices defines the source data
  80229. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  80230. * @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)
  80231. * @returns the current mesh
  80232. */
  80233. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): Mesh;
  80234. /**
  80235. * Invert the geometry to move from a right handed system to a left handed one.
  80236. * @returns the current mesh
  80237. */
  80238. toLeftHanded(): Mesh;
  80239. /** @hidden */
  80240. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  80241. /** @hidden */
  80242. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  80243. /**
  80244. * Registers for this mesh a javascript function called just before the rendering process
  80245. * @param func defines the function to call before rendering this mesh
  80246. * @returns the current mesh
  80247. */
  80248. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  80249. /**
  80250. * Disposes a previously registered javascript function called before the rendering
  80251. * @param func defines the function to remove
  80252. * @returns the current mesh
  80253. */
  80254. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  80255. /**
  80256. * Registers for this mesh a javascript function called just after the rendering is complete
  80257. * @param func defines the function to call after rendering this mesh
  80258. * @returns the current mesh
  80259. */
  80260. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  80261. /**
  80262. * Disposes a previously registered javascript function called after the rendering.
  80263. * @param func defines the function to remove
  80264. * @returns the current mesh
  80265. */
  80266. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  80267. /** @hidden */
  80268. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  80269. /** @hidden */
  80270. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  80271. /** @hidden */
  80272. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  80273. /**
  80274. * 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
  80275. * @param subMesh defines the subMesh to render
  80276. * @param enableAlphaMode defines if alpha mode can be changed
  80277. * @returns the current mesh
  80278. */
  80279. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  80280. private _onBeforeDraw;
  80281. /**
  80282. * Renormalize the mesh and patch it up if there are no weights
  80283. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  80284. * However in the case of zero weights then we set just a single influence to 1.
  80285. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  80286. */
  80287. cleanMatrixWeights(): void;
  80288. private normalizeSkinFourWeights;
  80289. private normalizeSkinWeightsAndExtra;
  80290. /**
  80291. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  80292. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  80293. * the user know there was an issue with importing the mesh
  80294. * @returns a validation object with skinned, valid and report string
  80295. */
  80296. validateSkinning(): {
  80297. skinned: boolean;
  80298. valid: boolean;
  80299. report: string;
  80300. };
  80301. /** @hidden */
  80302. _checkDelayState(): Mesh;
  80303. private _queueLoad;
  80304. /**
  80305. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  80306. * A mesh is in the frustum if its bounding box intersects the frustum
  80307. * @param frustumPlanes defines the frustum to test
  80308. * @returns true if the mesh is in the frustum planes
  80309. */
  80310. isInFrustum(frustumPlanes: Plane[]): boolean;
  80311. /**
  80312. * Sets the mesh material by the material or multiMaterial `id` property
  80313. * @param id is a string identifying the material or the multiMaterial
  80314. * @returns the current mesh
  80315. */
  80316. setMaterialByID(id: string): Mesh;
  80317. /**
  80318. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  80319. * @returns an array of IAnimatable
  80320. */
  80321. getAnimatables(): IAnimatable[];
  80322. /**
  80323. * Modifies the mesh geometry according to the passed transformation matrix.
  80324. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  80325. * The mesh normals are modified using the same transformation.
  80326. * Note that, under the hood, this method sets a new VertexBuffer each call.
  80327. * @param transform defines the transform matrix to use
  80328. * @see http://doc.babylonjs.com/resources/baking_transformations
  80329. * @returns the current mesh
  80330. */
  80331. bakeTransformIntoVertices(transform: Matrix): Mesh;
  80332. /**
  80333. * Modifies the mesh geometry according to its own current World Matrix.
  80334. * The mesh World Matrix is then reset.
  80335. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  80336. * Note that, under the hood, this method sets a new VertexBuffer each call.
  80337. * @see http://doc.babylonjs.com/resources/baking_transformations
  80338. * @returns the current mesh
  80339. */
  80340. bakeCurrentTransformIntoVertices(): Mesh;
  80341. /** @hidden */
  80342. readonly _positions: Nullable<Vector3[]>;
  80343. /** @hidden */
  80344. _resetPointsArrayCache(): Mesh;
  80345. /** @hidden */
  80346. _generatePointsArray(): boolean;
  80347. /**
  80348. * Returns a new Mesh object generated from the current mesh properties.
  80349. * This method must not get confused with createInstance()
  80350. * @param name is a string, the name given to the new mesh
  80351. * @param newParent can be any Node object (default `null`)
  80352. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  80353. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  80354. * @returns a new mesh
  80355. */
  80356. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  80357. /**
  80358. * Releases resources associated with this mesh.
  80359. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  80360. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  80361. */
  80362. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  80363. /**
  80364. * Modifies the mesh geometry according to a displacement map.
  80365. * 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.
  80366. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  80367. * @param url is a string, the URL from the image file is to be downloaded.
  80368. * @param minHeight is the lower limit of the displacement.
  80369. * @param maxHeight is the upper limit of the displacement.
  80370. * @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.
  80371. * @param uvOffset is an optional vector2 used to offset UV.
  80372. * @param uvScale is an optional vector2 used to scale UV.
  80373. * @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.
  80374. * @returns the Mesh.
  80375. */
  80376. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  80377. /**
  80378. * Modifies the mesh geometry according to a displacementMap buffer.
  80379. * 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.
  80380. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  80381. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  80382. * @param heightMapWidth is the width of the buffer image.
  80383. * @param heightMapHeight is the height of the buffer image.
  80384. * @param minHeight is the lower limit of the displacement.
  80385. * @param maxHeight is the upper limit of the displacement.
  80386. * @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.
  80387. * @param uvOffset is an optional vector2 used to offset UV.
  80388. * @param uvScale is an optional vector2 used to scale UV.
  80389. * @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.
  80390. * @returns the Mesh.
  80391. */
  80392. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  80393. /**
  80394. * Modify the mesh to get a flat shading rendering.
  80395. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  80396. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  80397. * @returns current mesh
  80398. */
  80399. convertToFlatShadedMesh(): Mesh;
  80400. /**
  80401. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  80402. * In other words, more vertices, no more indices and a single bigger VBO.
  80403. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  80404. * @returns current mesh
  80405. */
  80406. convertToUnIndexedMesh(): Mesh;
  80407. /**
  80408. * Inverses facet orientations.
  80409. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  80410. * @param flipNormals will also inverts the normals
  80411. * @returns current mesh
  80412. */
  80413. flipFaces(flipNormals?: boolean): Mesh;
  80414. /**
  80415. * Increase the number of facets and hence vertices in a mesh
  80416. * Vertex normals are interpolated from existing vertex normals
  80417. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  80418. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  80419. */
  80420. increaseVertices(numberPerEdge: number): void;
  80421. /**
  80422. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  80423. * This will undo any application of covertToFlatShadedMesh
  80424. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  80425. */
  80426. forceSharedVertices(): void;
  80427. /** @hidden */
  80428. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  80429. /** @hidden */
  80430. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  80431. /**
  80432. * Creates a new InstancedMesh object from the mesh model.
  80433. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  80434. * @param name defines the name of the new instance
  80435. * @returns a new InstancedMesh
  80436. */
  80437. createInstance(name: string): InstancedMesh;
  80438. /**
  80439. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  80440. * After this call, all the mesh instances have the same submeshes than the current mesh.
  80441. * @returns the current mesh
  80442. */
  80443. synchronizeInstances(): Mesh;
  80444. /**
  80445. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  80446. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  80447. * This should be used together with the simplification to avoid disappearing triangles.
  80448. * @param successCallback an optional success callback to be called after the optimization finished.
  80449. * @returns the current mesh
  80450. */
  80451. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  80452. /**
  80453. * Serialize current mesh
  80454. * @param serializationObject defines the object which will receive the serialization data
  80455. */
  80456. serialize(serializationObject: any): void;
  80457. /** @hidden */
  80458. _syncGeometryWithMorphTargetManager(): void;
  80459. /** @hidden */
  80460. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  80461. /**
  80462. * Returns a new Mesh object parsed from the source provided.
  80463. * @param parsedMesh is the source
  80464. * @param scene defines the hosting scene
  80465. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  80466. * @returns a new Mesh
  80467. */
  80468. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  80469. /**
  80470. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  80471. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  80472. * @param name defines the name of the mesh to create
  80473. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  80474. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  80475. * @param closePath creates a seam between the first and the last points of each path of the path array
  80476. * @param offset is taken in account only if the `pathArray` is containing a single path
  80477. * @param scene defines the hosting scene
  80478. * @param updatable defines if the mesh must be flagged as updatable
  80479. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  80480. * @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)
  80481. * @returns a new Mesh
  80482. */
  80483. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  80484. /**
  80485. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  80486. * @param name defines the name of the mesh to create
  80487. * @param radius sets the radius size (float) of the polygon (default 0.5)
  80488. * @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
  80489. * @param scene defines the hosting scene
  80490. * @param updatable defines if the mesh must be flagged as updatable
  80491. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  80492. * @returns a new Mesh
  80493. */
  80494. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  80495. /**
  80496. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  80497. * @param name defines the name of the mesh to create
  80498. * @param size sets the size (float) of each box side (default 1)
  80499. * @param scene defines the hosting scene
  80500. * @param updatable defines if the mesh must be flagged as updatable
  80501. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  80502. * @returns a new Mesh
  80503. */
  80504. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  80505. /**
  80506. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  80507. * @param name defines the name of the mesh to create
  80508. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  80509. * @param diameter sets the diameter size (float) of the sphere (default 1)
  80510. * @param scene defines the hosting scene
  80511. * @param updatable defines if the mesh must be flagged as updatable
  80512. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  80513. * @returns a new Mesh
  80514. */
  80515. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  80516. /**
  80517. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  80518. * @param name defines the name of the mesh to create
  80519. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  80520. * @param diameter sets the diameter size (float) of the sphere (default 1)
  80521. * @param scene defines the hosting scene
  80522. * @returns a new Mesh
  80523. */
  80524. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  80525. /**
  80526. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  80527. * @param name defines the name of the mesh to create
  80528. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  80529. * @param diameterTop set the top cap diameter (floats, default 1)
  80530. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  80531. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  80532. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  80533. * @param scene defines the hosting scene
  80534. * @param updatable defines if the mesh must be flagged as updatable
  80535. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  80536. * @returns a new Mesh
  80537. */
  80538. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  80539. /**
  80540. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  80541. * @param name defines the name of the mesh to create
  80542. * @param diameter sets the diameter size (float) of the torus (default 1)
  80543. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  80544. * @param tessellation sets the number of torus sides (postive integer, default 16)
  80545. * @param scene defines the hosting scene
  80546. * @param updatable defines if the mesh must be flagged as updatable
  80547. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  80548. * @returns a new Mesh
  80549. */
  80550. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  80551. /**
  80552. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  80553. * @param name defines the name of the mesh to create
  80554. * @param radius sets the global radius size (float) of the torus knot (default 2)
  80555. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  80556. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  80557. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  80558. * @param p the number of windings on X axis (positive integers, default 2)
  80559. * @param q the number of windings on Y axis (positive integers, default 3)
  80560. * @param scene defines the hosting scene
  80561. * @param updatable defines if the mesh must be flagged as updatable
  80562. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  80563. * @returns a new Mesh
  80564. */
  80565. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  80566. /**
  80567. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  80568. * @param name defines the name of the mesh to create
  80569. * @param points is an array successive Vector3
  80570. * @param scene defines the hosting scene
  80571. * @param updatable defines if the mesh must be flagged as updatable
  80572. * @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).
  80573. * @returns a new Mesh
  80574. */
  80575. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  80576. /**
  80577. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  80578. * @param name defines the name of the mesh to create
  80579. * @param points is an array successive Vector3
  80580. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  80581. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  80582. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  80583. * @param scene defines the hosting scene
  80584. * @param updatable defines if the mesh must be flagged as updatable
  80585. * @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)
  80586. * @returns a new Mesh
  80587. */
  80588. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  80589. /**
  80590. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  80591. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  80592. * 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.
  80593. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  80594. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  80595. * Remember you can only change the shape positions, not their number when updating a polygon.
  80596. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  80597. * @param name defines the name of the mesh to create
  80598. * @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
  80599. * @param scene defines the hosting scene
  80600. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  80601. * @param updatable defines if the mesh must be flagged as updatable
  80602. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  80603. * @param earcutInjection can be used to inject your own earcut reference
  80604. * @returns a new Mesh
  80605. */
  80606. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  80607. /**
  80608. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  80609. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  80610. * @param name defines the name of the mesh to create
  80611. * @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
  80612. * @param depth defines the height of extrusion
  80613. * @param scene defines the hosting scene
  80614. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  80615. * @param updatable defines if the mesh must be flagged as updatable
  80616. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  80617. * @param earcutInjection can be used to inject your own earcut reference
  80618. * @returns a new Mesh
  80619. */
  80620. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  80621. /**
  80622. * Creates an extruded shape mesh.
  80623. * 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
  80624. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  80625. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  80626. * @param name defines the name of the mesh to create
  80627. * @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
  80628. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  80629. * @param scale is the value to scale the shape
  80630. * @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
  80631. * @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
  80632. * @param scene defines the hosting scene
  80633. * @param updatable defines if the mesh must be flagged as updatable
  80634. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  80635. * @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)
  80636. * @returns a new Mesh
  80637. */
  80638. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  80639. /**
  80640. * Creates an custom extruded shape mesh.
  80641. * The custom extrusion is a parametric shape.
  80642. * It has no predefined shape. Its final shape will depend on the input parameters.
  80643. * Please consider using the same method from the MeshBuilder class instead
  80644. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  80645. * @param name defines the name of the mesh to create
  80646. * @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
  80647. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  80648. * @param scaleFunction is a custom Javascript function called on each path point
  80649. * @param rotationFunction is a custom Javascript function called on each path point
  80650. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  80651. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  80652. * @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
  80653. * @param scene defines the hosting scene
  80654. * @param updatable defines if the mesh must be flagged as updatable
  80655. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  80656. * @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)
  80657. * @returns a new Mesh
  80658. */
  80659. 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;
  80660. /**
  80661. * Creates lathe mesh.
  80662. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  80663. * Please consider using the same method from the MeshBuilder class instead
  80664. * @param name defines the name of the mesh to create
  80665. * @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
  80666. * @param radius is the radius value of the lathe
  80667. * @param tessellation is the side number of the lathe.
  80668. * @param scene defines the hosting scene
  80669. * @param updatable defines if the mesh must be flagged as updatable
  80670. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  80671. * @returns a new Mesh
  80672. */
  80673. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  80674. /**
  80675. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  80676. * @param name defines the name of the mesh to create
  80677. * @param size sets the size (float) of both sides of the plane at once (default 1)
  80678. * @param scene defines the hosting scene
  80679. * @param updatable defines if the mesh must be flagged as updatable
  80680. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  80681. * @returns a new Mesh
  80682. */
  80683. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  80684. /**
  80685. * Creates a ground mesh.
  80686. * Please consider using the same method from the MeshBuilder class instead
  80687. * @param name defines the name of the mesh to create
  80688. * @param width set the width of the ground
  80689. * @param height set the height of the ground
  80690. * @param subdivisions sets the number of subdivisions per side
  80691. * @param scene defines the hosting scene
  80692. * @param updatable defines if the mesh must be flagged as updatable
  80693. * @returns a new Mesh
  80694. */
  80695. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  80696. /**
  80697. * Creates a tiled ground mesh.
  80698. * Please consider using the same method from the MeshBuilder class instead
  80699. * @param name defines the name of the mesh to create
  80700. * @param xmin set the ground minimum X coordinate
  80701. * @param zmin set the ground minimum Y coordinate
  80702. * @param xmax set the ground maximum X coordinate
  80703. * @param zmax set the ground maximum Z coordinate
  80704. * @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
  80705. * @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
  80706. * @param scene defines the hosting scene
  80707. * @param updatable defines if the mesh must be flagged as updatable
  80708. * @returns a new Mesh
  80709. */
  80710. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  80711. w: number;
  80712. h: number;
  80713. }, precision: {
  80714. w: number;
  80715. h: number;
  80716. }, scene: Scene, updatable?: boolean): Mesh;
  80717. /**
  80718. * Creates a ground mesh from a height map.
  80719. * Please consider using the same method from the MeshBuilder class instead
  80720. * @see http://doc.babylonjs.com/babylon101/height_map
  80721. * @param name defines the name of the mesh to create
  80722. * @param url sets the URL of the height map image resource
  80723. * @param width set the ground width size
  80724. * @param height set the ground height size
  80725. * @param subdivisions sets the number of subdivision per side
  80726. * @param minHeight is the minimum altitude on the ground
  80727. * @param maxHeight is the maximum altitude on the ground
  80728. * @param scene defines the hosting scene
  80729. * @param updatable defines if the mesh must be flagged as updatable
  80730. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  80731. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  80732. * @returns a new Mesh
  80733. */
  80734. 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;
  80735. /**
  80736. * Creates a tube mesh.
  80737. * The tube is a parametric shape.
  80738. * It has no predefined shape. Its final shape will depend on the input parameters.
  80739. * Please consider using the same method from the MeshBuilder class instead
  80740. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  80741. * @param name defines the name of the mesh to create
  80742. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  80743. * @param radius sets the tube radius size
  80744. * @param tessellation is the number of sides on the tubular surface
  80745. * @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
  80746. * @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
  80747. * @param scene defines the hosting scene
  80748. * @param updatable defines if the mesh must be flagged as updatable
  80749. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  80750. * @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)
  80751. * @returns a new Mesh
  80752. */
  80753. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  80754. (i: number, distance: number): number;
  80755. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  80756. /**
  80757. * Creates a polyhedron mesh.
  80758. * Please consider using the same method from the MeshBuilder class instead.
  80759. * * 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
  80760. * * The parameter `size` (positive float, default 1) sets the polygon size
  80761. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  80762. * * 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`
  80763. * * 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
  80764. * * 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)`)
  80765. * * 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
  80766. * * 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
  80767. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  80768. * * If you create a double-sided mesh, you can choose what parts of 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
  80769. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  80770. * @param name defines the name of the mesh to create
  80771. * @param options defines the options used to create the mesh
  80772. * @param scene defines the hosting scene
  80773. * @returns a new Mesh
  80774. */
  80775. static CreatePolyhedron(name: string, options: {
  80776. type?: number;
  80777. size?: number;
  80778. sizeX?: number;
  80779. sizeY?: number;
  80780. sizeZ?: number;
  80781. custom?: any;
  80782. faceUV?: Vector4[];
  80783. faceColors?: Color4[];
  80784. updatable?: boolean;
  80785. sideOrientation?: number;
  80786. }, scene: Scene): Mesh;
  80787. /**
  80788. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  80789. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  80790. * * 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`)
  80791. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  80792. * * 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
  80793. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  80794. * * If you create a double-sided mesh, you can choose what parts of 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
  80795. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  80796. * @param name defines the name of the mesh
  80797. * @param options defines the options used to create the mesh
  80798. * @param scene defines the hosting scene
  80799. * @returns a new Mesh
  80800. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  80801. */
  80802. static CreateIcoSphere(name: string, options: {
  80803. radius?: number;
  80804. flat?: boolean;
  80805. subdivisions?: number;
  80806. sideOrientation?: number;
  80807. updatable?: boolean;
  80808. }, scene: Scene): Mesh;
  80809. /**
  80810. * Creates a decal mesh.
  80811. * Please consider using the same method from the MeshBuilder class instead.
  80812. * A decal is a mesh usually applied as a model onto the surface of another mesh
  80813. * @param name defines the name of the mesh
  80814. * @param sourceMesh defines the mesh receiving the decal
  80815. * @param position sets the position of the decal in world coordinates
  80816. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  80817. * @param size sets the decal scaling
  80818. * @param angle sets the angle to rotate the decal
  80819. * @returns a new Mesh
  80820. */
  80821. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  80822. /**
  80823. * Prepare internal position array for software CPU skinning
  80824. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  80825. */
  80826. setPositionsForCPUSkinning(): Float32Array;
  80827. /**
  80828. * Prepare internal normal array for software CPU skinning
  80829. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  80830. */
  80831. setNormalsForCPUSkinning(): Float32Array;
  80832. /**
  80833. * Updates the vertex buffer by applying transformation from the bones
  80834. * @param skeleton defines the skeleton to apply to current mesh
  80835. * @returns the current mesh
  80836. */
  80837. applySkeleton(skeleton: Skeleton): Mesh;
  80838. /**
  80839. * 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
  80840. * @param meshes defines the list of meshes to scan
  80841. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  80842. */
  80843. static MinMax(meshes: AbstractMesh[]): {
  80844. min: Vector3;
  80845. max: Vector3;
  80846. };
  80847. /**
  80848. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  80849. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  80850. * @returns a vector3
  80851. */
  80852. static Center(meshesOrMinMaxVector: {
  80853. min: Vector3;
  80854. max: Vector3;
  80855. } | AbstractMesh[]): Vector3;
  80856. /**
  80857. * Merge the array of meshes into a single mesh for performance reasons.
  80858. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  80859. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  80860. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  80861. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  80862. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  80863. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  80864. * @returns a new mesh
  80865. */
  80866. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  80867. /** @hidden */
  80868. addInstance(instance: InstancedMesh): void;
  80869. /** @hidden */
  80870. removeInstance(instance: InstancedMesh): void;
  80871. }
  80872. }
  80873. declare module BABYLON {
  80874. /**
  80875. * Base class for the main features of a material in Babylon.js
  80876. */
  80877. export class Material implements IAnimatable {
  80878. /**
  80879. * Returns the triangle fill mode
  80880. */
  80881. static readonly TriangleFillMode: number;
  80882. /**
  80883. * Returns the wireframe mode
  80884. */
  80885. static readonly WireFrameFillMode: number;
  80886. /**
  80887. * Returns the point fill mode
  80888. */
  80889. static readonly PointFillMode: number;
  80890. /**
  80891. * Returns the point list draw mode
  80892. */
  80893. static readonly PointListDrawMode: number;
  80894. /**
  80895. * Returns the line list draw mode
  80896. */
  80897. static readonly LineListDrawMode: number;
  80898. /**
  80899. * Returns the line loop draw mode
  80900. */
  80901. static readonly LineLoopDrawMode: number;
  80902. /**
  80903. * Returns the line strip draw mode
  80904. */
  80905. static readonly LineStripDrawMode: number;
  80906. /**
  80907. * Returns the triangle strip draw mode
  80908. */
  80909. static readonly TriangleStripDrawMode: number;
  80910. /**
  80911. * Returns the triangle fan draw mode
  80912. */
  80913. static readonly TriangleFanDrawMode: number;
  80914. /**
  80915. * Stores the clock-wise side orientation
  80916. */
  80917. static readonly ClockWiseSideOrientation: number;
  80918. /**
  80919. * Stores the counter clock-wise side orientation
  80920. */
  80921. static readonly CounterClockWiseSideOrientation: number;
  80922. /**
  80923. * The dirty texture flag value
  80924. */
  80925. static readonly TextureDirtyFlag: number;
  80926. /**
  80927. * The dirty light flag value
  80928. */
  80929. static readonly LightDirtyFlag: number;
  80930. /**
  80931. * The dirty fresnel flag value
  80932. */
  80933. static readonly FresnelDirtyFlag: number;
  80934. /**
  80935. * The dirty attribute flag value
  80936. */
  80937. static readonly AttributesDirtyFlag: number;
  80938. /**
  80939. * The dirty misc flag value
  80940. */
  80941. static readonly MiscDirtyFlag: number;
  80942. /**
  80943. * The all dirty flag value
  80944. */
  80945. static readonly AllDirtyFlag: number;
  80946. /**
  80947. * The ID of the material
  80948. */
  80949. id: string;
  80950. /**
  80951. * Gets or sets the unique id of the material
  80952. */
  80953. uniqueId: number;
  80954. /**
  80955. * The name of the material
  80956. */
  80957. name: string;
  80958. /**
  80959. * Gets or sets user defined metadata
  80960. */
  80961. metadata: any;
  80962. /**
  80963. * For internal use only. Please do not use.
  80964. */
  80965. reservedDataStore: any;
  80966. /**
  80967. * Specifies if the ready state should be checked on each call
  80968. */
  80969. checkReadyOnEveryCall: boolean;
  80970. /**
  80971. * Specifies if the ready state should be checked once
  80972. */
  80973. checkReadyOnlyOnce: boolean;
  80974. /**
  80975. * The state of the material
  80976. */
  80977. state: string;
  80978. /**
  80979. * The alpha value of the material
  80980. */
  80981. protected _alpha: number;
  80982. /**
  80983. * List of inspectable custom properties (used by the Inspector)
  80984. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  80985. */
  80986. inspectableCustomProperties: IInspectable[];
  80987. /**
  80988. * Sets the alpha value of the material
  80989. */
  80990. /**
  80991. * Gets the alpha value of the material
  80992. */
  80993. alpha: number;
  80994. /**
  80995. * Specifies if back face culling is enabled
  80996. */
  80997. protected _backFaceCulling: boolean;
  80998. /**
  80999. * Sets the back-face culling state
  81000. */
  81001. /**
  81002. * Gets the back-face culling state
  81003. */
  81004. backFaceCulling: boolean;
  81005. /**
  81006. * Stores the value for side orientation
  81007. */
  81008. sideOrientation: number;
  81009. /**
  81010. * Callback triggered when the material is compiled
  81011. */
  81012. onCompiled: (effect: Effect) => void;
  81013. /**
  81014. * Callback triggered when an error occurs
  81015. */
  81016. onError: (effect: Effect, errors: string) => void;
  81017. /**
  81018. * Callback triggered to get the render target textures
  81019. */
  81020. getRenderTargetTextures: () => SmartArray<RenderTargetTexture>;
  81021. /**
  81022. * Gets a boolean indicating that current material needs to register RTT
  81023. */
  81024. readonly hasRenderTargetTextures: boolean;
  81025. /**
  81026. * Specifies if the material should be serialized
  81027. */
  81028. doNotSerialize: boolean;
  81029. /**
  81030. * @hidden
  81031. */
  81032. _storeEffectOnSubMeshes: boolean;
  81033. /**
  81034. * Stores the animations for the material
  81035. */
  81036. animations: Array<Animation>;
  81037. /**
  81038. * An event triggered when the material is disposed
  81039. */
  81040. onDisposeObservable: Observable<Material>;
  81041. /**
  81042. * An observer which watches for dispose events
  81043. */
  81044. private _onDisposeObserver;
  81045. private _onUnBindObservable;
  81046. /**
  81047. * Called during a dispose event
  81048. */
  81049. onDispose: () => void;
  81050. private _onBindObservable;
  81051. /**
  81052. * An event triggered when the material is bound
  81053. */
  81054. readonly onBindObservable: Observable<AbstractMesh>;
  81055. /**
  81056. * An observer which watches for bind events
  81057. */
  81058. private _onBindObserver;
  81059. /**
  81060. * Called during a bind event
  81061. */
  81062. onBind: (Mesh: AbstractMesh) => void;
  81063. /**
  81064. * An event triggered when the material is unbound
  81065. */
  81066. readonly onUnBindObservable: Observable<Material>;
  81067. /**
  81068. * Stores the value of the alpha mode
  81069. */
  81070. private _alphaMode;
  81071. /**
  81072. * Sets the value of the alpha mode.
  81073. *
  81074. * | Value | Type | Description |
  81075. * | --- | --- | --- |
  81076. * | 0 | ALPHA_DISABLE | |
  81077. * | 1 | ALPHA_ADD | |
  81078. * | 2 | ALPHA_COMBINE | |
  81079. * | 3 | ALPHA_SUBTRACT | |
  81080. * | 4 | ALPHA_MULTIPLY | |
  81081. * | 5 | ALPHA_MAXIMIZED | |
  81082. * | 6 | ALPHA_ONEONE | |
  81083. * | 7 | ALPHA_PREMULTIPLIED | |
  81084. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  81085. * | 9 | ALPHA_INTERPOLATE | |
  81086. * | 10 | ALPHA_SCREENMODE | |
  81087. *
  81088. */
  81089. /**
  81090. * Gets the value of the alpha mode
  81091. */
  81092. alphaMode: number;
  81093. /**
  81094. * Stores the state of the need depth pre-pass value
  81095. */
  81096. private _needDepthPrePass;
  81097. /**
  81098. * Sets the need depth pre-pass value
  81099. */
  81100. /**
  81101. * Gets the depth pre-pass value
  81102. */
  81103. needDepthPrePass: boolean;
  81104. /**
  81105. * Specifies if depth writing should be disabled
  81106. */
  81107. disableDepthWrite: boolean;
  81108. /**
  81109. * Specifies if depth writing should be forced
  81110. */
  81111. forceDepthWrite: boolean;
  81112. /**
  81113. * Specifies if there should be a separate pass for culling
  81114. */
  81115. separateCullingPass: boolean;
  81116. /**
  81117. * Stores the state specifing if fog should be enabled
  81118. */
  81119. private _fogEnabled;
  81120. /**
  81121. * Sets the state for enabling fog
  81122. */
  81123. /**
  81124. * Gets the value of the fog enabled state
  81125. */
  81126. fogEnabled: boolean;
  81127. /**
  81128. * Stores the size of points
  81129. */
  81130. pointSize: number;
  81131. /**
  81132. * Stores the z offset value
  81133. */
  81134. zOffset: number;
  81135. /**
  81136. * Gets a value specifying if wireframe mode is enabled
  81137. */
  81138. /**
  81139. * Sets the state of wireframe mode
  81140. */
  81141. wireframe: boolean;
  81142. /**
  81143. * Gets the value specifying if point clouds are enabled
  81144. */
  81145. /**
  81146. * Sets the state of point cloud mode
  81147. */
  81148. pointsCloud: boolean;
  81149. /**
  81150. * Gets the material fill mode
  81151. */
  81152. /**
  81153. * Sets the material fill mode
  81154. */
  81155. fillMode: number;
  81156. /**
  81157. * @hidden
  81158. * Stores the effects for the material
  81159. */
  81160. _effect: Nullable<Effect>;
  81161. /**
  81162. * @hidden
  81163. * Specifies if the material was previously ready
  81164. */
  81165. _wasPreviouslyReady: boolean;
  81166. /**
  81167. * Specifies if uniform buffers should be used
  81168. */
  81169. private _useUBO;
  81170. /**
  81171. * Stores a reference to the scene
  81172. */
  81173. private _scene;
  81174. /**
  81175. * Stores the fill mode state
  81176. */
  81177. private _fillMode;
  81178. /**
  81179. * Specifies if the depth write state should be cached
  81180. */
  81181. private _cachedDepthWriteState;
  81182. /**
  81183. * Stores the uniform buffer
  81184. */
  81185. protected _uniformBuffer: UniformBuffer;
  81186. /** @hidden */
  81187. _indexInSceneMaterialArray: number;
  81188. /** @hidden */
  81189. meshMap: Nullable<{
  81190. [id: string]: AbstractMesh | undefined;
  81191. }>;
  81192. /**
  81193. * Creates a material instance
  81194. * @param name defines the name of the material
  81195. * @param scene defines the scene to reference
  81196. * @param doNotAdd specifies if the material should be added to the scene
  81197. */
  81198. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  81199. /**
  81200. * Returns a string representation of the current material
  81201. * @param fullDetails defines a boolean indicating which levels of logging is desired
  81202. * @returns a string with material information
  81203. */
  81204. toString(fullDetails?: boolean): string;
  81205. /**
  81206. * Gets the class name of the material
  81207. * @returns a string with the class name of the material
  81208. */
  81209. getClassName(): string;
  81210. /**
  81211. * Specifies if updates for the material been locked
  81212. */
  81213. readonly isFrozen: boolean;
  81214. /**
  81215. * Locks updates for the material
  81216. */
  81217. freeze(): void;
  81218. /**
  81219. * Unlocks updates for the material
  81220. */
  81221. unfreeze(): void;
  81222. /**
  81223. * Specifies if the material is ready to be used
  81224. * @param mesh defines the mesh to check
  81225. * @param useInstances specifies if instances should be used
  81226. * @returns a boolean indicating if the material is ready to be used
  81227. */
  81228. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  81229. /**
  81230. * Specifies that the submesh is ready to be used
  81231. * @param mesh defines the mesh to check
  81232. * @param subMesh defines which submesh to check
  81233. * @param useInstances specifies that instances should be used
  81234. * @returns a boolean indicating that the submesh is ready or not
  81235. */
  81236. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  81237. /**
  81238. * Returns the material effect
  81239. * @returns the effect associated with the material
  81240. */
  81241. getEffect(): Nullable<Effect>;
  81242. /**
  81243. * Returns the current scene
  81244. * @returns a Scene
  81245. */
  81246. getScene(): Scene;
  81247. /**
  81248. * Specifies if the material will require alpha blending
  81249. * @returns a boolean specifying if alpha blending is needed
  81250. */
  81251. needAlphaBlending(): boolean;
  81252. /**
  81253. * Specifies if the mesh will require alpha blending
  81254. * @param mesh defines the mesh to check
  81255. * @returns a boolean specifying if alpha blending is needed for the mesh
  81256. */
  81257. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  81258. /**
  81259. * Specifies if this material should be rendered in alpha test mode
  81260. * @returns a boolean specifying if an alpha test is needed.
  81261. */
  81262. needAlphaTesting(): boolean;
  81263. /**
  81264. * Gets the texture used for the alpha test
  81265. * @returns the texture to use for alpha testing
  81266. */
  81267. getAlphaTestTexture(): Nullable<BaseTexture>;
  81268. /**
  81269. * Marks the material to indicate that it needs to be re-calculated
  81270. */
  81271. markDirty(): void;
  81272. /** @hidden */
  81273. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  81274. /**
  81275. * Binds the material to the mesh
  81276. * @param world defines the world transformation matrix
  81277. * @param mesh defines the mesh to bind the material to
  81278. */
  81279. bind(world: Matrix, mesh?: Mesh): void;
  81280. /**
  81281. * Binds the submesh to the material
  81282. * @param world defines the world transformation matrix
  81283. * @param mesh defines the mesh containing the submesh
  81284. * @param subMesh defines the submesh to bind the material to
  81285. */
  81286. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  81287. /**
  81288. * Binds the world matrix to the material
  81289. * @param world defines the world transformation matrix
  81290. */
  81291. bindOnlyWorldMatrix(world: Matrix): void;
  81292. /**
  81293. * Binds the scene's uniform buffer to the effect.
  81294. * @param effect defines the effect to bind to the scene uniform buffer
  81295. * @param sceneUbo defines the uniform buffer storing scene data
  81296. */
  81297. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  81298. /**
  81299. * Binds the view matrix to the effect
  81300. * @param effect defines the effect to bind the view matrix to
  81301. */
  81302. bindView(effect: Effect): void;
  81303. /**
  81304. * Binds the view projection matrix to the effect
  81305. * @param effect defines the effect to bind the view projection matrix to
  81306. */
  81307. bindViewProjection(effect: Effect): void;
  81308. /**
  81309. * Specifies if material alpha testing should be turned on for the mesh
  81310. * @param mesh defines the mesh to check
  81311. */
  81312. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  81313. /**
  81314. * Processes to execute after binding the material to a mesh
  81315. * @param mesh defines the rendered mesh
  81316. */
  81317. protected _afterBind(mesh?: Mesh): void;
  81318. /**
  81319. * Unbinds the material from the mesh
  81320. */
  81321. unbind(): void;
  81322. /**
  81323. * Gets the active textures from the material
  81324. * @returns an array of textures
  81325. */
  81326. getActiveTextures(): BaseTexture[];
  81327. /**
  81328. * Specifies if the material uses a texture
  81329. * @param texture defines the texture to check against the material
  81330. * @returns a boolean specifying if the material uses the texture
  81331. */
  81332. hasTexture(texture: BaseTexture): boolean;
  81333. /**
  81334. * Makes a duplicate of the material, and gives it a new name
  81335. * @param name defines the new name for the duplicated material
  81336. * @returns the cloned material
  81337. */
  81338. clone(name: string): Nullable<Material>;
  81339. /**
  81340. * Gets the meshes bound to the material
  81341. * @returns an array of meshes bound to the material
  81342. */
  81343. getBindedMeshes(): AbstractMesh[];
  81344. /**
  81345. * Force shader compilation
  81346. * @param mesh defines the mesh associated with this material
  81347. * @param onCompiled defines a function to execute once the material is compiled
  81348. * @param options defines the options to configure the compilation
  81349. */
  81350. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  81351. clipPlane: boolean;
  81352. }>): void;
  81353. /**
  81354. * Force shader compilation
  81355. * @param mesh defines the mesh that will use this material
  81356. * @param options defines additional options for compiling the shaders
  81357. * @returns a promise that resolves when the compilation completes
  81358. */
  81359. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  81360. clipPlane: boolean;
  81361. }>): Promise<void>;
  81362. private static readonly _ImageProcessingDirtyCallBack;
  81363. private static readonly _TextureDirtyCallBack;
  81364. private static readonly _FresnelDirtyCallBack;
  81365. private static readonly _MiscDirtyCallBack;
  81366. private static readonly _LightsDirtyCallBack;
  81367. private static readonly _AttributeDirtyCallBack;
  81368. private static _FresnelAndMiscDirtyCallBack;
  81369. private static _TextureAndMiscDirtyCallBack;
  81370. private static readonly _DirtyCallbackArray;
  81371. private static readonly _RunDirtyCallBacks;
  81372. /**
  81373. * Marks a define in the material to indicate that it needs to be re-computed
  81374. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  81375. */
  81376. markAsDirty(flag: number): void;
  81377. /**
  81378. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  81379. * @param func defines a function which checks material defines against the submeshes
  81380. */
  81381. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  81382. /**
  81383. * Indicates that image processing needs to be re-calculated for all submeshes
  81384. */
  81385. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  81386. /**
  81387. * Indicates that textures need to be re-calculated for all submeshes
  81388. */
  81389. protected _markAllSubMeshesAsTexturesDirty(): void;
  81390. /**
  81391. * Indicates that fresnel needs to be re-calculated for all submeshes
  81392. */
  81393. protected _markAllSubMeshesAsFresnelDirty(): void;
  81394. /**
  81395. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  81396. */
  81397. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  81398. /**
  81399. * Indicates that lights need to be re-calculated for all submeshes
  81400. */
  81401. protected _markAllSubMeshesAsLightsDirty(): void;
  81402. /**
  81403. * Indicates that attributes need to be re-calculated for all submeshes
  81404. */
  81405. protected _markAllSubMeshesAsAttributesDirty(): void;
  81406. /**
  81407. * Indicates that misc needs to be re-calculated for all submeshes
  81408. */
  81409. protected _markAllSubMeshesAsMiscDirty(): void;
  81410. /**
  81411. * Indicates that textures and misc need to be re-calculated for all submeshes
  81412. */
  81413. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  81414. /**
  81415. * Disposes the material
  81416. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  81417. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  81418. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  81419. */
  81420. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  81421. /** @hidden */
  81422. private releaseVertexArrayObject;
  81423. /**
  81424. * Serializes this material
  81425. * @returns the serialized material object
  81426. */
  81427. serialize(): any;
  81428. /**
  81429. * Creates a material from parsed material data
  81430. * @param parsedMaterial defines parsed material data
  81431. * @param scene defines the hosting scene
  81432. * @param rootUrl defines the root URL to use to load textures
  81433. * @returns a new material
  81434. */
  81435. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  81436. }
  81437. }
  81438. declare module BABYLON {
  81439. /**
  81440. * Base class for submeshes
  81441. */
  81442. export class BaseSubMesh {
  81443. /** @hidden */
  81444. _materialDefines: Nullable<MaterialDefines>;
  81445. /** @hidden */
  81446. _materialEffect: Nullable<Effect>;
  81447. /**
  81448. * Gets associated effect
  81449. */
  81450. readonly effect: Nullable<Effect>;
  81451. /**
  81452. * Sets associated effect (effect used to render this submesh)
  81453. * @param effect defines the effect to associate with
  81454. * @param defines defines the set of defines used to compile this effect
  81455. */
  81456. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  81457. }
  81458. /**
  81459. * Defines a subdivision inside a mesh
  81460. */
  81461. export class SubMesh extends BaseSubMesh implements ICullable {
  81462. /** the material index to use */
  81463. materialIndex: number;
  81464. /** vertex index start */
  81465. verticesStart: number;
  81466. /** vertices count */
  81467. verticesCount: number;
  81468. /** index start */
  81469. indexStart: number;
  81470. /** indices count */
  81471. indexCount: number;
  81472. /** @hidden */
  81473. _linesIndexCount: number;
  81474. private _mesh;
  81475. private _renderingMesh;
  81476. private _boundingInfo;
  81477. private _linesIndexBuffer;
  81478. /** @hidden */
  81479. _lastColliderWorldVertices: Nullable<Vector3[]>;
  81480. /** @hidden */
  81481. _trianglePlanes: Plane[];
  81482. /** @hidden */
  81483. _lastColliderTransformMatrix: Matrix;
  81484. /** @hidden */
  81485. _renderId: number;
  81486. /** @hidden */
  81487. _alphaIndex: number;
  81488. /** @hidden */
  81489. _distanceToCamera: number;
  81490. /** @hidden */
  81491. _id: number;
  81492. private _currentMaterial;
  81493. /**
  81494. * Add a new submesh to a mesh
  81495. * @param materialIndex defines the material index to use
  81496. * @param verticesStart defines vertex index start
  81497. * @param verticesCount defines vertices count
  81498. * @param indexStart defines index start
  81499. * @param indexCount defines indices count
  81500. * @param mesh defines the parent mesh
  81501. * @param renderingMesh defines an optional rendering mesh
  81502. * @param createBoundingBox defines if bounding box should be created for this submesh
  81503. * @returns the new submesh
  81504. */
  81505. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  81506. /**
  81507. * Creates a new submesh
  81508. * @param materialIndex defines the material index to use
  81509. * @param verticesStart defines vertex index start
  81510. * @param verticesCount defines vertices count
  81511. * @param indexStart defines index start
  81512. * @param indexCount defines indices count
  81513. * @param mesh defines the parent mesh
  81514. * @param renderingMesh defines an optional rendering mesh
  81515. * @param createBoundingBox defines if bounding box should be created for this submesh
  81516. */
  81517. constructor(
  81518. /** the material index to use */
  81519. materialIndex: number,
  81520. /** vertex index start */
  81521. verticesStart: number,
  81522. /** vertices count */
  81523. verticesCount: number,
  81524. /** index start */
  81525. indexStart: number,
  81526. /** indices count */
  81527. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  81528. /**
  81529. * Returns true if this submesh covers the entire parent mesh
  81530. * @ignorenaming
  81531. */
  81532. readonly IsGlobal: boolean;
  81533. /**
  81534. * Returns the submesh BoudingInfo object
  81535. * @returns current bounding info (or mesh's one if the submesh is global)
  81536. */
  81537. getBoundingInfo(): BoundingInfo;
  81538. /**
  81539. * Sets the submesh BoundingInfo
  81540. * @param boundingInfo defines the new bounding info to use
  81541. * @returns the SubMesh
  81542. */
  81543. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  81544. /**
  81545. * Returns the mesh of the current submesh
  81546. * @return the parent mesh
  81547. */
  81548. getMesh(): AbstractMesh;
  81549. /**
  81550. * Returns the rendering mesh of the submesh
  81551. * @returns the rendering mesh (could be different from parent mesh)
  81552. */
  81553. getRenderingMesh(): Mesh;
  81554. /**
  81555. * Returns the submesh material
  81556. * @returns null or the current material
  81557. */
  81558. getMaterial(): Nullable<Material>;
  81559. /**
  81560. * Sets a new updated BoundingInfo object to the submesh
  81561. * @returns the SubMesh
  81562. */
  81563. refreshBoundingInfo(): SubMesh;
  81564. /** @hidden */
  81565. _checkCollision(collider: Collider): boolean;
  81566. /**
  81567. * Updates the submesh BoundingInfo
  81568. * @param world defines the world matrix to use to update the bounding info
  81569. * @returns the submesh
  81570. */
  81571. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  81572. /**
  81573. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  81574. * @param frustumPlanes defines the frustum planes
  81575. * @returns true if the submesh is intersecting with the frustum
  81576. */
  81577. isInFrustum(frustumPlanes: Plane[]): boolean;
  81578. /**
  81579. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  81580. * @param frustumPlanes defines the frustum planes
  81581. * @returns true if the submesh is inside the frustum
  81582. */
  81583. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  81584. /**
  81585. * Renders the submesh
  81586. * @param enableAlphaMode defines if alpha needs to be used
  81587. * @returns the submesh
  81588. */
  81589. render(enableAlphaMode: boolean): SubMesh;
  81590. /**
  81591. * @hidden
  81592. */
  81593. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): WebGLBuffer;
  81594. /**
  81595. * Checks if the submesh intersects with a ray
  81596. * @param ray defines the ray to test
  81597. * @returns true is the passed ray intersects the submesh bounding box
  81598. */
  81599. canIntersects(ray: Ray): boolean;
  81600. /**
  81601. * Intersects current submesh with a ray
  81602. * @param ray defines the ray to test
  81603. * @param positions defines mesh's positions array
  81604. * @param indices defines mesh's indices array
  81605. * @param fastCheck defines if only bounding info should be used
  81606. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  81607. * @returns intersection info or null if no intersection
  81608. */
  81609. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  81610. /** @hidden */
  81611. private _intersectLines;
  81612. /** @hidden */
  81613. private _intersectTriangles;
  81614. /** @hidden */
  81615. _rebuild(): void;
  81616. /**
  81617. * Creates a new submesh from the passed mesh
  81618. * @param newMesh defines the new hosting mesh
  81619. * @param newRenderingMesh defines an optional rendering mesh
  81620. * @returns the new submesh
  81621. */
  81622. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  81623. /**
  81624. * Release associated resources
  81625. */
  81626. dispose(): void;
  81627. /**
  81628. * Gets the class name
  81629. * @returns the string "SubMesh".
  81630. */
  81631. getClassName(): string;
  81632. /**
  81633. * Creates a new submesh from indices data
  81634. * @param materialIndex the index of the main mesh material
  81635. * @param startIndex the index where to start the copy in the mesh indices array
  81636. * @param indexCount the number of indices to copy then from the startIndex
  81637. * @param mesh the main mesh to create the submesh from
  81638. * @param renderingMesh the optional rendering mesh
  81639. * @returns a new submesh
  81640. */
  81641. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  81642. }
  81643. }
  81644. declare module BABYLON {
  81645. /**
  81646. * Class used to store geometry data (vertex buffers + index buffer)
  81647. */
  81648. export class Geometry implements IGetSetVerticesData {
  81649. /**
  81650. * Gets or sets the ID of the geometry
  81651. */
  81652. id: string;
  81653. /**
  81654. * Gets or sets the unique ID of the geometry
  81655. */
  81656. uniqueId: number;
  81657. /**
  81658. * Gets the delay loading state of the geometry (none by default which means not delayed)
  81659. */
  81660. delayLoadState: number;
  81661. /**
  81662. * Gets the file containing the data to load when running in delay load state
  81663. */
  81664. delayLoadingFile: Nullable<string>;
  81665. /**
  81666. * Callback called when the geometry is updated
  81667. */
  81668. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  81669. private _scene;
  81670. private _engine;
  81671. private _meshes;
  81672. private _totalVertices;
  81673. /** @hidden */
  81674. _indices: IndicesArray;
  81675. /** @hidden */
  81676. _vertexBuffers: {
  81677. [key: string]: VertexBuffer;
  81678. };
  81679. private _isDisposed;
  81680. private _extend;
  81681. private _boundingBias;
  81682. /** @hidden */
  81683. _delayInfo: Array<string>;
  81684. private _indexBuffer;
  81685. private _indexBufferIsUpdatable;
  81686. /** @hidden */
  81687. _boundingInfo: Nullable<BoundingInfo>;
  81688. /** @hidden */
  81689. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  81690. /** @hidden */
  81691. _softwareSkinningFrameId: number;
  81692. private _vertexArrayObjects;
  81693. private _updatable;
  81694. /** @hidden */
  81695. _positions: Nullable<Vector3[]>;
  81696. /**
  81697. * 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
  81698. */
  81699. /**
  81700. * 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
  81701. */
  81702. boundingBias: Vector2;
  81703. /**
  81704. * Static function used to attach a new empty geometry to a mesh
  81705. * @param mesh defines the mesh to attach the geometry to
  81706. * @returns the new Geometry
  81707. */
  81708. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  81709. /**
  81710. * Creates a new geometry
  81711. * @param id defines the unique ID
  81712. * @param scene defines the hosting scene
  81713. * @param vertexData defines the VertexData used to get geometry data
  81714. * @param updatable defines if geometry must be updatable (false by default)
  81715. * @param mesh defines the mesh that will be associated with the geometry
  81716. */
  81717. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  81718. /**
  81719. * Gets the current extend of the geometry
  81720. */
  81721. readonly extend: {
  81722. minimum: Vector3;
  81723. maximum: Vector3;
  81724. };
  81725. /**
  81726. * Gets the hosting scene
  81727. * @returns the hosting Scene
  81728. */
  81729. getScene(): Scene;
  81730. /**
  81731. * Gets the hosting engine
  81732. * @returns the hosting Engine
  81733. */
  81734. getEngine(): Engine;
  81735. /**
  81736. * Defines if the geometry is ready to use
  81737. * @returns true if the geometry is ready to be used
  81738. */
  81739. isReady(): boolean;
  81740. /**
  81741. * Gets a value indicating that the geometry should not be serialized
  81742. */
  81743. readonly doNotSerialize: boolean;
  81744. /** @hidden */
  81745. _rebuild(): void;
  81746. /**
  81747. * Affects all geometry data in one call
  81748. * @param vertexData defines the geometry data
  81749. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  81750. */
  81751. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  81752. /**
  81753. * Set specific vertex data
  81754. * @param kind defines the data kind (Position, normal, etc...)
  81755. * @param data defines the vertex data to use
  81756. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  81757. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  81758. */
  81759. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  81760. /**
  81761. * Removes a specific vertex data
  81762. * @param kind defines the data kind (Position, normal, etc...)
  81763. */
  81764. removeVerticesData(kind: string): void;
  81765. /**
  81766. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  81767. * @param buffer defines the vertex buffer to use
  81768. * @param totalVertices defines the total number of vertices for position kind (could be null)
  81769. */
  81770. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  81771. /**
  81772. * Update a specific vertex buffer
  81773. * This function will directly update the underlying WebGLBuffer according to the passed numeric array or Float32Array
  81774. * It will do nothing if the buffer is not updatable
  81775. * @param kind defines the data kind (Position, normal, etc...)
  81776. * @param data defines the data to use
  81777. * @param offset defines the offset in the target buffer where to store the data
  81778. * @param useBytes set to true if the offset is in bytes
  81779. */
  81780. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  81781. /**
  81782. * Update a specific vertex buffer
  81783. * This function will create a new buffer if the current one is not updatable
  81784. * @param kind defines the data kind (Position, normal, etc...)
  81785. * @param data defines the data to use
  81786. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  81787. */
  81788. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  81789. private _updateBoundingInfo;
  81790. /** @hidden */
  81791. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<WebGLBuffer>): void;
  81792. /**
  81793. * Gets total number of vertices
  81794. * @returns the total number of vertices
  81795. */
  81796. getTotalVertices(): number;
  81797. /**
  81798. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  81799. * @param kind defines the data kind (Position, normal, etc...)
  81800. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  81801. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  81802. * @returns a float array containing vertex data
  81803. */
  81804. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  81805. /**
  81806. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  81807. * @param kind defines the data kind (Position, normal, etc...)
  81808. * @returns true if the vertex buffer with the specified kind is updatable
  81809. */
  81810. isVertexBufferUpdatable(kind: string): boolean;
  81811. /**
  81812. * Gets a specific vertex buffer
  81813. * @param kind defines the data kind (Position, normal, etc...)
  81814. * @returns a VertexBuffer
  81815. */
  81816. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  81817. /**
  81818. * Returns all vertex buffers
  81819. * @return an object holding all vertex buffers indexed by kind
  81820. */
  81821. getVertexBuffers(): Nullable<{
  81822. [key: string]: VertexBuffer;
  81823. }>;
  81824. /**
  81825. * Gets a boolean indicating if specific vertex buffer is present
  81826. * @param kind defines the data kind (Position, normal, etc...)
  81827. * @returns true if data is present
  81828. */
  81829. isVerticesDataPresent(kind: string): boolean;
  81830. /**
  81831. * Gets a list of all attached data kinds (Position, normal, etc...)
  81832. * @returns a list of string containing all kinds
  81833. */
  81834. getVerticesDataKinds(): string[];
  81835. /**
  81836. * Update index buffer
  81837. * @param indices defines the indices to store in the index buffer
  81838. * @param offset defines the offset in the target buffer where to store the data
  81839. * @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)
  81840. */
  81841. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  81842. /**
  81843. * Creates a new index buffer
  81844. * @param indices defines the indices to store in the index buffer
  81845. * @param totalVertices defines the total number of vertices (could be null)
  81846. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  81847. */
  81848. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  81849. /**
  81850. * Return the total number of indices
  81851. * @returns the total number of indices
  81852. */
  81853. getTotalIndices(): number;
  81854. /**
  81855. * Gets the index buffer array
  81856. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  81857. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  81858. * @returns the index buffer array
  81859. */
  81860. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  81861. /**
  81862. * Gets the index buffer
  81863. * @return the index buffer
  81864. */
  81865. getIndexBuffer(): Nullable<WebGLBuffer>;
  81866. /** @hidden */
  81867. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  81868. /**
  81869. * Release the associated resources for a specific mesh
  81870. * @param mesh defines the source mesh
  81871. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  81872. */
  81873. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  81874. /**
  81875. * Apply current geometry to a given mesh
  81876. * @param mesh defines the mesh to apply geometry to
  81877. */
  81878. applyToMesh(mesh: Mesh): void;
  81879. private _updateExtend;
  81880. private _applyToMesh;
  81881. private notifyUpdate;
  81882. /**
  81883. * Load the geometry if it was flagged as delay loaded
  81884. * @param scene defines the hosting scene
  81885. * @param onLoaded defines a callback called when the geometry is loaded
  81886. */
  81887. load(scene: Scene, onLoaded?: () => void): void;
  81888. private _queueLoad;
  81889. /**
  81890. * Invert the geometry to move from a right handed system to a left handed one.
  81891. */
  81892. toLeftHanded(): void;
  81893. /** @hidden */
  81894. _resetPointsArrayCache(): void;
  81895. /** @hidden */
  81896. _generatePointsArray(): boolean;
  81897. /**
  81898. * Gets a value indicating if the geometry is disposed
  81899. * @returns true if the geometry was disposed
  81900. */
  81901. isDisposed(): boolean;
  81902. private _disposeVertexArrayObjects;
  81903. /**
  81904. * Free all associated resources
  81905. */
  81906. dispose(): void;
  81907. /**
  81908. * Clone the current geometry into a new geometry
  81909. * @param id defines the unique ID of the new geometry
  81910. * @returns a new geometry object
  81911. */
  81912. copy(id: string): Geometry;
  81913. /**
  81914. * Serialize the current geometry info (and not the vertices data) into a JSON object
  81915. * @return a JSON representation of the current geometry data (without the vertices data)
  81916. */
  81917. serialize(): any;
  81918. private toNumberArray;
  81919. /**
  81920. * Serialize all vertices data into a JSON oject
  81921. * @returns a JSON representation of the current geometry data
  81922. */
  81923. serializeVerticeData(): any;
  81924. /**
  81925. * Extracts a clone of a mesh geometry
  81926. * @param mesh defines the source mesh
  81927. * @param id defines the unique ID of the new geometry object
  81928. * @returns the new geometry object
  81929. */
  81930. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  81931. /**
  81932. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  81933. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  81934. * Be aware Math.random() could cause collisions, but:
  81935. * "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"
  81936. * @returns a string containing a new GUID
  81937. */
  81938. static RandomId(): string;
  81939. /** @hidden */
  81940. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  81941. private static _CleanMatricesWeights;
  81942. /**
  81943. * Create a new geometry from persisted data (Using .babylon file format)
  81944. * @param parsedVertexData defines the persisted data
  81945. * @param scene defines the hosting scene
  81946. * @param rootUrl defines the root url to use to load assets (like delayed data)
  81947. * @returns the new geometry object
  81948. */
  81949. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  81950. }
  81951. }
  81952. declare module BABYLON {
  81953. /**
  81954. * Define an interface for all classes that will get and set the data on vertices
  81955. */
  81956. export interface IGetSetVerticesData {
  81957. /**
  81958. * Gets a boolean indicating if specific vertex data is present
  81959. * @param kind defines the vertex data kind to use
  81960. * @returns true is data kind is present
  81961. */
  81962. isVerticesDataPresent(kind: string): boolean;
  81963. /**
  81964. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  81965. * @param kind defines the data kind (Position, normal, etc...)
  81966. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  81967. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  81968. * @returns a float array containing vertex data
  81969. */
  81970. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  81971. /**
  81972. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  81973. * @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.
  81974. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  81975. * @returns the indices array or an empty array if the mesh has no geometry
  81976. */
  81977. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  81978. /**
  81979. * Set specific vertex data
  81980. * @param kind defines the data kind (Position, normal, etc...)
  81981. * @param data defines the vertex data to use
  81982. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  81983. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  81984. */
  81985. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  81986. /**
  81987. * Update a specific associated vertex buffer
  81988. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  81989. * - VertexBuffer.PositionKind
  81990. * - VertexBuffer.UVKind
  81991. * - VertexBuffer.UV2Kind
  81992. * - VertexBuffer.UV3Kind
  81993. * - VertexBuffer.UV4Kind
  81994. * - VertexBuffer.UV5Kind
  81995. * - VertexBuffer.UV6Kind
  81996. * - VertexBuffer.ColorKind
  81997. * - VertexBuffer.MatricesIndicesKind
  81998. * - VertexBuffer.MatricesIndicesExtraKind
  81999. * - VertexBuffer.MatricesWeightsKind
  82000. * - VertexBuffer.MatricesWeightsExtraKind
  82001. * @param data defines the data source
  82002. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  82003. * @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)
  82004. */
  82005. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  82006. /**
  82007. * Creates a new index buffer
  82008. * @param indices defines the indices to store in the index buffer
  82009. * @param totalVertices defines the total number of vertices (could be null)
  82010. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  82011. */
  82012. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  82013. }
  82014. /**
  82015. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  82016. */
  82017. export class VertexData {
  82018. /**
  82019. * Mesh side orientation : usually the external or front surface
  82020. */
  82021. static readonly FRONTSIDE: number;
  82022. /**
  82023. * Mesh side orientation : usually the internal or back surface
  82024. */
  82025. static readonly BACKSIDE: number;
  82026. /**
  82027. * Mesh side orientation : both internal and external or front and back surfaces
  82028. */
  82029. static readonly DOUBLESIDE: number;
  82030. /**
  82031. * Mesh side orientation : by default, `FRONTSIDE`
  82032. */
  82033. static readonly DEFAULTSIDE: number;
  82034. /**
  82035. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  82036. */
  82037. positions: Nullable<FloatArray>;
  82038. /**
  82039. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  82040. */
  82041. normals: Nullable<FloatArray>;
  82042. /**
  82043. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  82044. */
  82045. tangents: Nullable<FloatArray>;
  82046. /**
  82047. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  82048. */
  82049. uvs: Nullable<FloatArray>;
  82050. /**
  82051. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  82052. */
  82053. uvs2: Nullable<FloatArray>;
  82054. /**
  82055. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  82056. */
  82057. uvs3: Nullable<FloatArray>;
  82058. /**
  82059. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  82060. */
  82061. uvs4: Nullable<FloatArray>;
  82062. /**
  82063. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  82064. */
  82065. uvs5: Nullable<FloatArray>;
  82066. /**
  82067. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  82068. */
  82069. uvs6: Nullable<FloatArray>;
  82070. /**
  82071. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  82072. */
  82073. colors: Nullable<FloatArray>;
  82074. /**
  82075. * 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).
  82076. */
  82077. matricesIndices: Nullable<FloatArray>;
  82078. /**
  82079. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  82080. */
  82081. matricesWeights: Nullable<FloatArray>;
  82082. /**
  82083. * An array extending the number of possible indices
  82084. */
  82085. matricesIndicesExtra: Nullable<FloatArray>;
  82086. /**
  82087. * An array extending the number of possible weights when the number of indices is extended
  82088. */
  82089. matricesWeightsExtra: Nullable<FloatArray>;
  82090. /**
  82091. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  82092. */
  82093. indices: Nullable<IndicesArray>;
  82094. /**
  82095. * Uses the passed data array to set the set the values for the specified kind of data
  82096. * @param data a linear array of floating numbers
  82097. * @param kind the type of data that is being set, eg positions, colors etc
  82098. */
  82099. set(data: FloatArray, kind: string): void;
  82100. /**
  82101. * Associates the vertexData to the passed Mesh.
  82102. * Sets it as updatable or not (default `false`)
  82103. * @param mesh the mesh the vertexData is applied to
  82104. * @param updatable when used and having the value true allows new data to update the vertexData
  82105. * @returns the VertexData
  82106. */
  82107. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  82108. /**
  82109. * Associates the vertexData to the passed Geometry.
  82110. * Sets it as updatable or not (default `false`)
  82111. * @param geometry the geometry the vertexData is applied to
  82112. * @param updatable when used and having the value true allows new data to update the vertexData
  82113. * @returns VertexData
  82114. */
  82115. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  82116. /**
  82117. * Updates the associated mesh
  82118. * @param mesh the mesh to be updated
  82119. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  82120. * @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
  82121. * @returns VertexData
  82122. */
  82123. updateMesh(mesh: Mesh): VertexData;
  82124. /**
  82125. * Updates the associated geometry
  82126. * @param geometry the geometry to be updated
  82127. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  82128. * @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
  82129. * @returns VertexData.
  82130. */
  82131. updateGeometry(geometry: Geometry): VertexData;
  82132. private _applyTo;
  82133. private _update;
  82134. /**
  82135. * Transforms each position and each normal of the vertexData according to the passed Matrix
  82136. * @param matrix the transforming matrix
  82137. * @returns the VertexData
  82138. */
  82139. transform(matrix: Matrix): VertexData;
  82140. /**
  82141. * Merges the passed VertexData into the current one
  82142. * @param other the VertexData to be merged into the current one
  82143. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  82144. * @returns the modified VertexData
  82145. */
  82146. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  82147. private _mergeElement;
  82148. private _validate;
  82149. /**
  82150. * Serializes the VertexData
  82151. * @returns a serialized object
  82152. */
  82153. serialize(): any;
  82154. /**
  82155. * Extracts the vertexData from a mesh
  82156. * @param mesh the mesh from which to extract the VertexData
  82157. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  82158. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  82159. * @returns the object VertexData associated to the passed mesh
  82160. */
  82161. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  82162. /**
  82163. * Extracts the vertexData from the geometry
  82164. * @param geometry the geometry from which to extract the VertexData
  82165. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  82166. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  82167. * @returns the object VertexData associated to the passed mesh
  82168. */
  82169. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  82170. private static _ExtractFrom;
  82171. /**
  82172. * Creates the VertexData for a Ribbon
  82173. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  82174. * * pathArray array of paths, each of which an array of successive Vector3
  82175. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  82176. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  82177. * * 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
  82178. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  82179. * * 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)
  82180. * * 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)
  82181. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  82182. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  82183. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  82184. * @returns the VertexData of the ribbon
  82185. */
  82186. static CreateRibbon(options: {
  82187. pathArray: Vector3[][];
  82188. closeArray?: boolean;
  82189. closePath?: boolean;
  82190. offset?: number;
  82191. sideOrientation?: number;
  82192. frontUVs?: Vector4;
  82193. backUVs?: Vector4;
  82194. invertUV?: boolean;
  82195. uvs?: Vector2[];
  82196. colors?: Color4[];
  82197. }): VertexData;
  82198. /**
  82199. * Creates the VertexData for a box
  82200. * @param options an object used to set the following optional parameters for the box, required but can be empty
  82201. * * size sets the width, height and depth of the box to the value of size, optional default 1
  82202. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  82203. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  82204. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  82205. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  82206. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  82207. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  82208. * * 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)
  82209. * * 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)
  82210. * @returns the VertexData of the box
  82211. */
  82212. static CreateBox(options: {
  82213. size?: number;
  82214. width?: number;
  82215. height?: number;
  82216. depth?: number;
  82217. faceUV?: Vector4[];
  82218. faceColors?: Color4[];
  82219. sideOrientation?: number;
  82220. frontUVs?: Vector4;
  82221. backUVs?: Vector4;
  82222. }): VertexData;
  82223. /**
  82224. * Creates the VertexData for an ellipsoid, defaults to a sphere
  82225. * @param options an object used to set the following optional parameters for the box, required but can be empty
  82226. * * segments sets the number of horizontal strips optional, default 32
  82227. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  82228. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  82229. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  82230. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  82231. * * 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
  82232. * * 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
  82233. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  82234. * * 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)
  82235. * * 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)
  82236. * @returns the VertexData of the ellipsoid
  82237. */
  82238. static CreateSphere(options: {
  82239. segments?: number;
  82240. diameter?: number;
  82241. diameterX?: number;
  82242. diameterY?: number;
  82243. diameterZ?: number;
  82244. arc?: number;
  82245. slice?: number;
  82246. sideOrientation?: number;
  82247. frontUVs?: Vector4;
  82248. backUVs?: Vector4;
  82249. }): VertexData;
  82250. /**
  82251. * Creates the VertexData for a cylinder, cone or prism
  82252. * @param options an object used to set the following optional parameters for the box, required but can be empty
  82253. * * height sets the height (y direction) of the cylinder, optional, default 2
  82254. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  82255. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  82256. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  82257. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  82258. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  82259. * * 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
  82260. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  82261. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  82262. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  82263. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  82264. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  82265. * * 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)
  82266. * * 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)
  82267. * @returns the VertexData of the cylinder, cone or prism
  82268. */
  82269. static CreateCylinder(options: {
  82270. height?: number;
  82271. diameterTop?: number;
  82272. diameterBottom?: number;
  82273. diameter?: number;
  82274. tessellation?: number;
  82275. subdivisions?: number;
  82276. arc?: number;
  82277. faceColors?: Color4[];
  82278. faceUV?: Vector4[];
  82279. hasRings?: boolean;
  82280. enclose?: boolean;
  82281. sideOrientation?: number;
  82282. frontUVs?: Vector4;
  82283. backUVs?: Vector4;
  82284. }): VertexData;
  82285. /**
  82286. * Creates the VertexData for a torus
  82287. * @param options an object used to set the following optional parameters for the box, required but can be empty
  82288. * * diameter the diameter of the torus, optional default 1
  82289. * * thickness the diameter of the tube forming the torus, optional default 0.5
  82290. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  82291. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  82292. * * 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)
  82293. * * 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)
  82294. * @returns the VertexData of the torus
  82295. */
  82296. static CreateTorus(options: {
  82297. diameter?: number;
  82298. thickness?: number;
  82299. tessellation?: number;
  82300. sideOrientation?: number;
  82301. frontUVs?: Vector4;
  82302. backUVs?: Vector4;
  82303. }): VertexData;
  82304. /**
  82305. * Creates the VertexData of the LineSystem
  82306. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  82307. * - lines an array of lines, each line being an array of successive Vector3
  82308. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  82309. * @returns the VertexData of the LineSystem
  82310. */
  82311. static CreateLineSystem(options: {
  82312. lines: Vector3[][];
  82313. colors?: Nullable<Color4[][]>;
  82314. }): VertexData;
  82315. /**
  82316. * Create the VertexData for a DashedLines
  82317. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  82318. * - points an array successive Vector3
  82319. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  82320. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  82321. * - dashNb the intended total number of dashes, optional, default 200
  82322. * @returns the VertexData for the DashedLines
  82323. */
  82324. static CreateDashedLines(options: {
  82325. points: Vector3[];
  82326. dashSize?: number;
  82327. gapSize?: number;
  82328. dashNb?: number;
  82329. }): VertexData;
  82330. /**
  82331. * Creates the VertexData for a Ground
  82332. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  82333. * - width the width (x direction) of the ground, optional, default 1
  82334. * - height the height (z direction) of the ground, optional, default 1
  82335. * - subdivisions the number of subdivisions per side, optional, default 1
  82336. * @returns the VertexData of the Ground
  82337. */
  82338. static CreateGround(options: {
  82339. width?: number;
  82340. height?: number;
  82341. subdivisions?: number;
  82342. subdivisionsX?: number;
  82343. subdivisionsY?: number;
  82344. }): VertexData;
  82345. /**
  82346. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  82347. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  82348. * * xmin the ground minimum X coordinate, optional, default -1
  82349. * * zmin the ground minimum Z coordinate, optional, default -1
  82350. * * xmax the ground maximum X coordinate, optional, default 1
  82351. * * zmax the ground maximum Z coordinate, optional, default 1
  82352. * * 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}
  82353. * * 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}
  82354. * @returns the VertexData of the TiledGround
  82355. */
  82356. static CreateTiledGround(options: {
  82357. xmin: number;
  82358. zmin: number;
  82359. xmax: number;
  82360. zmax: number;
  82361. subdivisions?: {
  82362. w: number;
  82363. h: number;
  82364. };
  82365. precision?: {
  82366. w: number;
  82367. h: number;
  82368. };
  82369. }): VertexData;
  82370. /**
  82371. * Creates the VertexData of the Ground designed from a heightmap
  82372. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  82373. * * width the width (x direction) of the ground
  82374. * * height the height (z direction) of the ground
  82375. * * subdivisions the number of subdivisions per side
  82376. * * minHeight the minimum altitude on the ground, optional, default 0
  82377. * * maxHeight the maximum altitude on the ground, optional default 1
  82378. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  82379. * * buffer the array holding the image color data
  82380. * * bufferWidth the width of image
  82381. * * bufferHeight the height of image
  82382. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  82383. * @returns the VertexData of the Ground designed from a heightmap
  82384. */
  82385. static CreateGroundFromHeightMap(options: {
  82386. width: number;
  82387. height: number;
  82388. subdivisions: number;
  82389. minHeight: number;
  82390. maxHeight: number;
  82391. colorFilter: Color3;
  82392. buffer: Uint8Array;
  82393. bufferWidth: number;
  82394. bufferHeight: number;
  82395. alphaFilter: number;
  82396. }): VertexData;
  82397. /**
  82398. * Creates the VertexData for a Plane
  82399. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  82400. * * size sets the width and height of the plane to the value of size, optional default 1
  82401. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  82402. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  82403. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  82404. * * 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)
  82405. * * 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)
  82406. * @returns the VertexData of the box
  82407. */
  82408. static CreatePlane(options: {
  82409. size?: number;
  82410. width?: number;
  82411. height?: number;
  82412. sideOrientation?: number;
  82413. frontUVs?: Vector4;
  82414. backUVs?: Vector4;
  82415. }): VertexData;
  82416. /**
  82417. * Creates the VertexData of the Disc or regular Polygon
  82418. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  82419. * * radius the radius of the disc, optional default 0.5
  82420. * * tessellation the number of polygon sides, optional, default 64
  82421. * * 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
  82422. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  82423. * * 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)
  82424. * * 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)
  82425. * @returns the VertexData of the box
  82426. */
  82427. static CreateDisc(options: {
  82428. radius?: number;
  82429. tessellation?: number;
  82430. arc?: number;
  82431. sideOrientation?: number;
  82432. frontUVs?: Vector4;
  82433. backUVs?: Vector4;
  82434. }): VertexData;
  82435. /**
  82436. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  82437. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  82438. * @param polygon a mesh built from polygonTriangulation.build()
  82439. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  82440. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  82441. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  82442. * @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)
  82443. * @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)
  82444. * @returns the VertexData of the Polygon
  82445. */
  82446. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  82447. /**
  82448. * Creates the VertexData of the IcoSphere
  82449. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  82450. * * radius the radius of the IcoSphere, optional default 1
  82451. * * radiusX allows stretching in the x direction, optional, default radius
  82452. * * radiusY allows stretching in the y direction, optional, default radius
  82453. * * radiusZ allows stretching in the z direction, optional, default radius
  82454. * * flat when true creates a flat shaded mesh, optional, default true
  82455. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  82456. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  82457. * * 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)
  82458. * * 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)
  82459. * @returns the VertexData of the IcoSphere
  82460. */
  82461. static CreateIcoSphere(options: {
  82462. radius?: number;
  82463. radiusX?: number;
  82464. radiusY?: number;
  82465. radiusZ?: number;
  82466. flat?: boolean;
  82467. subdivisions?: number;
  82468. sideOrientation?: number;
  82469. frontUVs?: Vector4;
  82470. backUVs?: Vector4;
  82471. }): VertexData;
  82472. /**
  82473. * Creates the VertexData for a Polyhedron
  82474. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  82475. * * type provided types are:
  82476. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  82477. * * 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)
  82478. * * size the size of the IcoSphere, optional default 1
  82479. * * sizeX allows stretching in the x direction, optional, default size
  82480. * * sizeY allows stretching in the y direction, optional, default size
  82481. * * sizeZ allows stretching in the z direction, optional, default size
  82482. * * 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
  82483. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  82484. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  82485. * * flat when true creates a flat shaded mesh, optional, default true
  82486. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  82487. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  82488. * * 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)
  82489. * * 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)
  82490. * @returns the VertexData of the Polyhedron
  82491. */
  82492. static CreatePolyhedron(options: {
  82493. type?: number;
  82494. size?: number;
  82495. sizeX?: number;
  82496. sizeY?: number;
  82497. sizeZ?: number;
  82498. custom?: any;
  82499. faceUV?: Vector4[];
  82500. faceColors?: Color4[];
  82501. flat?: boolean;
  82502. sideOrientation?: number;
  82503. frontUVs?: Vector4;
  82504. backUVs?: Vector4;
  82505. }): VertexData;
  82506. /**
  82507. * Creates the VertexData for a TorusKnot
  82508. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  82509. * * radius the radius of the torus knot, optional, default 2
  82510. * * tube the thickness of the tube, optional, default 0.5
  82511. * * radialSegments the number of sides on each tube segments, optional, default 32
  82512. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  82513. * * p the number of windings around the z axis, optional, default 2
  82514. * * q the number of windings around the x axis, optional, default 3
  82515. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  82516. * * 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)
  82517. * * 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)
  82518. * @returns the VertexData of the Torus Knot
  82519. */
  82520. static CreateTorusKnot(options: {
  82521. radius?: number;
  82522. tube?: number;
  82523. radialSegments?: number;
  82524. tubularSegments?: number;
  82525. p?: number;
  82526. q?: number;
  82527. sideOrientation?: number;
  82528. frontUVs?: Vector4;
  82529. backUVs?: Vector4;
  82530. }): VertexData;
  82531. /**
  82532. * Compute normals for given positions and indices
  82533. * @param positions an array of vertex positions, [...., x, y, z, ......]
  82534. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  82535. * @param normals an array of vertex normals, [...., x, y, z, ......]
  82536. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  82537. * * facetNormals : optional array of facet normals (vector3)
  82538. * * facetPositions : optional array of facet positions (vector3)
  82539. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  82540. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  82541. * * bInfo : optional bounding info, required for facetPartitioning computation
  82542. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  82543. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  82544. * * useRightHandedSystem: optional boolean to for right handed system computation
  82545. * * depthSort : optional boolean to enable the facet depth sort computation
  82546. * * distanceTo : optional Vector3 to compute the facet depth from this location
  82547. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  82548. */
  82549. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  82550. facetNormals?: any;
  82551. facetPositions?: any;
  82552. facetPartitioning?: any;
  82553. ratio?: number;
  82554. bInfo?: any;
  82555. bbSize?: Vector3;
  82556. subDiv?: any;
  82557. useRightHandedSystem?: boolean;
  82558. depthSort?: boolean;
  82559. distanceTo?: Vector3;
  82560. depthSortedFacets?: any;
  82561. }): void;
  82562. /** @hidden */
  82563. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  82564. /**
  82565. * Applies VertexData created from the imported parameters to the geometry
  82566. * @param parsedVertexData the parsed data from an imported file
  82567. * @param geometry the geometry to apply the VertexData to
  82568. */
  82569. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  82570. }
  82571. }
  82572. declare module BABYLON {
  82573. /**
  82574. * Class containing static functions to help procedurally build meshes
  82575. */
  82576. export class DiscBuilder {
  82577. /**
  82578. * Creates a plane polygonal mesh. By default, this is a disc
  82579. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  82580. * * 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
  82581. * * 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
  82582. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  82583. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  82584. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  82585. * @param name defines the name of the mesh
  82586. * @param options defines the options used to create the mesh
  82587. * @param scene defines the hosting scene
  82588. * @returns the plane polygonal mesh
  82589. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  82590. */
  82591. static CreateDisc(name: string, options: {
  82592. radius?: number;
  82593. tessellation?: number;
  82594. arc?: number;
  82595. updatable?: boolean;
  82596. sideOrientation?: number;
  82597. frontUVs?: Vector4;
  82598. backUVs?: Vector4;
  82599. }, scene?: Nullable<Scene>): Mesh;
  82600. }
  82601. }
  82602. declare module BABYLON {
  82603. /**
  82604. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  82605. *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.
  82606. * The SPS is also a particle system. It provides some methods to manage the particles.
  82607. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  82608. *
  82609. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  82610. */
  82611. export class SolidParticleSystem implements IDisposable {
  82612. /**
  82613. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  82614. * Example : var p = SPS.particles[i];
  82615. */
  82616. particles: SolidParticle[];
  82617. /**
  82618. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  82619. */
  82620. nbParticles: number;
  82621. /**
  82622. * If the particles must ever face the camera (default false). Useful for planar particles.
  82623. */
  82624. billboard: boolean;
  82625. /**
  82626. * Recompute normals when adding a shape
  82627. */
  82628. recomputeNormals: boolean;
  82629. /**
  82630. * This a counter ofr your own usage. It's not set by any SPS functions.
  82631. */
  82632. counter: number;
  82633. /**
  82634. * The SPS name. This name is also given to the underlying mesh.
  82635. */
  82636. name: string;
  82637. /**
  82638. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  82639. */
  82640. mesh: Mesh;
  82641. /**
  82642. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  82643. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  82644. */
  82645. vars: any;
  82646. /**
  82647. * This array is populated when the SPS is set as 'pickable'.
  82648. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  82649. * Each element of this array is an object `{idx: int, faceId: int}`.
  82650. * `idx` is the picked particle index in the `SPS.particles` array
  82651. * `faceId` is the picked face index counted within this particle.
  82652. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  82653. */
  82654. pickedParticles: {
  82655. idx: number;
  82656. faceId: number;
  82657. }[];
  82658. /**
  82659. * This array is populated when `enableDepthSort` is set to true.
  82660. * Each element of this array is an instance of the class DepthSortedParticle.
  82661. */
  82662. depthSortedParticles: DepthSortedParticle[];
  82663. /**
  82664. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  82665. * @hidden
  82666. */
  82667. _bSphereOnly: boolean;
  82668. /**
  82669. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  82670. * @hidden
  82671. */
  82672. _bSphereRadiusFactor: number;
  82673. private _scene;
  82674. private _positions;
  82675. private _indices;
  82676. private _normals;
  82677. private _colors;
  82678. private _uvs;
  82679. private _indices32;
  82680. private _positions32;
  82681. private _normals32;
  82682. private _fixedNormal32;
  82683. private _colors32;
  82684. private _uvs32;
  82685. private _index;
  82686. private _updatable;
  82687. private _pickable;
  82688. private _isVisibilityBoxLocked;
  82689. private _alwaysVisible;
  82690. private _depthSort;
  82691. private _shapeCounter;
  82692. private _copy;
  82693. private _color;
  82694. private _computeParticleColor;
  82695. private _computeParticleTexture;
  82696. private _computeParticleRotation;
  82697. private _computeParticleVertex;
  82698. private _computeBoundingBox;
  82699. private _depthSortParticles;
  82700. private _camera;
  82701. private _mustUnrotateFixedNormals;
  82702. private _particlesIntersect;
  82703. private _needs32Bits;
  82704. /**
  82705. * Creates a SPS (Solid Particle System) object.
  82706. * @param name (String) is the SPS name, this will be the underlying mesh name.
  82707. * @param scene (Scene) is the scene in which the SPS is added.
  82708. * @param options defines the options of the sps e.g.
  82709. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  82710. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  82711. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  82712. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  82713. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  82714. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  82715. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  82716. */
  82717. constructor(name: string, scene: Scene, options?: {
  82718. updatable?: boolean;
  82719. isPickable?: boolean;
  82720. enableDepthSort?: boolean;
  82721. particleIntersection?: boolean;
  82722. boundingSphereOnly?: boolean;
  82723. bSphereRadiusFactor?: number;
  82724. });
  82725. /**
  82726. * Builds the SPS underlying mesh. Returns a standard Mesh.
  82727. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  82728. * @returns the created mesh
  82729. */
  82730. buildMesh(): Mesh;
  82731. /**
  82732. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  82733. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  82734. * Thus the particles generated from `digest()` have their property `position` set yet.
  82735. * @param mesh ( Mesh ) is the mesh to be digested
  82736. * @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
  82737. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  82738. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  82739. * @returns the current SPS
  82740. */
  82741. digest(mesh: Mesh, options?: {
  82742. facetNb?: number;
  82743. number?: number;
  82744. delta?: number;
  82745. }): SolidParticleSystem;
  82746. private _unrotateFixedNormals;
  82747. private _resetCopy;
  82748. private _meshBuilder;
  82749. private _posToShape;
  82750. private _uvsToShapeUV;
  82751. private _addParticle;
  82752. /**
  82753. * Adds some particles to the SPS from the model shape. Returns the shape id.
  82754. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  82755. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  82756. * @param nb (positive integer) the number of particles to be created from this model
  82757. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  82758. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  82759. * @returns the number of shapes in the system
  82760. */
  82761. addShape(mesh: Mesh, nb: number, options?: {
  82762. positionFunction?: any;
  82763. vertexFunction?: any;
  82764. }): number;
  82765. private _rebuildParticle;
  82766. /**
  82767. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  82768. * @returns the SPS.
  82769. */
  82770. rebuildMesh(): SolidParticleSystem;
  82771. /**
  82772. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  82773. * This method calls `updateParticle()` for each particle of the SPS.
  82774. * For an animated SPS, it is usually called within the render loop.
  82775. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  82776. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  82777. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  82778. * @returns the SPS.
  82779. */
  82780. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  82781. /**
  82782. * Disposes the SPS.
  82783. */
  82784. dispose(): void;
  82785. /**
  82786. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  82787. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  82788. * @returns the SPS.
  82789. */
  82790. refreshVisibleSize(): SolidParticleSystem;
  82791. /**
  82792. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  82793. * @param size the size (float) of the visibility box
  82794. * note : this doesn't lock the SPS mesh bounding box.
  82795. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  82796. */
  82797. setVisibilityBox(size: number): void;
  82798. /**
  82799. * Gets whether the SPS as always visible or not
  82800. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  82801. */
  82802. /**
  82803. * Sets the SPS as always visible or not
  82804. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  82805. */
  82806. isAlwaysVisible: boolean;
  82807. /**
  82808. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  82809. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  82810. */
  82811. /**
  82812. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  82813. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  82814. */
  82815. isVisibilityBoxLocked: boolean;
  82816. /**
  82817. * Tells to `setParticles()` to compute the particle rotations or not.
  82818. * Default value : true. The SPS is faster when it's set to false.
  82819. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  82820. */
  82821. /**
  82822. * Gets if `setParticles()` computes the particle rotations or not.
  82823. * Default value : true. The SPS is faster when it's set to false.
  82824. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  82825. */
  82826. computeParticleRotation: boolean;
  82827. /**
  82828. * Tells to `setParticles()` to compute the particle colors or not.
  82829. * Default value : true. The SPS is faster when it's set to false.
  82830. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  82831. */
  82832. /**
  82833. * Gets if `setParticles()` computes the particle colors or not.
  82834. * Default value : true. The SPS is faster when it's set to false.
  82835. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  82836. */
  82837. computeParticleColor: boolean;
  82838. /**
  82839. * Gets if `setParticles()` computes the particle textures or not.
  82840. * Default value : true. The SPS is faster when it's set to false.
  82841. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  82842. */
  82843. computeParticleTexture: boolean;
  82844. /**
  82845. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  82846. * Default value : false. The SPS is faster when it's set to false.
  82847. * Note : the particle custom vertex positions aren't stored values.
  82848. */
  82849. /**
  82850. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  82851. * Default value : false. The SPS is faster when it's set to false.
  82852. * Note : the particle custom vertex positions aren't stored values.
  82853. */
  82854. computeParticleVertex: boolean;
  82855. /**
  82856. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  82857. */
  82858. /**
  82859. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  82860. */
  82861. computeBoundingBox: boolean;
  82862. /**
  82863. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  82864. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  82865. * Default : `true`
  82866. */
  82867. /**
  82868. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  82869. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  82870. * Default : `true`
  82871. */
  82872. depthSortParticles: boolean;
  82873. /**
  82874. * This function does nothing. It may be overwritten to set all the particle first values.
  82875. * The SPS doesn't call this function, you may have to call it by your own.
  82876. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  82877. */
  82878. initParticles(): void;
  82879. /**
  82880. * This function does nothing. It may be overwritten to recycle a particle.
  82881. * The SPS doesn't call this function, you may have to call it by your own.
  82882. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  82883. * @param particle The particle to recycle
  82884. * @returns the recycled particle
  82885. */
  82886. recycleParticle(particle: SolidParticle): SolidParticle;
  82887. /**
  82888. * Updates a particle : this function should be overwritten by the user.
  82889. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  82890. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  82891. * @example : just set a particle position or velocity and recycle conditions
  82892. * @param particle The particle to update
  82893. * @returns the updated particle
  82894. */
  82895. updateParticle(particle: SolidParticle): SolidParticle;
  82896. /**
  82897. * Updates a vertex of a particle : it can be overwritten by the user.
  82898. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  82899. * @param particle the current particle
  82900. * @param vertex the current index of the current particle
  82901. * @param pt the index of the current vertex in the particle shape
  82902. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  82903. * @example : just set a vertex particle position
  82904. * @returns the updated vertex
  82905. */
  82906. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  82907. /**
  82908. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  82909. * This does nothing and may be overwritten by the user.
  82910. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  82911. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  82912. * @param update the boolean update value actually passed to setParticles()
  82913. */
  82914. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  82915. /**
  82916. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  82917. * This will be passed three parameters.
  82918. * This does nothing and may be overwritten by the user.
  82919. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  82920. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  82921. * @param update the boolean update value actually passed to setParticles()
  82922. */
  82923. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  82924. }
  82925. }
  82926. declare module BABYLON {
  82927. /**
  82928. * Represents one particle of a solid particle system.
  82929. */
  82930. export class SolidParticle {
  82931. /**
  82932. * particle global index
  82933. */
  82934. idx: number;
  82935. /**
  82936. * The color of the particle
  82937. */
  82938. color: Nullable<Color4>;
  82939. /**
  82940. * The world space position of the particle.
  82941. */
  82942. position: Vector3;
  82943. /**
  82944. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  82945. */
  82946. rotation: Vector3;
  82947. /**
  82948. * The world space rotation quaternion of the particle.
  82949. */
  82950. rotationQuaternion: Nullable<Quaternion>;
  82951. /**
  82952. * The scaling of the particle.
  82953. */
  82954. scaling: Vector3;
  82955. /**
  82956. * The uvs of the particle.
  82957. */
  82958. uvs: Vector4;
  82959. /**
  82960. * The current speed of the particle.
  82961. */
  82962. velocity: Vector3;
  82963. /**
  82964. * The pivot point in the particle local space.
  82965. */
  82966. pivot: Vector3;
  82967. /**
  82968. * Must the particle be translated from its pivot point in its local space ?
  82969. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  82970. * Default : false
  82971. */
  82972. translateFromPivot: boolean;
  82973. /**
  82974. * Is the particle active or not ?
  82975. */
  82976. alive: boolean;
  82977. /**
  82978. * Is the particle visible or not ?
  82979. */
  82980. isVisible: boolean;
  82981. /**
  82982. * Index of this particle in the global "positions" array (Internal use)
  82983. * @hidden
  82984. */
  82985. _pos: number;
  82986. /**
  82987. * @hidden Index of this particle in the global "indices" array (Internal use)
  82988. */
  82989. _ind: number;
  82990. /**
  82991. * @hidden ModelShape of this particle (Internal use)
  82992. */
  82993. _model: ModelShape;
  82994. /**
  82995. * ModelShape id of this particle
  82996. */
  82997. shapeId: number;
  82998. /**
  82999. * Index of the particle in its shape id (Internal use)
  83000. */
  83001. idxInShape: number;
  83002. /**
  83003. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  83004. */
  83005. _modelBoundingInfo: BoundingInfo;
  83006. /**
  83007. * @hidden Particle BoundingInfo object (Internal use)
  83008. */
  83009. _boundingInfo: BoundingInfo;
  83010. /**
  83011. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  83012. */
  83013. _sps: SolidParticleSystem;
  83014. /**
  83015. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  83016. */
  83017. _stillInvisible: boolean;
  83018. /**
  83019. * @hidden Last computed particle rotation matrix
  83020. */
  83021. _rotationMatrix: number[];
  83022. /**
  83023. * Parent particle Id, if any.
  83024. * Default null.
  83025. */
  83026. parentId: Nullable<number>;
  83027. /**
  83028. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  83029. * The possible values are :
  83030. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  83031. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  83032. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  83033. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  83034. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  83035. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  83036. * */
  83037. cullingStrategy: number;
  83038. /**
  83039. * @hidden Internal global position in the SPS.
  83040. */
  83041. _globalPosition: Vector3;
  83042. /**
  83043. * Creates a Solid Particle object.
  83044. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  83045. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  83046. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  83047. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  83048. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  83049. * @param shapeId (integer) is the model shape identifier in the SPS.
  83050. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  83051. * @param sps defines the sps it is associated to
  83052. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  83053. */
  83054. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  83055. /**
  83056. * Legacy support, changed scale to scaling
  83057. */
  83058. /**
  83059. * Legacy support, changed scale to scaling
  83060. */
  83061. scale: Vector3;
  83062. /**
  83063. * Legacy support, changed quaternion to rotationQuaternion
  83064. */
  83065. /**
  83066. * Legacy support, changed quaternion to rotationQuaternion
  83067. */
  83068. quaternion: Nullable<Quaternion>;
  83069. /**
  83070. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  83071. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  83072. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  83073. * @returns true if it intersects
  83074. */
  83075. intersectsMesh(target: Mesh | SolidParticle): boolean;
  83076. /**
  83077. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  83078. * A particle is in the frustum if its bounding box intersects the frustum
  83079. * @param frustumPlanes defines the frustum to test
  83080. * @returns true if the particle is in the frustum planes
  83081. */
  83082. isInFrustum(frustumPlanes: Plane[]): boolean;
  83083. /**
  83084. * get the rotation matrix of the particle
  83085. * @hidden
  83086. */
  83087. getRotationMatrix(m: Matrix): void;
  83088. }
  83089. /**
  83090. * Represents the shape of the model used by one particle of a solid particle system.
  83091. * SPS internal tool, don't use it manually.
  83092. */
  83093. export class ModelShape {
  83094. /**
  83095. * The shape id
  83096. * @hidden
  83097. */
  83098. shapeID: number;
  83099. /**
  83100. * flat array of model positions (internal use)
  83101. * @hidden
  83102. */
  83103. _shape: Vector3[];
  83104. /**
  83105. * flat array of model UVs (internal use)
  83106. * @hidden
  83107. */
  83108. _shapeUV: number[];
  83109. /**
  83110. * length of the shape in the model indices array (internal use)
  83111. * @hidden
  83112. */
  83113. _indicesLength: number;
  83114. /**
  83115. * Custom position function (internal use)
  83116. * @hidden
  83117. */
  83118. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  83119. /**
  83120. * Custom vertex function (internal use)
  83121. * @hidden
  83122. */
  83123. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  83124. /**
  83125. * 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.
  83126. * SPS internal tool, don't use it manually.
  83127. * @hidden
  83128. */
  83129. 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>);
  83130. }
  83131. /**
  83132. * Represents a Depth Sorted Particle in the solid particle system.
  83133. */
  83134. export class DepthSortedParticle {
  83135. /**
  83136. * Index of the particle in the "indices" array
  83137. */
  83138. ind: number;
  83139. /**
  83140. * Length of the particle shape in the "indices" array
  83141. */
  83142. indicesLength: number;
  83143. /**
  83144. * Squared distance from the particle to the camera
  83145. */
  83146. sqDistance: number;
  83147. }
  83148. }
  83149. declare module BABYLON {
  83150. /**
  83151. * Class used to store all common mesh properties
  83152. */
  83153. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  83154. /** No occlusion */
  83155. static OCCLUSION_TYPE_NONE: number;
  83156. /** Occlusion set to optimisitic */
  83157. static OCCLUSION_TYPE_OPTIMISTIC: number;
  83158. /** Occlusion set to strict */
  83159. static OCCLUSION_TYPE_STRICT: number;
  83160. /** Use an accurante occlusion algorithm */
  83161. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  83162. /** Use a conservative occlusion algorithm */
  83163. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  83164. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  83165. * Test order :
  83166. * Is the bounding sphere outside the frustum ?
  83167. * If not, are the bounding box vertices outside the frustum ?
  83168. * It not, then the cullable object is in the frustum.
  83169. */
  83170. static readonly CULLINGSTRATEGY_STANDARD: number;
  83171. /** Culling strategy : Bounding Sphere Only.
  83172. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  83173. * It's also less accurate than the standard because some not visible objects can still be selected.
  83174. * Test : is the bounding sphere outside the frustum ?
  83175. * If not, then the cullable object is in the frustum.
  83176. */
  83177. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  83178. /** Culling strategy : Optimistic Inclusion.
  83179. * This in an inclusion test first, then the standard exclusion test.
  83180. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  83181. * 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.
  83182. * Anyway, it's as accurate as the standard strategy.
  83183. * Test :
  83184. * Is the cullable object bounding sphere center in the frustum ?
  83185. * If not, apply the default culling strategy.
  83186. */
  83187. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  83188. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  83189. * This in an inclusion test first, then the bounding sphere only exclusion test.
  83190. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  83191. * 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.
  83192. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  83193. * Test :
  83194. * Is the cullable object bounding sphere center in the frustum ?
  83195. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  83196. */
  83197. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  83198. /**
  83199. * No billboard
  83200. */
  83201. static readonly BILLBOARDMODE_NONE: number;
  83202. /** Billboard on X axis */
  83203. static readonly BILLBOARDMODE_X: number;
  83204. /** Billboard on Y axis */
  83205. static readonly BILLBOARDMODE_Y: number;
  83206. /** Billboard on Z axis */
  83207. static readonly BILLBOARDMODE_Z: number;
  83208. /** Billboard on all axes */
  83209. static readonly BILLBOARDMODE_ALL: number;
  83210. private _facetData;
  83211. /**
  83212. * The culling strategy to use to check whether the mesh must be rendered or not.
  83213. * This value can be changed at any time and will be used on the next render mesh selection.
  83214. * The possible values are :
  83215. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  83216. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  83217. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  83218. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  83219. * Please read each static variable documentation to get details about the culling process.
  83220. * */
  83221. cullingStrategy: number;
  83222. /**
  83223. * Gets the number of facets in the mesh
  83224. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  83225. */
  83226. readonly facetNb: number;
  83227. /**
  83228. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  83229. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  83230. */
  83231. partitioningSubdivisions: number;
  83232. /**
  83233. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  83234. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  83235. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  83236. */
  83237. partitioningBBoxRatio: number;
  83238. /**
  83239. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  83240. * Works only for updatable meshes.
  83241. * Doesn't work with multi-materials
  83242. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  83243. */
  83244. mustDepthSortFacets: boolean;
  83245. /**
  83246. * The location (Vector3) where the facet depth sort must be computed from.
  83247. * By default, the active camera position.
  83248. * Used only when facet depth sort is enabled
  83249. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  83250. */
  83251. facetDepthSortFrom: Vector3;
  83252. /**
  83253. * gets a boolean indicating if facetData is enabled
  83254. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  83255. */
  83256. readonly isFacetDataEnabled: boolean;
  83257. /** @hidden */
  83258. _updateNonUniformScalingState(value: boolean): boolean;
  83259. /**
  83260. * An event triggered when this mesh collides with another one
  83261. */
  83262. onCollideObservable: Observable<AbstractMesh>;
  83263. private _onCollideObserver;
  83264. /** Set a function to call when this mesh collides with another one */
  83265. onCollide: () => void;
  83266. /**
  83267. * An event triggered when the collision's position changes
  83268. */
  83269. onCollisionPositionChangeObservable: Observable<Vector3>;
  83270. private _onCollisionPositionChangeObserver;
  83271. /** Set a function to call when the collision's position changes */
  83272. onCollisionPositionChange: () => void;
  83273. /**
  83274. * An event triggered when material is changed
  83275. */
  83276. onMaterialChangedObservable: Observable<AbstractMesh>;
  83277. /**
  83278. * Gets or sets the orientation for POV movement & rotation
  83279. */
  83280. definedFacingForward: boolean;
  83281. /** @hidden */
  83282. _occlusionQuery: Nullable<WebGLQuery>;
  83283. private _visibility;
  83284. /**
  83285. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  83286. */
  83287. /**
  83288. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  83289. */
  83290. visibility: number;
  83291. /** Gets or sets the alpha index used to sort transparent meshes
  83292. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  83293. */
  83294. alphaIndex: number;
  83295. /**
  83296. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  83297. */
  83298. isVisible: boolean;
  83299. /**
  83300. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  83301. */
  83302. isPickable: boolean;
  83303. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  83304. showSubMeshesBoundingBox: boolean;
  83305. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  83306. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  83307. */
  83308. isBlocker: boolean;
  83309. /**
  83310. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  83311. */
  83312. enablePointerMoveEvents: boolean;
  83313. /**
  83314. * Specifies the rendering group id for this mesh (0 by default)
  83315. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  83316. */
  83317. renderingGroupId: number;
  83318. private _material;
  83319. /** Gets or sets current material */
  83320. material: Nullable<Material>;
  83321. private _receiveShadows;
  83322. /**
  83323. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  83324. * @see http://doc.babylonjs.com/babylon101/shadows
  83325. */
  83326. receiveShadows: boolean;
  83327. /** Defines color to use when rendering outline */
  83328. outlineColor: Color3;
  83329. /** Define width to use when rendering outline */
  83330. outlineWidth: number;
  83331. /** Defines color to use when rendering overlay */
  83332. overlayColor: Color3;
  83333. /** Defines alpha to use when rendering overlay */
  83334. overlayAlpha: number;
  83335. private _hasVertexAlpha;
  83336. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  83337. hasVertexAlpha: boolean;
  83338. private _useVertexColors;
  83339. /** 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) */
  83340. useVertexColors: boolean;
  83341. private _computeBonesUsingShaders;
  83342. /**
  83343. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  83344. */
  83345. computeBonesUsingShaders: boolean;
  83346. private _numBoneInfluencers;
  83347. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  83348. numBoneInfluencers: number;
  83349. private _applyFog;
  83350. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  83351. applyFog: boolean;
  83352. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  83353. useOctreeForRenderingSelection: boolean;
  83354. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  83355. useOctreeForPicking: boolean;
  83356. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  83357. useOctreeForCollisions: boolean;
  83358. private _layerMask;
  83359. /**
  83360. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  83361. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  83362. */
  83363. layerMask: number;
  83364. /**
  83365. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  83366. */
  83367. alwaysSelectAsActiveMesh: boolean;
  83368. /**
  83369. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  83370. */
  83371. doNotSyncBoundingInfo: boolean;
  83372. /**
  83373. * Gets or sets the current action manager
  83374. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  83375. */
  83376. actionManager: Nullable<AbstractActionManager>;
  83377. private _checkCollisions;
  83378. private _collisionMask;
  83379. private _collisionGroup;
  83380. /**
  83381. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  83382. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  83383. */
  83384. ellipsoid: Vector3;
  83385. /**
  83386. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  83387. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  83388. */
  83389. ellipsoidOffset: Vector3;
  83390. private _collider;
  83391. private _oldPositionForCollisions;
  83392. private _diffPositionForCollisions;
  83393. /**
  83394. * Gets or sets a collision mask used to mask collisions (default is -1).
  83395. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  83396. */
  83397. collisionMask: number;
  83398. /**
  83399. * Gets or sets the current collision group mask (-1 by default).
  83400. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  83401. */
  83402. collisionGroup: number;
  83403. /**
  83404. * Defines edge width used when edgesRenderer is enabled
  83405. * @see https://www.babylonjs-playground.com/#10OJSG#13
  83406. */
  83407. edgesWidth: number;
  83408. /**
  83409. * Defines edge color used when edgesRenderer is enabled
  83410. * @see https://www.babylonjs-playground.com/#10OJSG#13
  83411. */
  83412. edgesColor: Color4;
  83413. /** @hidden */
  83414. _edgesRenderer: Nullable<IEdgesRenderer>;
  83415. /** @hidden */
  83416. _masterMesh: Nullable<AbstractMesh>;
  83417. /** @hidden */
  83418. _boundingInfo: Nullable<BoundingInfo>;
  83419. /** @hidden */
  83420. _renderId: number;
  83421. /**
  83422. * Gets or sets the list of subMeshes
  83423. * @see http://doc.babylonjs.com/how_to/multi_materials
  83424. */
  83425. subMeshes: SubMesh[];
  83426. /** @hidden */
  83427. _intersectionsInProgress: AbstractMesh[];
  83428. /** @hidden */
  83429. _unIndexed: boolean;
  83430. /** @hidden */
  83431. _lightSources: Light[];
  83432. /** @hidden */
  83433. readonly _positions: Nullable<Vector3[]>;
  83434. /** @hidden */
  83435. _waitingActions: any;
  83436. /** @hidden */
  83437. _waitingFreezeWorldMatrix: Nullable<boolean>;
  83438. private _skeleton;
  83439. /** @hidden */
  83440. _bonesTransformMatrices: Nullable<Float32Array>;
  83441. /**
  83442. * Gets or sets a skeleton to apply skining transformations
  83443. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  83444. */
  83445. skeleton: Nullable<Skeleton>;
  83446. /**
  83447. * An event triggered when the mesh is rebuilt.
  83448. */
  83449. onRebuildObservable: Observable<AbstractMesh>;
  83450. /**
  83451. * Creates a new AbstractMesh
  83452. * @param name defines the name of the mesh
  83453. * @param scene defines the hosting scene
  83454. */
  83455. constructor(name: string, scene?: Nullable<Scene>);
  83456. /**
  83457. * Returns the string "AbstractMesh"
  83458. * @returns "AbstractMesh"
  83459. */
  83460. getClassName(): string;
  83461. /**
  83462. * Gets a string representation of the current mesh
  83463. * @param fullDetails defines a boolean indicating if full details must be included
  83464. * @returns a string representation of the current mesh
  83465. */
  83466. toString(fullDetails?: boolean): string;
  83467. /**
  83468. * @hidden
  83469. */
  83470. protected _getEffectiveParent(): Nullable<Node>;
  83471. /** @hidden */
  83472. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  83473. /** @hidden */
  83474. _rebuild(): void;
  83475. /** @hidden */
  83476. _resyncLightSources(): void;
  83477. /** @hidden */
  83478. _resyncLighSource(light: Light): void;
  83479. /** @hidden */
  83480. _unBindEffect(): void;
  83481. /** @hidden */
  83482. _removeLightSource(light: Light): void;
  83483. private _markSubMeshesAsDirty;
  83484. /** @hidden */
  83485. _markSubMeshesAsLightDirty(): void;
  83486. /** @hidden */
  83487. _markSubMeshesAsAttributesDirty(): void;
  83488. /** @hidden */
  83489. _markSubMeshesAsMiscDirty(): void;
  83490. /**
  83491. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  83492. */
  83493. scaling: Vector3;
  83494. /**
  83495. * Returns true if the mesh is blocked. Implemented by child classes
  83496. */
  83497. readonly isBlocked: boolean;
  83498. /**
  83499. * Returns the mesh itself by default. Implemented by child classes
  83500. * @param camera defines the camera to use to pick the right LOD level
  83501. * @returns the currentAbstractMesh
  83502. */
  83503. getLOD(camera: Camera): Nullable<AbstractMesh>;
  83504. /**
  83505. * Returns 0 by default. Implemented by child classes
  83506. * @returns an integer
  83507. */
  83508. getTotalVertices(): number;
  83509. /**
  83510. * Returns a positive integer : the total number of indices in this mesh geometry.
  83511. * @returns the numner of indices or zero if the mesh has no geometry.
  83512. */
  83513. getTotalIndices(): number;
  83514. /**
  83515. * Returns null by default. Implemented by child classes
  83516. * @returns null
  83517. */
  83518. getIndices(): Nullable<IndicesArray>;
  83519. /**
  83520. * Returns the array of the requested vertex data kind. Implemented by child classes
  83521. * @param kind defines the vertex data kind to use
  83522. * @returns null
  83523. */
  83524. getVerticesData(kind: string): Nullable<FloatArray>;
  83525. /**
  83526. * Sets the vertex data of the mesh geometry for the requested `kind`.
  83527. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  83528. * Note that a new underlying VertexBuffer object is created each call.
  83529. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  83530. * @param kind defines vertex data kind:
  83531. * * VertexBuffer.PositionKind
  83532. * * VertexBuffer.UVKind
  83533. * * VertexBuffer.UV2Kind
  83534. * * VertexBuffer.UV3Kind
  83535. * * VertexBuffer.UV4Kind
  83536. * * VertexBuffer.UV5Kind
  83537. * * VertexBuffer.UV6Kind
  83538. * * VertexBuffer.ColorKind
  83539. * * VertexBuffer.MatricesIndicesKind
  83540. * * VertexBuffer.MatricesIndicesExtraKind
  83541. * * VertexBuffer.MatricesWeightsKind
  83542. * * VertexBuffer.MatricesWeightsExtraKind
  83543. * @param data defines the data source
  83544. * @param updatable defines if the data must be flagged as updatable (or static)
  83545. * @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
  83546. * @returns the current mesh
  83547. */
  83548. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  83549. /**
  83550. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  83551. * If the mesh has no geometry, it is simply returned as it is.
  83552. * @param kind defines vertex data kind:
  83553. * * VertexBuffer.PositionKind
  83554. * * VertexBuffer.UVKind
  83555. * * VertexBuffer.UV2Kind
  83556. * * VertexBuffer.UV3Kind
  83557. * * VertexBuffer.UV4Kind
  83558. * * VertexBuffer.UV5Kind
  83559. * * VertexBuffer.UV6Kind
  83560. * * VertexBuffer.ColorKind
  83561. * * VertexBuffer.MatricesIndicesKind
  83562. * * VertexBuffer.MatricesIndicesExtraKind
  83563. * * VertexBuffer.MatricesWeightsKind
  83564. * * VertexBuffer.MatricesWeightsExtraKind
  83565. * @param data defines the data source
  83566. * @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
  83567. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  83568. * @returns the current mesh
  83569. */
  83570. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  83571. /**
  83572. * Sets the mesh indices,
  83573. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  83574. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  83575. * @param totalVertices Defines the total number of vertices
  83576. * @returns the current mesh
  83577. */
  83578. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  83579. /**
  83580. * Gets a boolean indicating if specific vertex data is present
  83581. * @param kind defines the vertex data kind to use
  83582. * @returns true is data kind is present
  83583. */
  83584. isVerticesDataPresent(kind: string): boolean;
  83585. /**
  83586. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  83587. * @returns a BoundingInfo
  83588. */
  83589. getBoundingInfo(): BoundingInfo;
  83590. /**
  83591. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  83592. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  83593. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  83594. * @returns the current mesh
  83595. */
  83596. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean): AbstractMesh;
  83597. /**
  83598. * Overwrite the current bounding info
  83599. * @param boundingInfo defines the new bounding info
  83600. * @returns the current mesh
  83601. */
  83602. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  83603. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  83604. readonly useBones: boolean;
  83605. /** @hidden */
  83606. _preActivate(): void;
  83607. /** @hidden */
  83608. _preActivateForIntermediateRendering(renderId: number): void;
  83609. /** @hidden */
  83610. _activate(renderId: number): void;
  83611. /**
  83612. * Gets the current world matrix
  83613. * @returns a Matrix
  83614. */
  83615. getWorldMatrix(): Matrix;
  83616. /** @hidden */
  83617. _getWorldMatrixDeterminant(): number;
  83618. /**
  83619. * Perform relative position change from the point of view of behind the front of the mesh.
  83620. * This is performed taking into account the meshes current rotation, so you do not have to care.
  83621. * Supports definition of mesh facing forward or backward
  83622. * @param amountRight defines the distance on the right axis
  83623. * @param amountUp defines the distance on the up axis
  83624. * @param amountForward defines the distance on the forward axis
  83625. * @returns the current mesh
  83626. */
  83627. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  83628. /**
  83629. * Calculate relative position change from the point of view of behind the front of the mesh.
  83630. * This is performed taking into account the meshes current rotation, so you do not have to care.
  83631. * Supports definition of mesh facing forward or backward
  83632. * @param amountRight defines the distance on the right axis
  83633. * @param amountUp defines the distance on the up axis
  83634. * @param amountForward defines the distance on the forward axis
  83635. * @returns the new displacement vector
  83636. */
  83637. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  83638. /**
  83639. * Perform relative rotation change from the point of view of behind the front of the mesh.
  83640. * Supports definition of mesh facing forward or backward
  83641. * @param flipBack defines the flip
  83642. * @param twirlClockwise defines the twirl
  83643. * @param tiltRight defines the tilt
  83644. * @returns the current mesh
  83645. */
  83646. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  83647. /**
  83648. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  83649. * Supports definition of mesh facing forward or backward.
  83650. * @param flipBack defines the flip
  83651. * @param twirlClockwise defines the twirl
  83652. * @param tiltRight defines the tilt
  83653. * @returns the new rotation vector
  83654. */
  83655. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  83656. /**
  83657. * Return the minimum and maximum world vectors of the entire hierarchy under current mesh
  83658. * @param includeDescendants Include bounding info from descendants as well (true by default)
  83659. * @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
  83660. * @returns the new bounding vectors
  83661. */
  83662. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  83663. min: Vector3;
  83664. max: Vector3;
  83665. };
  83666. /**
  83667. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  83668. * This means the mesh underlying bounding box and sphere are recomputed.
  83669. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  83670. * @returns the current mesh
  83671. */
  83672. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  83673. /** @hidden */
  83674. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  83675. /** @hidden */
  83676. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  83677. /** @hidden */
  83678. _updateBoundingInfo(): AbstractMesh;
  83679. /** @hidden */
  83680. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  83681. /** @hidden */
  83682. protected _afterComputeWorldMatrix(): void;
  83683. /** @hidden */
  83684. readonly _effectiveMesh: AbstractMesh;
  83685. /**
  83686. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  83687. * A mesh is in the frustum if its bounding box intersects the frustum
  83688. * @param frustumPlanes defines the frustum to test
  83689. * @returns true if the mesh is in the frustum planes
  83690. */
  83691. isInFrustum(frustumPlanes: Plane[]): boolean;
  83692. /**
  83693. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  83694. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  83695. * @param frustumPlanes defines the frustum to test
  83696. * @returns true if the mesh is completely in the frustum planes
  83697. */
  83698. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  83699. /**
  83700. * True if the mesh intersects another mesh or a SolidParticle object
  83701. * @param mesh defines a target mesh or SolidParticle to test
  83702. * @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)
  83703. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  83704. * @returns true if there is an intersection
  83705. */
  83706. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  83707. /**
  83708. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  83709. * @param point defines the point to test
  83710. * @returns true if there is an intersection
  83711. */
  83712. intersectsPoint(point: Vector3): boolean;
  83713. /**
  83714. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  83715. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  83716. */
  83717. checkCollisions: boolean;
  83718. /**
  83719. * Gets Collider object used to compute collisions (not physics)
  83720. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  83721. */
  83722. readonly collider: Collider;
  83723. /**
  83724. * Move the mesh using collision engine
  83725. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  83726. * @param displacement defines the requested displacement vector
  83727. * @returns the current mesh
  83728. */
  83729. moveWithCollisions(displacement: Vector3): AbstractMesh;
  83730. private _onCollisionPositionChange;
  83731. /** @hidden */
  83732. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  83733. /** @hidden */
  83734. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  83735. /** @hidden */
  83736. _checkCollision(collider: Collider): AbstractMesh;
  83737. /** @hidden */
  83738. _generatePointsArray(): boolean;
  83739. /**
  83740. * Checks if the passed Ray intersects with the mesh
  83741. * @param ray defines the ray to use
  83742. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  83743. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  83744. * @returns the picking info
  83745. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  83746. */
  83747. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  83748. /**
  83749. * Clones the current mesh
  83750. * @param name defines the mesh name
  83751. * @param newParent defines the new mesh parent
  83752. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  83753. * @returns the new mesh
  83754. */
  83755. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  83756. /**
  83757. * Disposes all the submeshes of the current meshnp
  83758. * @returns the current mesh
  83759. */
  83760. releaseSubMeshes(): AbstractMesh;
  83761. /**
  83762. * Releases resources associated with this abstract mesh.
  83763. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  83764. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  83765. */
  83766. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  83767. /**
  83768. * Adds the passed mesh as a child to the current mesh
  83769. * @param mesh defines the child mesh
  83770. * @returns the current mesh
  83771. */
  83772. addChild(mesh: AbstractMesh): AbstractMesh;
  83773. /**
  83774. * Removes the passed mesh from the current mesh children list
  83775. * @param mesh defines the child mesh
  83776. * @returns the current mesh
  83777. */
  83778. removeChild(mesh: AbstractMesh): AbstractMesh;
  83779. /** @hidden */
  83780. private _initFacetData;
  83781. /**
  83782. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  83783. * This method can be called within the render loop.
  83784. * 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
  83785. * @returns the current mesh
  83786. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  83787. */
  83788. updateFacetData(): AbstractMesh;
  83789. /**
  83790. * Returns the facetLocalNormals array.
  83791. * The normals are expressed in the mesh local spac
  83792. * @returns an array of Vector3
  83793. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  83794. */
  83795. getFacetLocalNormals(): Vector3[];
  83796. /**
  83797. * Returns the facetLocalPositions array.
  83798. * The facet positions are expressed in the mesh local space
  83799. * @returns an array of Vector3
  83800. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  83801. */
  83802. getFacetLocalPositions(): Vector3[];
  83803. /**
  83804. * Returns the facetLocalPartioning array
  83805. * @returns an array of array of numbers
  83806. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  83807. */
  83808. getFacetLocalPartitioning(): number[][];
  83809. /**
  83810. * Returns the i-th facet position in the world system.
  83811. * This method allocates a new Vector3 per call
  83812. * @param i defines the facet index
  83813. * @returns a new Vector3
  83814. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  83815. */
  83816. getFacetPosition(i: number): Vector3;
  83817. /**
  83818. * Sets the reference Vector3 with the i-th facet position in the world system
  83819. * @param i defines the facet index
  83820. * @param ref defines the target vector
  83821. * @returns the current mesh
  83822. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  83823. */
  83824. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  83825. /**
  83826. * Returns the i-th facet normal in the world system.
  83827. * This method allocates a new Vector3 per call
  83828. * @param i defines the facet index
  83829. * @returns a new Vector3
  83830. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  83831. */
  83832. getFacetNormal(i: number): Vector3;
  83833. /**
  83834. * Sets the reference Vector3 with the i-th facet normal in the world system
  83835. * @param i defines the facet index
  83836. * @param ref defines the target vector
  83837. * @returns the current mesh
  83838. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  83839. */
  83840. getFacetNormalToRef(i: number, ref: Vector3): this;
  83841. /**
  83842. * 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)
  83843. * @param x defines x coordinate
  83844. * @param y defines y coordinate
  83845. * @param z defines z coordinate
  83846. * @returns the array of facet indexes
  83847. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  83848. */
  83849. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  83850. /**
  83851. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  83852. * @param projected sets as the (x,y,z) world projection on the facet
  83853. * @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
  83854. * @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
  83855. * @param x defines x coordinate
  83856. * @param y defines y coordinate
  83857. * @param z defines z coordinate
  83858. * @returns the face index if found (or null instead)
  83859. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  83860. */
  83861. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  83862. /**
  83863. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  83864. * @param projected sets as the (x,y,z) local projection on the facet
  83865. * @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
  83866. * @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
  83867. * @param x defines x coordinate
  83868. * @param y defines y coordinate
  83869. * @param z defines z coordinate
  83870. * @returns the face index if found (or null instead)
  83871. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  83872. */
  83873. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  83874. /**
  83875. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  83876. * @returns the parameters
  83877. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  83878. */
  83879. getFacetDataParameters(): any;
  83880. /**
  83881. * Disables the feature FacetData and frees the related memory
  83882. * @returns the current mesh
  83883. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  83884. */
  83885. disableFacetData(): AbstractMesh;
  83886. /**
  83887. * Updates the AbstractMesh indices array
  83888. * @param indices defines the data source
  83889. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  83890. * @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)
  83891. * @returns the current mesh
  83892. */
  83893. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  83894. /**
  83895. * Creates new normals data for the mesh
  83896. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  83897. * @returns the current mesh
  83898. */
  83899. createNormals(updatable: boolean): AbstractMesh;
  83900. /**
  83901. * Align the mesh with a normal
  83902. * @param normal defines the normal to use
  83903. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  83904. * @returns the current mesh
  83905. */
  83906. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  83907. /** @hidden */
  83908. _checkOcclusionQuery(): boolean;
  83909. }
  83910. }
  83911. declare module BABYLON {
  83912. /**
  83913. * Interface used to define ActionEvent
  83914. */
  83915. export interface IActionEvent {
  83916. /** The mesh or sprite that triggered the action */
  83917. source: any;
  83918. /** The X mouse cursor position at the time of the event */
  83919. pointerX: number;
  83920. /** The Y mouse cursor position at the time of the event */
  83921. pointerY: number;
  83922. /** The mesh that is currently pointed at (can be null) */
  83923. meshUnderPointer: Nullable<AbstractMesh>;
  83924. /** the original (browser) event that triggered the ActionEvent */
  83925. sourceEvent?: any;
  83926. /** additional data for the event */
  83927. additionalData?: any;
  83928. }
  83929. /**
  83930. * ActionEvent is the event being sent when an action is triggered.
  83931. */
  83932. export class ActionEvent implements IActionEvent {
  83933. /** The mesh or sprite that triggered the action */
  83934. source: any;
  83935. /** The X mouse cursor position at the time of the event */
  83936. pointerX: number;
  83937. /** The Y mouse cursor position at the time of the event */
  83938. pointerY: number;
  83939. /** The mesh that is currently pointed at (can be null) */
  83940. meshUnderPointer: Nullable<AbstractMesh>;
  83941. /** the original (browser) event that triggered the ActionEvent */
  83942. sourceEvent?: any;
  83943. /** additional data for the event */
  83944. additionalData?: any;
  83945. /**
  83946. * Creates a new ActionEvent
  83947. * @param source The mesh or sprite that triggered the action
  83948. * @param pointerX The X mouse cursor position at the time of the event
  83949. * @param pointerY The Y mouse cursor position at the time of the event
  83950. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  83951. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  83952. * @param additionalData additional data for the event
  83953. */
  83954. constructor(
  83955. /** The mesh or sprite that triggered the action */
  83956. source: any,
  83957. /** The X mouse cursor position at the time of the event */
  83958. pointerX: number,
  83959. /** The Y mouse cursor position at the time of the event */
  83960. pointerY: number,
  83961. /** The mesh that is currently pointed at (can be null) */
  83962. meshUnderPointer: Nullable<AbstractMesh>,
  83963. /** the original (browser) event that triggered the ActionEvent */
  83964. sourceEvent?: any,
  83965. /** additional data for the event */
  83966. additionalData?: any);
  83967. /**
  83968. * Helper function to auto-create an ActionEvent from a source mesh.
  83969. * @param source The source mesh that triggered the event
  83970. * @param evt The original (browser) event
  83971. * @param additionalData additional data for the event
  83972. * @returns the new ActionEvent
  83973. */
  83974. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  83975. /**
  83976. * Helper function to auto-create an ActionEvent from a source sprite
  83977. * @param source The source sprite that triggered the event
  83978. * @param scene Scene associated with the sprite
  83979. * @param evt The original (browser) event
  83980. * @param additionalData additional data for the event
  83981. * @returns the new ActionEvent
  83982. */
  83983. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  83984. /**
  83985. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  83986. * @param scene the scene where the event occurred
  83987. * @param evt The original (browser) event
  83988. * @returns the new ActionEvent
  83989. */
  83990. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  83991. /**
  83992. * Helper function to auto-create an ActionEvent from a primitive
  83993. * @param prim defines the target primitive
  83994. * @param pointerPos defines the pointer position
  83995. * @param evt The original (browser) event
  83996. * @param additionalData additional data for the event
  83997. * @returns the new ActionEvent
  83998. */
  83999. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  84000. }
  84001. }
  84002. declare module BABYLON {
  84003. /**
  84004. * Abstract class used to decouple action Manager from scene and meshes.
  84005. * Do not instantiate.
  84006. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  84007. */
  84008. export abstract class AbstractActionManager implements IDisposable {
  84009. /** Gets the list of active triggers */
  84010. static Triggers: {
  84011. [key: string]: number;
  84012. };
  84013. /** Gets the cursor to use when hovering items */
  84014. hoverCursor: string;
  84015. /** Gets the list of actions */
  84016. actions: IAction[];
  84017. /**
  84018. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  84019. */
  84020. isRecursive: boolean;
  84021. /**
  84022. * Releases all associated resources
  84023. */
  84024. abstract dispose(): void;
  84025. /**
  84026. * Does this action manager has pointer triggers
  84027. */
  84028. abstract readonly hasPointerTriggers: boolean;
  84029. /**
  84030. * Does this action manager has pick triggers
  84031. */
  84032. abstract readonly hasPickTriggers: boolean;
  84033. /**
  84034. * Process a specific trigger
  84035. * @param trigger defines the trigger to process
  84036. * @param evt defines the event details to be processed
  84037. */
  84038. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  84039. /**
  84040. * Does this action manager handles actions of any of the given triggers
  84041. * @param triggers defines the triggers to be tested
  84042. * @return a boolean indicating whether one (or more) of the triggers is handled
  84043. */
  84044. abstract hasSpecificTriggers(triggers: number[]): boolean;
  84045. /**
  84046. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  84047. * speed.
  84048. * @param triggerA defines the trigger to be tested
  84049. * @param triggerB defines the trigger to be tested
  84050. * @return a boolean indicating whether one (or more) of the triggers is handled
  84051. */
  84052. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  84053. /**
  84054. * Does this action manager handles actions of a given trigger
  84055. * @param trigger defines the trigger to be tested
  84056. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  84057. * @return whether the trigger is handled
  84058. */
  84059. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  84060. /**
  84061. * Serialize this manager to a JSON object
  84062. * @param name defines the property name to store this manager
  84063. * @returns a JSON representation of this manager
  84064. */
  84065. abstract serialize(name: string): any;
  84066. /**
  84067. * Registers an action to this action manager
  84068. * @param action defines the action to be registered
  84069. * @return the action amended (prepared) after registration
  84070. */
  84071. abstract registerAction(action: IAction): Nullable<IAction>;
  84072. /**
  84073. * Unregisters an action to this action manager
  84074. * @param action defines the action to be unregistered
  84075. * @return a boolean indicating whether the action has been unregistered
  84076. */
  84077. abstract unregisterAction(action: IAction): Boolean;
  84078. /**
  84079. * Does exist one action manager with at least one trigger
  84080. **/
  84081. static readonly HasTriggers: boolean;
  84082. /**
  84083. * Does exist one action manager with at least one pick trigger
  84084. **/
  84085. static readonly HasPickTriggers: boolean;
  84086. /**
  84087. * Does exist one action manager that handles actions of a given trigger
  84088. * @param trigger defines the trigger to be tested
  84089. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  84090. **/
  84091. static HasSpecificTrigger(trigger: number): boolean;
  84092. }
  84093. }
  84094. declare module BABYLON {
  84095. /**
  84096. * Defines how a node can be built from a string name.
  84097. */
  84098. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  84099. /**
  84100. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  84101. */
  84102. export class Node implements IBehaviorAware<Node> {
  84103. /** @hidden */
  84104. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  84105. private static _NodeConstructors;
  84106. /**
  84107. * Add a new node constructor
  84108. * @param type defines the type name of the node to construct
  84109. * @param constructorFunc defines the constructor function
  84110. */
  84111. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  84112. /**
  84113. * Returns a node constructor based on type name
  84114. * @param type defines the type name
  84115. * @param name defines the new node name
  84116. * @param scene defines the hosting scene
  84117. * @param options defines optional options to transmit to constructors
  84118. * @returns the new constructor or null
  84119. */
  84120. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  84121. /**
  84122. * Gets or sets the name of the node
  84123. */
  84124. name: string;
  84125. /**
  84126. * Gets or sets the id of the node
  84127. */
  84128. id: string;
  84129. /**
  84130. * Gets or sets the unique id of the node
  84131. */
  84132. uniqueId: number;
  84133. /**
  84134. * Gets or sets a string used to store user defined state for the node
  84135. */
  84136. state: string;
  84137. /**
  84138. * Gets or sets an object used to store user defined information for the node
  84139. */
  84140. metadata: any;
  84141. /**
  84142. * For internal use only. Please do not use.
  84143. */
  84144. reservedDataStore: any;
  84145. /**
  84146. * List of inspectable custom properties (used by the Inspector)
  84147. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  84148. */
  84149. inspectableCustomProperties: IInspectable[];
  84150. /**
  84151. * Gets or sets a boolean used to define if the node must be serialized
  84152. */
  84153. doNotSerialize: boolean;
  84154. /** @hidden */
  84155. _isDisposed: boolean;
  84156. /**
  84157. * Gets a list of Animations associated with the node
  84158. */
  84159. animations: Animation[];
  84160. protected _ranges: {
  84161. [name: string]: Nullable<AnimationRange>;
  84162. };
  84163. /**
  84164. * Callback raised when the node is ready to be used
  84165. */
  84166. onReady: (node: Node) => void;
  84167. private _isEnabled;
  84168. private _isParentEnabled;
  84169. private _isReady;
  84170. /** @hidden */
  84171. _currentRenderId: number;
  84172. private _parentUpdateId;
  84173. protected _childUpdateId: number;
  84174. /** @hidden */
  84175. _waitingParentId: Nullable<string>;
  84176. /** @hidden */
  84177. _scene: Scene;
  84178. /** @hidden */
  84179. _cache: any;
  84180. private _parentNode;
  84181. private _children;
  84182. /** @hidden */
  84183. _worldMatrix: Matrix;
  84184. /** @hidden */
  84185. _worldMatrixDeterminant: number;
  84186. /** @hidden */
  84187. private _sceneRootNodesIndex;
  84188. /**
  84189. * Gets a boolean indicating if the node has been disposed
  84190. * @returns true if the node was disposed
  84191. */
  84192. isDisposed(): boolean;
  84193. /**
  84194. * Gets or sets the parent of the node (without keeping the current position in the scene)
  84195. * @see https://doc.babylonjs.com/how_to/parenting
  84196. */
  84197. parent: Nullable<Node>;
  84198. private addToSceneRootNodes;
  84199. private removeFromSceneRootNodes;
  84200. private _animationPropertiesOverride;
  84201. /**
  84202. * Gets or sets the animation properties override
  84203. */
  84204. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  84205. /**
  84206. * Gets a string idenfifying the name of the class
  84207. * @returns "Node" string
  84208. */
  84209. getClassName(): string;
  84210. /** @hidden */
  84211. readonly _isNode: boolean;
  84212. /**
  84213. * An event triggered when the mesh is disposed
  84214. */
  84215. onDisposeObservable: Observable<Node>;
  84216. private _onDisposeObserver;
  84217. /**
  84218. * Sets a callback that will be raised when the node will be disposed
  84219. */
  84220. onDispose: () => void;
  84221. /**
  84222. * Creates a new Node
  84223. * @param name the name and id to be given to this node
  84224. * @param scene the scene this node will be added to
  84225. * @param addToRootNodes the node will be added to scene.rootNodes
  84226. */
  84227. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  84228. /**
  84229. * Gets the scene of the node
  84230. * @returns a scene
  84231. */
  84232. getScene(): Scene;
  84233. /**
  84234. * Gets the engine of the node
  84235. * @returns a Engine
  84236. */
  84237. getEngine(): Engine;
  84238. private _behaviors;
  84239. /**
  84240. * Attach a behavior to the node
  84241. * @see http://doc.babylonjs.com/features/behaviour
  84242. * @param behavior defines the behavior to attach
  84243. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  84244. * @returns the current Node
  84245. */
  84246. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  84247. /**
  84248. * Remove an attached behavior
  84249. * @see http://doc.babylonjs.com/features/behaviour
  84250. * @param behavior defines the behavior to attach
  84251. * @returns the current Node
  84252. */
  84253. removeBehavior(behavior: Behavior<Node>): Node;
  84254. /**
  84255. * Gets the list of attached behaviors
  84256. * @see http://doc.babylonjs.com/features/behaviour
  84257. */
  84258. readonly behaviors: Behavior<Node>[];
  84259. /**
  84260. * Gets an attached behavior by name
  84261. * @param name defines the name of the behavior to look for
  84262. * @see http://doc.babylonjs.com/features/behaviour
  84263. * @returns null if behavior was not found else the requested behavior
  84264. */
  84265. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  84266. /**
  84267. * Returns the latest update of the World matrix
  84268. * @returns a Matrix
  84269. */
  84270. getWorldMatrix(): Matrix;
  84271. /** @hidden */
  84272. _getWorldMatrixDeterminant(): number;
  84273. /**
  84274. * Returns directly the latest state of the mesh World matrix.
  84275. * A Matrix is returned.
  84276. */
  84277. readonly worldMatrixFromCache: Matrix;
  84278. /** @hidden */
  84279. _initCache(): void;
  84280. /** @hidden */
  84281. updateCache(force?: boolean): void;
  84282. /** @hidden */
  84283. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  84284. /** @hidden */
  84285. _updateCache(ignoreParentClass?: boolean): void;
  84286. /** @hidden */
  84287. _isSynchronized(): boolean;
  84288. /** @hidden */
  84289. _markSyncedWithParent(): void;
  84290. /** @hidden */
  84291. isSynchronizedWithParent(): boolean;
  84292. /** @hidden */
  84293. isSynchronized(): boolean;
  84294. /**
  84295. * Is this node ready to be used/rendered
  84296. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  84297. * @return true if the node is ready
  84298. */
  84299. isReady(completeCheck?: boolean): boolean;
  84300. /**
  84301. * Is this node enabled?
  84302. * 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
  84303. * @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
  84304. * @return whether this node (and its parent) is enabled
  84305. */
  84306. isEnabled(checkAncestors?: boolean): boolean;
  84307. /** @hidden */
  84308. protected _syncParentEnabledState(): void;
  84309. /**
  84310. * Set the enabled state of this node
  84311. * @param value defines the new enabled state
  84312. */
  84313. setEnabled(value: boolean): void;
  84314. /**
  84315. * Is this node a descendant of the given node?
  84316. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  84317. * @param ancestor defines the parent node to inspect
  84318. * @returns a boolean indicating if this node is a descendant of the given node
  84319. */
  84320. isDescendantOf(ancestor: Node): boolean;
  84321. /** @hidden */
  84322. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  84323. /**
  84324. * Will return all nodes that have this node as ascendant
  84325. * @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
  84326. * @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
  84327. * @return all children nodes of all types
  84328. */
  84329. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  84330. /**
  84331. * Get all child-meshes of this node
  84332. * @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)
  84333. * @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
  84334. * @returns an array of AbstractMesh
  84335. */
  84336. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  84337. /**
  84338. * Get all direct children of this node
  84339. * @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
  84340. * @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)
  84341. * @returns an array of Node
  84342. */
  84343. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  84344. /** @hidden */
  84345. _setReady(state: boolean): void;
  84346. /**
  84347. * Get an animation by name
  84348. * @param name defines the name of the animation to look for
  84349. * @returns null if not found else the requested animation
  84350. */
  84351. getAnimationByName(name: string): Nullable<Animation>;
  84352. /**
  84353. * Creates an animation range for this node
  84354. * @param name defines the name of the range
  84355. * @param from defines the starting key
  84356. * @param to defines the end key
  84357. */
  84358. createAnimationRange(name: string, from: number, to: number): void;
  84359. /**
  84360. * Delete a specific animation range
  84361. * @param name defines the name of the range to delete
  84362. * @param deleteFrames defines if animation frames from the range must be deleted as well
  84363. */
  84364. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  84365. /**
  84366. * Get an animation range by name
  84367. * @param name defines the name of the animation range to look for
  84368. * @returns null if not found else the requested animation range
  84369. */
  84370. getAnimationRange(name: string): Nullable<AnimationRange>;
  84371. /**
  84372. * Gets the list of all animation ranges defined on this node
  84373. * @returns an array
  84374. */
  84375. getAnimationRanges(): Nullable<AnimationRange>[];
  84376. /**
  84377. * Will start the animation sequence
  84378. * @param name defines the range frames for animation sequence
  84379. * @param loop defines if the animation should loop (false by default)
  84380. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  84381. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  84382. * @returns the object created for this animation. If range does not exist, it will return null
  84383. */
  84384. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  84385. /**
  84386. * Serialize animation ranges into a JSON compatible object
  84387. * @returns serialization object
  84388. */
  84389. serializeAnimationRanges(): any;
  84390. /**
  84391. * Computes the world matrix of the node
  84392. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  84393. * @returns the world matrix
  84394. */
  84395. computeWorldMatrix(force?: boolean): Matrix;
  84396. /**
  84397. * Releases resources associated with this node.
  84398. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  84399. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  84400. */
  84401. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  84402. /**
  84403. * Parse animation range data from a serialization object and store them into a given node
  84404. * @param node defines where to store the animation ranges
  84405. * @param parsedNode defines the serialization object to read data from
  84406. * @param scene defines the hosting scene
  84407. */
  84408. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  84409. }
  84410. }
  84411. declare module BABYLON {
  84412. /**
  84413. * Class used to store any kind of animation
  84414. */
  84415. export class Animation {
  84416. /**Name of the animation */
  84417. name: string;
  84418. /**Property to animate */
  84419. targetProperty: string;
  84420. /**The frames per second of the animation */
  84421. framePerSecond: number;
  84422. /**The data type of the animation */
  84423. dataType: number;
  84424. /**The loop mode of the animation */
  84425. loopMode?: number | undefined;
  84426. /**Specifies if blending should be enabled */
  84427. enableBlending?: boolean | undefined;
  84428. /**
  84429. * Use matrix interpolation instead of using direct key value when animating matrices
  84430. */
  84431. static AllowMatricesInterpolation: boolean;
  84432. /**
  84433. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  84434. */
  84435. static AllowMatrixDecomposeForInterpolation: boolean;
  84436. /**
  84437. * Stores the key frames of the animation
  84438. */
  84439. private _keys;
  84440. /**
  84441. * Stores the easing function of the animation
  84442. */
  84443. private _easingFunction;
  84444. /**
  84445. * @hidden Internal use only
  84446. */
  84447. _runtimeAnimations: RuntimeAnimation[];
  84448. /**
  84449. * The set of event that will be linked to this animation
  84450. */
  84451. private _events;
  84452. /**
  84453. * Stores an array of target property paths
  84454. */
  84455. targetPropertyPath: string[];
  84456. /**
  84457. * Stores the blending speed of the animation
  84458. */
  84459. blendingSpeed: number;
  84460. /**
  84461. * Stores the animation ranges for the animation
  84462. */
  84463. private _ranges;
  84464. /**
  84465. * @hidden Internal use
  84466. */
  84467. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  84468. /**
  84469. * Sets up an animation
  84470. * @param property The property to animate
  84471. * @param animationType The animation type to apply
  84472. * @param framePerSecond The frames per second of the animation
  84473. * @param easingFunction The easing function used in the animation
  84474. * @returns The created animation
  84475. */
  84476. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  84477. /**
  84478. * Create and start an animation on a node
  84479. * @param name defines the name of the global animation that will be run on all nodes
  84480. * @param node defines the root node where the animation will take place
  84481. * @param targetProperty defines property to animate
  84482. * @param framePerSecond defines the number of frame per second yo use
  84483. * @param totalFrame defines the number of frames in total
  84484. * @param from defines the initial value
  84485. * @param to defines the final value
  84486. * @param loopMode defines which loop mode you want to use (off by default)
  84487. * @param easingFunction defines the easing function to use (linear by default)
  84488. * @param onAnimationEnd defines the callback to call when animation end
  84489. * @returns the animatable created for this animation
  84490. */
  84491. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  84492. /**
  84493. * Create and start an animation on a node and its descendants
  84494. * @param name defines the name of the global animation that will be run on all nodes
  84495. * @param node defines the root node where the animation will take place
  84496. * @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
  84497. * @param targetProperty defines property to animate
  84498. * @param framePerSecond defines the number of frame per second to use
  84499. * @param totalFrame defines the number of frames in total
  84500. * @param from defines the initial value
  84501. * @param to defines the final value
  84502. * @param loopMode defines which loop mode you want to use (off by default)
  84503. * @param easingFunction defines the easing function to use (linear by default)
  84504. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  84505. * @returns the list of animatables created for all nodes
  84506. * @example https://www.babylonjs-playground.com/#MH0VLI
  84507. */
  84508. 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[]>;
  84509. /**
  84510. * Creates a new animation, merges it with the existing animations and starts it
  84511. * @param name Name of the animation
  84512. * @param node Node which contains the scene that begins the animations
  84513. * @param targetProperty Specifies which property to animate
  84514. * @param framePerSecond The frames per second of the animation
  84515. * @param totalFrame The total number of frames
  84516. * @param from The frame at the beginning of the animation
  84517. * @param to The frame at the end of the animation
  84518. * @param loopMode Specifies the loop mode of the animation
  84519. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  84520. * @param onAnimationEnd Callback to run once the animation is complete
  84521. * @returns Nullable animation
  84522. */
  84523. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  84524. /**
  84525. * Transition property of an host to the target Value
  84526. * @param property The property to transition
  84527. * @param targetValue The target Value of the property
  84528. * @param host The object where the property to animate belongs
  84529. * @param scene Scene used to run the animation
  84530. * @param frameRate Framerate (in frame/s) to use
  84531. * @param transition The transition type we want to use
  84532. * @param duration The duration of the animation, in milliseconds
  84533. * @param onAnimationEnd Callback trigger at the end of the animation
  84534. * @returns Nullable animation
  84535. */
  84536. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  84537. /**
  84538. * Return the array of runtime animations currently using this animation
  84539. */
  84540. readonly runtimeAnimations: RuntimeAnimation[];
  84541. /**
  84542. * Specifies if any of the runtime animations are currently running
  84543. */
  84544. readonly hasRunningRuntimeAnimations: boolean;
  84545. /**
  84546. * Initializes the animation
  84547. * @param name Name of the animation
  84548. * @param targetProperty Property to animate
  84549. * @param framePerSecond The frames per second of the animation
  84550. * @param dataType The data type of the animation
  84551. * @param loopMode The loop mode of the animation
  84552. * @param enableBlending Specifies if blending should be enabled
  84553. */
  84554. constructor(
  84555. /**Name of the animation */
  84556. name: string,
  84557. /**Property to animate */
  84558. targetProperty: string,
  84559. /**The frames per second of the animation */
  84560. framePerSecond: number,
  84561. /**The data type of the animation */
  84562. dataType: number,
  84563. /**The loop mode of the animation */
  84564. loopMode?: number | undefined,
  84565. /**Specifies if blending should be enabled */
  84566. enableBlending?: boolean | undefined);
  84567. /**
  84568. * Converts the animation to a string
  84569. * @param fullDetails support for multiple levels of logging within scene loading
  84570. * @returns String form of the animation
  84571. */
  84572. toString(fullDetails?: boolean): string;
  84573. /**
  84574. * Add an event to this animation
  84575. * @param event Event to add
  84576. */
  84577. addEvent(event: AnimationEvent): void;
  84578. /**
  84579. * Remove all events found at the given frame
  84580. * @param frame The frame to remove events from
  84581. */
  84582. removeEvents(frame: number): void;
  84583. /**
  84584. * Retrieves all the events from the animation
  84585. * @returns Events from the animation
  84586. */
  84587. getEvents(): AnimationEvent[];
  84588. /**
  84589. * Creates an animation range
  84590. * @param name Name of the animation range
  84591. * @param from Starting frame of the animation range
  84592. * @param to Ending frame of the animation
  84593. */
  84594. createRange(name: string, from: number, to: number): void;
  84595. /**
  84596. * Deletes an animation range by name
  84597. * @param name Name of the animation range to delete
  84598. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  84599. */
  84600. deleteRange(name: string, deleteFrames?: boolean): void;
  84601. /**
  84602. * Gets the animation range by name, or null if not defined
  84603. * @param name Name of the animation range
  84604. * @returns Nullable animation range
  84605. */
  84606. getRange(name: string): Nullable<AnimationRange>;
  84607. /**
  84608. * Gets the key frames from the animation
  84609. * @returns The key frames of the animation
  84610. */
  84611. getKeys(): Array<IAnimationKey>;
  84612. /**
  84613. * Gets the highest frame rate of the animation
  84614. * @returns Highest frame rate of the animation
  84615. */
  84616. getHighestFrame(): number;
  84617. /**
  84618. * Gets the easing function of the animation
  84619. * @returns Easing function of the animation
  84620. */
  84621. getEasingFunction(): IEasingFunction;
  84622. /**
  84623. * Sets the easing function of the animation
  84624. * @param easingFunction A custom mathematical formula for animation
  84625. */
  84626. setEasingFunction(easingFunction: EasingFunction): void;
  84627. /**
  84628. * Interpolates a scalar linearly
  84629. * @param startValue Start value of the animation curve
  84630. * @param endValue End value of the animation curve
  84631. * @param gradient Scalar amount to interpolate
  84632. * @returns Interpolated scalar value
  84633. */
  84634. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  84635. /**
  84636. * Interpolates a scalar cubically
  84637. * @param startValue Start value of the animation curve
  84638. * @param outTangent End tangent of the animation
  84639. * @param endValue End value of the animation curve
  84640. * @param inTangent Start tangent of the animation curve
  84641. * @param gradient Scalar amount to interpolate
  84642. * @returns Interpolated scalar value
  84643. */
  84644. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  84645. /**
  84646. * Interpolates a quaternion using a spherical linear interpolation
  84647. * @param startValue Start value of the animation curve
  84648. * @param endValue End value of the animation curve
  84649. * @param gradient Scalar amount to interpolate
  84650. * @returns Interpolated quaternion value
  84651. */
  84652. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  84653. /**
  84654. * Interpolates a quaternion cubically
  84655. * @param startValue Start value of the animation curve
  84656. * @param outTangent End tangent of the animation curve
  84657. * @param endValue End value of the animation curve
  84658. * @param inTangent Start tangent of the animation curve
  84659. * @param gradient Scalar amount to interpolate
  84660. * @returns Interpolated quaternion value
  84661. */
  84662. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  84663. /**
  84664. * Interpolates a Vector3 linearl
  84665. * @param startValue Start value of the animation curve
  84666. * @param endValue End value of the animation curve
  84667. * @param gradient Scalar amount to interpolate
  84668. * @returns Interpolated scalar value
  84669. */
  84670. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  84671. /**
  84672. * Interpolates a Vector3 cubically
  84673. * @param startValue Start value of the animation curve
  84674. * @param outTangent End tangent of the animation
  84675. * @param endValue End value of the animation curve
  84676. * @param inTangent Start tangent of the animation curve
  84677. * @param gradient Scalar amount to interpolate
  84678. * @returns InterpolatedVector3 value
  84679. */
  84680. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  84681. /**
  84682. * Interpolates a Vector2 linearly
  84683. * @param startValue Start value of the animation curve
  84684. * @param endValue End value of the animation curve
  84685. * @param gradient Scalar amount to interpolate
  84686. * @returns Interpolated Vector2 value
  84687. */
  84688. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  84689. /**
  84690. * Interpolates a Vector2 cubically
  84691. * @param startValue Start value of the animation curve
  84692. * @param outTangent End tangent of the animation
  84693. * @param endValue End value of the animation curve
  84694. * @param inTangent Start tangent of the animation curve
  84695. * @param gradient Scalar amount to interpolate
  84696. * @returns Interpolated Vector2 value
  84697. */
  84698. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  84699. /**
  84700. * Interpolates a size linearly
  84701. * @param startValue Start value of the animation curve
  84702. * @param endValue End value of the animation curve
  84703. * @param gradient Scalar amount to interpolate
  84704. * @returns Interpolated Size value
  84705. */
  84706. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  84707. /**
  84708. * Interpolates a Color3 linearly
  84709. * @param startValue Start value of the animation curve
  84710. * @param endValue End value of the animation curve
  84711. * @param gradient Scalar amount to interpolate
  84712. * @returns Interpolated Color3 value
  84713. */
  84714. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  84715. /**
  84716. * @hidden Internal use only
  84717. */
  84718. _getKeyValue(value: any): any;
  84719. /**
  84720. * @hidden Internal use only
  84721. */
  84722. _interpolate(currentFrame: number, repeatCount: number, workValue?: any, loopMode?: number, offsetValue?: any, highLimitValue?: any): any;
  84723. /**
  84724. * Defines the function to use to interpolate matrices
  84725. * @param startValue defines the start matrix
  84726. * @param endValue defines the end matrix
  84727. * @param gradient defines the gradient between both matrices
  84728. * @param result defines an optional target matrix where to store the interpolation
  84729. * @returns the interpolated matrix
  84730. */
  84731. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  84732. /**
  84733. * Makes a copy of the animation
  84734. * @returns Cloned animation
  84735. */
  84736. clone(): Animation;
  84737. /**
  84738. * Sets the key frames of the animation
  84739. * @param values The animation key frames to set
  84740. */
  84741. setKeys(values: Array<IAnimationKey>): void;
  84742. /**
  84743. * Serializes the animation to an object
  84744. * @returns Serialized object
  84745. */
  84746. serialize(): any;
  84747. /**
  84748. * Float animation type
  84749. */
  84750. private static _ANIMATIONTYPE_FLOAT;
  84751. /**
  84752. * Vector3 animation type
  84753. */
  84754. private static _ANIMATIONTYPE_VECTOR3;
  84755. /**
  84756. * Quaternion animation type
  84757. */
  84758. private static _ANIMATIONTYPE_QUATERNION;
  84759. /**
  84760. * Matrix animation type
  84761. */
  84762. private static _ANIMATIONTYPE_MATRIX;
  84763. /**
  84764. * Color3 animation type
  84765. */
  84766. private static _ANIMATIONTYPE_COLOR3;
  84767. /**
  84768. * Vector2 animation type
  84769. */
  84770. private static _ANIMATIONTYPE_VECTOR2;
  84771. /**
  84772. * Size animation type
  84773. */
  84774. private static _ANIMATIONTYPE_SIZE;
  84775. /**
  84776. * Relative Loop Mode
  84777. */
  84778. private static _ANIMATIONLOOPMODE_RELATIVE;
  84779. /**
  84780. * Cycle Loop Mode
  84781. */
  84782. private static _ANIMATIONLOOPMODE_CYCLE;
  84783. /**
  84784. * Constant Loop Mode
  84785. */
  84786. private static _ANIMATIONLOOPMODE_CONSTANT;
  84787. /**
  84788. * Get the float animation type
  84789. */
  84790. static readonly ANIMATIONTYPE_FLOAT: number;
  84791. /**
  84792. * Get the Vector3 animation type
  84793. */
  84794. static readonly ANIMATIONTYPE_VECTOR3: number;
  84795. /**
  84796. * Get the Vector2 animation type
  84797. */
  84798. static readonly ANIMATIONTYPE_VECTOR2: number;
  84799. /**
  84800. * Get the Size animation type
  84801. */
  84802. static readonly ANIMATIONTYPE_SIZE: number;
  84803. /**
  84804. * Get the Quaternion animation type
  84805. */
  84806. static readonly ANIMATIONTYPE_QUATERNION: number;
  84807. /**
  84808. * Get the Matrix animation type
  84809. */
  84810. static readonly ANIMATIONTYPE_MATRIX: number;
  84811. /**
  84812. * Get the Color3 animation type
  84813. */
  84814. static readonly ANIMATIONTYPE_COLOR3: number;
  84815. /**
  84816. * Get the Relative Loop Mode
  84817. */
  84818. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  84819. /**
  84820. * Get the Cycle Loop Mode
  84821. */
  84822. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  84823. /**
  84824. * Get the Constant Loop Mode
  84825. */
  84826. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  84827. /** @hidden */
  84828. static _UniversalLerp(left: any, right: any, amount: number): any;
  84829. /**
  84830. * Parses an animation object and creates an animation
  84831. * @param parsedAnimation Parsed animation object
  84832. * @returns Animation object
  84833. */
  84834. static Parse(parsedAnimation: any): Animation;
  84835. /**
  84836. * Appends the serialized animations from the source animations
  84837. * @param source Source containing the animations
  84838. * @param destination Target to store the animations
  84839. */
  84840. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  84841. }
  84842. }
  84843. declare module BABYLON {
  84844. /**
  84845. * Base class of all the textures in babylon.
  84846. * It groups all the common properties the materials, post process, lights... might need
  84847. * in order to make a correct use of the texture.
  84848. */
  84849. export class BaseTexture implements IAnimatable {
  84850. /**
  84851. * Default anisotropic filtering level for the application.
  84852. * It is set to 4 as a good tradeoff between perf and quality.
  84853. */
  84854. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  84855. /**
  84856. * Gets or sets the unique id of the texture
  84857. */
  84858. uniqueId: number;
  84859. /**
  84860. * Define the name of the texture.
  84861. */
  84862. name: string;
  84863. /**
  84864. * Gets or sets an object used to store user defined information.
  84865. */
  84866. metadata: any;
  84867. /**
  84868. * For internal use only. Please do not use.
  84869. */
  84870. reservedDataStore: any;
  84871. private _hasAlpha;
  84872. /**
  84873. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  84874. */
  84875. hasAlpha: boolean;
  84876. /**
  84877. * Defines if the alpha value should be determined via the rgb values.
  84878. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  84879. */
  84880. getAlphaFromRGB: boolean;
  84881. /**
  84882. * Intensity or strength of the texture.
  84883. * It is commonly used by materials to fine tune the intensity of the texture
  84884. */
  84885. level: number;
  84886. /**
  84887. * Define the UV chanel to use starting from 0 and defaulting to 0.
  84888. * This is part of the texture as textures usually maps to one uv set.
  84889. */
  84890. coordinatesIndex: number;
  84891. private _coordinatesMode;
  84892. /**
  84893. * How a texture is mapped.
  84894. *
  84895. * | Value | Type | Description |
  84896. * | ----- | ----------------------------------- | ----------- |
  84897. * | 0 | EXPLICIT_MODE | |
  84898. * | 1 | SPHERICAL_MODE | |
  84899. * | 2 | PLANAR_MODE | |
  84900. * | 3 | CUBIC_MODE | |
  84901. * | 4 | PROJECTION_MODE | |
  84902. * | 5 | SKYBOX_MODE | |
  84903. * | 6 | INVCUBIC_MODE | |
  84904. * | 7 | EQUIRECTANGULAR_MODE | |
  84905. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  84906. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  84907. */
  84908. coordinatesMode: number;
  84909. /**
  84910. * | Value | Type | Description |
  84911. * | ----- | ------------------ | ----------- |
  84912. * | 0 | CLAMP_ADDRESSMODE | |
  84913. * | 1 | WRAP_ADDRESSMODE | |
  84914. * | 2 | MIRROR_ADDRESSMODE | |
  84915. */
  84916. wrapU: number;
  84917. /**
  84918. * | Value | Type | Description |
  84919. * | ----- | ------------------ | ----------- |
  84920. * | 0 | CLAMP_ADDRESSMODE | |
  84921. * | 1 | WRAP_ADDRESSMODE | |
  84922. * | 2 | MIRROR_ADDRESSMODE | |
  84923. */
  84924. wrapV: number;
  84925. /**
  84926. * | Value | Type | Description |
  84927. * | ----- | ------------------ | ----------- |
  84928. * | 0 | CLAMP_ADDRESSMODE | |
  84929. * | 1 | WRAP_ADDRESSMODE | |
  84930. * | 2 | MIRROR_ADDRESSMODE | |
  84931. */
  84932. wrapR: number;
  84933. /**
  84934. * With compliant hardware and browser (supporting anisotropic filtering)
  84935. * this defines the level of anisotropic filtering in the texture.
  84936. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  84937. */
  84938. anisotropicFilteringLevel: number;
  84939. /**
  84940. * Define if the texture is a cube texture or if false a 2d texture.
  84941. */
  84942. isCube: boolean;
  84943. /**
  84944. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  84945. */
  84946. is3D: boolean;
  84947. /**
  84948. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  84949. * HDR texture are usually stored in linear space.
  84950. * This only impacts the PBR and Background materials
  84951. */
  84952. gammaSpace: boolean;
  84953. /**
  84954. * Gets whether or not the texture contains RGBD data.
  84955. */
  84956. readonly isRGBD: boolean;
  84957. /**
  84958. * Is Z inverted in the texture (useful in a cube texture).
  84959. */
  84960. invertZ: boolean;
  84961. /**
  84962. * Are mip maps generated for this texture or not.
  84963. */
  84964. readonly noMipmap: boolean;
  84965. /**
  84966. * @hidden
  84967. */
  84968. lodLevelInAlpha: boolean;
  84969. /**
  84970. * With prefiltered texture, defined the offset used during the prefiltering steps.
  84971. */
  84972. lodGenerationOffset: number;
  84973. /**
  84974. * With prefiltered texture, defined the scale used during the prefiltering steps.
  84975. */
  84976. lodGenerationScale: number;
  84977. /**
  84978. * Define if the texture is a render target.
  84979. */
  84980. isRenderTarget: boolean;
  84981. /**
  84982. * Define the unique id of the texture in the scene.
  84983. */
  84984. readonly uid: string;
  84985. /**
  84986. * Return a string representation of the texture.
  84987. * @returns the texture as a string
  84988. */
  84989. toString(): string;
  84990. /**
  84991. * Get the class name of the texture.
  84992. * @returns "BaseTexture"
  84993. */
  84994. getClassName(): string;
  84995. /**
  84996. * Define the list of animation attached to the texture.
  84997. */
  84998. animations: Animation[];
  84999. /**
  85000. * An event triggered when the texture is disposed.
  85001. */
  85002. onDisposeObservable: Observable<BaseTexture>;
  85003. private _onDisposeObserver;
  85004. /**
  85005. * Callback triggered when the texture has been disposed.
  85006. * Kept for back compatibility, you can use the onDisposeObservable instead.
  85007. */
  85008. onDispose: () => void;
  85009. /**
  85010. * Define the current state of the loading sequence when in delayed load mode.
  85011. */
  85012. delayLoadState: number;
  85013. private _scene;
  85014. /** @hidden */
  85015. _texture: Nullable<InternalTexture>;
  85016. private _uid;
  85017. /**
  85018. * Define if the texture is preventinga material to render or not.
  85019. * If not and the texture is not ready, the engine will use a default black texture instead.
  85020. */
  85021. readonly isBlocking: boolean;
  85022. /**
  85023. * Instantiates a new BaseTexture.
  85024. * Base class of all the textures in babylon.
  85025. * It groups all the common properties the materials, post process, lights... might need
  85026. * in order to make a correct use of the texture.
  85027. * @param scene Define the scene the texture blongs to
  85028. */
  85029. constructor(scene: Nullable<Scene>);
  85030. /**
  85031. * Get the scene the texture belongs to.
  85032. * @returns the scene or null if undefined
  85033. */
  85034. getScene(): Nullable<Scene>;
  85035. /**
  85036. * Get the texture transform matrix used to offset tile the texture for istance.
  85037. * @returns the transformation matrix
  85038. */
  85039. getTextureMatrix(): Matrix;
  85040. /**
  85041. * Get the texture reflection matrix used to rotate/transform the reflection.
  85042. * @returns the reflection matrix
  85043. */
  85044. getReflectionTextureMatrix(): Matrix;
  85045. /**
  85046. * Get the underlying lower level texture from Babylon.
  85047. * @returns the insternal texture
  85048. */
  85049. getInternalTexture(): Nullable<InternalTexture>;
  85050. /**
  85051. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  85052. * @returns true if ready or not blocking
  85053. */
  85054. isReadyOrNotBlocking(): boolean;
  85055. /**
  85056. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  85057. * @returns true if fully ready
  85058. */
  85059. isReady(): boolean;
  85060. private _cachedSize;
  85061. /**
  85062. * Get the size of the texture.
  85063. * @returns the texture size.
  85064. */
  85065. getSize(): ISize;
  85066. /**
  85067. * Get the base size of the texture.
  85068. * It can be different from the size if the texture has been resized for POT for instance
  85069. * @returns the base size
  85070. */
  85071. getBaseSize(): ISize;
  85072. /**
  85073. * Update the sampling mode of the texture.
  85074. * Default is Trilinear mode.
  85075. *
  85076. * | Value | Type | Description |
  85077. * | ----- | ------------------ | ----------- |
  85078. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  85079. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  85080. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  85081. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  85082. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  85083. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  85084. * | 7 | NEAREST_LINEAR | |
  85085. * | 8 | NEAREST_NEAREST | |
  85086. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  85087. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  85088. * | 11 | LINEAR_LINEAR | |
  85089. * | 12 | LINEAR_NEAREST | |
  85090. *
  85091. * > _mag_: magnification filter (close to the viewer)
  85092. * > _min_: minification filter (far from the viewer)
  85093. * > _mip_: filter used between mip map levels
  85094. *@param samplingMode Define the new sampling mode of the texture
  85095. */
  85096. updateSamplingMode(samplingMode: number): void;
  85097. /**
  85098. * Scales the texture if is `canRescale()`
  85099. * @param ratio the resize factor we want to use to rescale
  85100. */
  85101. scale(ratio: number): void;
  85102. /**
  85103. * Get if the texture can rescale.
  85104. */
  85105. readonly canRescale: boolean;
  85106. /** @hidden */
  85107. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  85108. /** @hidden */
  85109. _rebuild(): void;
  85110. /**
  85111. * Triggers the load sequence in delayed load mode.
  85112. */
  85113. delayLoad(): void;
  85114. /**
  85115. * Clones the texture.
  85116. * @returns the cloned texture
  85117. */
  85118. clone(): Nullable<BaseTexture>;
  85119. /**
  85120. * Get the texture underlying type (INT, FLOAT...)
  85121. */
  85122. readonly textureType: number;
  85123. /**
  85124. * Get the texture underlying format (RGB, RGBA...)
  85125. */
  85126. readonly textureFormat: number;
  85127. /**
  85128. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  85129. * This will returns an RGBA array buffer containing either in values (0-255) or
  85130. * float values (0-1) depending of the underlying buffer type.
  85131. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  85132. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  85133. * @param buffer defines a user defined buffer to fill with data (can be null)
  85134. * @returns The Array buffer containing the pixels data.
  85135. */
  85136. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  85137. /**
  85138. * Release and destroy the underlying lower level texture aka internalTexture.
  85139. */
  85140. releaseInternalTexture(): void;
  85141. /**
  85142. * Get the polynomial representation of the texture data.
  85143. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  85144. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  85145. */
  85146. sphericalPolynomial: Nullable<SphericalPolynomial>;
  85147. /** @hidden */
  85148. readonly _lodTextureHigh: Nullable<BaseTexture>;
  85149. /** @hidden */
  85150. readonly _lodTextureMid: Nullable<BaseTexture>;
  85151. /** @hidden */
  85152. readonly _lodTextureLow: Nullable<BaseTexture>;
  85153. /**
  85154. * Dispose the texture and release its associated resources.
  85155. */
  85156. dispose(): void;
  85157. /**
  85158. * Serialize the texture into a JSON representation that can be parsed later on.
  85159. * @returns the JSON representation of the texture
  85160. */
  85161. serialize(): any;
  85162. /**
  85163. * Helper function to be called back once a list of texture contains only ready textures.
  85164. * @param textures Define the list of textures to wait for
  85165. * @param callback Define the callback triggered once the entire list will be ready
  85166. */
  85167. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  85168. }
  85169. }
  85170. declare module BABYLON {
  85171. /**
  85172. * Uniform buffer objects.
  85173. *
  85174. * Handles blocks of uniform on the GPU.
  85175. *
  85176. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  85177. *
  85178. * For more information, please refer to :
  85179. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  85180. */
  85181. export class UniformBuffer {
  85182. private _engine;
  85183. private _buffer;
  85184. private _data;
  85185. private _bufferData;
  85186. private _dynamic?;
  85187. private _uniformLocations;
  85188. private _uniformSizes;
  85189. private _uniformLocationPointer;
  85190. private _needSync;
  85191. private _noUBO;
  85192. private _currentEffect;
  85193. private static _MAX_UNIFORM_SIZE;
  85194. private static _tempBuffer;
  85195. /**
  85196. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  85197. * This is dynamic to allow compat with webgl 1 and 2.
  85198. * You will need to pass the name of the uniform as well as the value.
  85199. */
  85200. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  85201. /**
  85202. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  85203. * This is dynamic to allow compat with webgl 1 and 2.
  85204. * You will need to pass the name of the uniform as well as the value.
  85205. */
  85206. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  85207. /**
  85208. * Lambda to Update a single float in a uniform buffer.
  85209. * This is dynamic to allow compat with webgl 1 and 2.
  85210. * You will need to pass the name of the uniform as well as the value.
  85211. */
  85212. updateFloat: (name: string, x: number) => void;
  85213. /**
  85214. * Lambda to Update a vec2 of float in a uniform buffer.
  85215. * This is dynamic to allow compat with webgl 1 and 2.
  85216. * You will need to pass the name of the uniform as well as the value.
  85217. */
  85218. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  85219. /**
  85220. * Lambda to Update a vec3 of float in a uniform buffer.
  85221. * This is dynamic to allow compat with webgl 1 and 2.
  85222. * You will need to pass the name of the uniform as well as the value.
  85223. */
  85224. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  85225. /**
  85226. * Lambda to Update a vec4 of float in a uniform buffer.
  85227. * This is dynamic to allow compat with webgl 1 and 2.
  85228. * You will need to pass the name of the uniform as well as the value.
  85229. */
  85230. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  85231. /**
  85232. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  85233. * This is dynamic to allow compat with webgl 1 and 2.
  85234. * You will need to pass the name of the uniform as well as the value.
  85235. */
  85236. updateMatrix: (name: string, mat: Matrix) => void;
  85237. /**
  85238. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  85239. * This is dynamic to allow compat with webgl 1 and 2.
  85240. * You will need to pass the name of the uniform as well as the value.
  85241. */
  85242. updateVector3: (name: string, vector: Vector3) => void;
  85243. /**
  85244. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  85245. * This is dynamic to allow compat with webgl 1 and 2.
  85246. * You will need to pass the name of the uniform as well as the value.
  85247. */
  85248. updateVector4: (name: string, vector: Vector4) => void;
  85249. /**
  85250. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  85251. * This is dynamic to allow compat with webgl 1 and 2.
  85252. * You will need to pass the name of the uniform as well as the value.
  85253. */
  85254. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  85255. /**
  85256. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  85257. * This is dynamic to allow compat with webgl 1 and 2.
  85258. * You will need to pass the name of the uniform as well as the value.
  85259. */
  85260. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  85261. /**
  85262. * Instantiates a new Uniform buffer objects.
  85263. *
  85264. * Handles blocks of uniform on the GPU.
  85265. *
  85266. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  85267. *
  85268. * For more information, please refer to :
  85269. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  85270. * @param engine Define the engine the buffer is associated with
  85271. * @param data Define the data contained in the buffer
  85272. * @param dynamic Define if the buffer is updatable
  85273. */
  85274. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  85275. /**
  85276. * Indicates if the buffer is using the WebGL2 UBO implementation,
  85277. * or just falling back on setUniformXXX calls.
  85278. */
  85279. readonly useUbo: boolean;
  85280. /**
  85281. * Indicates if the WebGL underlying uniform buffer is in sync
  85282. * with the javascript cache data.
  85283. */
  85284. readonly isSync: boolean;
  85285. /**
  85286. * Indicates if the WebGL underlying uniform buffer is dynamic.
  85287. * Also, a dynamic UniformBuffer will disable cache verification and always
  85288. * update the underlying WebGL uniform buffer to the GPU.
  85289. * @returns if Dynamic, otherwise false
  85290. */
  85291. isDynamic(): boolean;
  85292. /**
  85293. * The data cache on JS side.
  85294. * @returns the underlying data as a float array
  85295. */
  85296. getData(): Float32Array;
  85297. /**
  85298. * The underlying WebGL Uniform buffer.
  85299. * @returns the webgl buffer
  85300. */
  85301. getBuffer(): Nullable<WebGLBuffer>;
  85302. /**
  85303. * std140 layout specifies how to align data within an UBO structure.
  85304. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  85305. * for specs.
  85306. */
  85307. private _fillAlignment;
  85308. /**
  85309. * Adds an uniform in the buffer.
  85310. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  85311. * for the layout to be correct !
  85312. * @param name Name of the uniform, as used in the uniform block in the shader.
  85313. * @param size Data size, or data directly.
  85314. */
  85315. addUniform(name: string, size: number | number[]): void;
  85316. /**
  85317. * Adds a Matrix 4x4 to the uniform buffer.
  85318. * @param name Name of the uniform, as used in the uniform block in the shader.
  85319. * @param mat A 4x4 matrix.
  85320. */
  85321. addMatrix(name: string, mat: Matrix): void;
  85322. /**
  85323. * Adds a vec2 to the uniform buffer.
  85324. * @param name Name of the uniform, as used in the uniform block in the shader.
  85325. * @param x Define the x component value of the vec2
  85326. * @param y Define the y component value of the vec2
  85327. */
  85328. addFloat2(name: string, x: number, y: number): void;
  85329. /**
  85330. * Adds a vec3 to the uniform buffer.
  85331. * @param name Name of the uniform, as used in the uniform block in the shader.
  85332. * @param x Define the x component value of the vec3
  85333. * @param y Define the y component value of the vec3
  85334. * @param z Define the z component value of the vec3
  85335. */
  85336. addFloat3(name: string, x: number, y: number, z: number): void;
  85337. /**
  85338. * Adds a vec3 to the uniform buffer.
  85339. * @param name Name of the uniform, as used in the uniform block in the shader.
  85340. * @param color Define the vec3 from a Color
  85341. */
  85342. addColor3(name: string, color: Color3): void;
  85343. /**
  85344. * Adds a vec4 to the uniform buffer.
  85345. * @param name Name of the uniform, as used in the uniform block in the shader.
  85346. * @param color Define the rgb components from a Color
  85347. * @param alpha Define the a component of the vec4
  85348. */
  85349. addColor4(name: string, color: Color3, alpha: number): void;
  85350. /**
  85351. * Adds a vec3 to the uniform buffer.
  85352. * @param name Name of the uniform, as used in the uniform block in the shader.
  85353. * @param vector Define the vec3 components from a Vector
  85354. */
  85355. addVector3(name: string, vector: Vector3): void;
  85356. /**
  85357. * Adds a Matrix 3x3 to the uniform buffer.
  85358. * @param name Name of the uniform, as used in the uniform block in the shader.
  85359. */
  85360. addMatrix3x3(name: string): void;
  85361. /**
  85362. * Adds a Matrix 2x2 to the uniform buffer.
  85363. * @param name Name of the uniform, as used in the uniform block in the shader.
  85364. */
  85365. addMatrix2x2(name: string): void;
  85366. /**
  85367. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  85368. */
  85369. create(): void;
  85370. /** @hidden */
  85371. _rebuild(): void;
  85372. /**
  85373. * Updates the WebGL Uniform Buffer on the GPU.
  85374. * If the `dynamic` flag is set to true, no cache comparison is done.
  85375. * Otherwise, the buffer will be updated only if the cache differs.
  85376. */
  85377. update(): void;
  85378. /**
  85379. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  85380. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  85381. * @param data Define the flattened data
  85382. * @param size Define the size of the data.
  85383. */
  85384. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  85385. private _updateMatrix3x3ForUniform;
  85386. private _updateMatrix3x3ForEffect;
  85387. private _updateMatrix2x2ForEffect;
  85388. private _updateMatrix2x2ForUniform;
  85389. private _updateFloatForEffect;
  85390. private _updateFloatForUniform;
  85391. private _updateFloat2ForEffect;
  85392. private _updateFloat2ForUniform;
  85393. private _updateFloat3ForEffect;
  85394. private _updateFloat3ForUniform;
  85395. private _updateFloat4ForEffect;
  85396. private _updateFloat4ForUniform;
  85397. private _updateMatrixForEffect;
  85398. private _updateMatrixForUniform;
  85399. private _updateVector3ForEffect;
  85400. private _updateVector3ForUniform;
  85401. private _updateVector4ForEffect;
  85402. private _updateVector4ForUniform;
  85403. private _updateColor3ForEffect;
  85404. private _updateColor3ForUniform;
  85405. private _updateColor4ForEffect;
  85406. private _updateColor4ForUniform;
  85407. /**
  85408. * Sets a sampler uniform on the effect.
  85409. * @param name Define the name of the sampler.
  85410. * @param texture Define the texture to set in the sampler
  85411. */
  85412. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  85413. /**
  85414. * Directly updates the value of the uniform in the cache AND on the GPU.
  85415. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  85416. * @param data Define the flattened data
  85417. */
  85418. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  85419. /**
  85420. * Binds this uniform buffer to an effect.
  85421. * @param effect Define the effect to bind the buffer to
  85422. * @param name Name of the uniform block in the shader.
  85423. */
  85424. bindToEffect(effect: Effect, name: string): void;
  85425. /**
  85426. * Disposes the uniform buffer.
  85427. */
  85428. dispose(): void;
  85429. }
  85430. }
  85431. declare module BABYLON {
  85432. /**
  85433. * This represents the required contract to create a new type of texture loader.
  85434. */
  85435. export interface IInternalTextureLoader {
  85436. /**
  85437. * Defines wether the loader supports cascade loading the different faces.
  85438. */
  85439. supportCascades: boolean;
  85440. /**
  85441. * This returns if the loader support the current file information.
  85442. * @param extension defines the file extension of the file being loaded
  85443. * @param textureFormatInUse defines the current compressed format in use iun the engine
  85444. * @param fallback defines the fallback internal texture if any
  85445. * @param isBase64 defines whether the texture is encoded as a base64
  85446. * @param isBuffer defines whether the texture data are stored as a buffer
  85447. * @returns true if the loader can load the specified file
  85448. */
  85449. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  85450. /**
  85451. * Transform the url before loading if required.
  85452. * @param rootUrl the url of the texture
  85453. * @param textureFormatInUse defines the current compressed format in use iun the engine
  85454. * @returns the transformed texture
  85455. */
  85456. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  85457. /**
  85458. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  85459. * @param rootUrl the url of the texture
  85460. * @param textureFormatInUse defines the current compressed format in use iun the engine
  85461. * @returns the fallback texture
  85462. */
  85463. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  85464. /**
  85465. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  85466. * @param data contains the texture data
  85467. * @param texture defines the BabylonJS internal texture
  85468. * @param createPolynomials will be true if polynomials have been requested
  85469. * @param onLoad defines the callback to trigger once the texture is ready
  85470. * @param onError defines the callback to trigger in case of error
  85471. */
  85472. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  85473. /**
  85474. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  85475. * @param data contains the texture data
  85476. * @param texture defines the BabylonJS internal texture
  85477. * @param callback defines the method to call once ready to upload
  85478. */
  85479. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  85480. }
  85481. }
  85482. declare module BABYLON {
  85483. /**
  85484. * Creation options of the multi render target texture.
  85485. */
  85486. export interface IMultiRenderTargetOptions {
  85487. /**
  85488. * Define if the texture needs to create mip maps after render.
  85489. */
  85490. generateMipMaps?: boolean;
  85491. /**
  85492. * Define the types of all the draw buffers we want to create
  85493. */
  85494. types?: number[];
  85495. /**
  85496. * Define the sampling modes of all the draw buffers we want to create
  85497. */
  85498. samplingModes?: number[];
  85499. /**
  85500. * Define if a depth buffer is required
  85501. */
  85502. generateDepthBuffer?: boolean;
  85503. /**
  85504. * Define if a stencil buffer is required
  85505. */
  85506. generateStencilBuffer?: boolean;
  85507. /**
  85508. * Define if a depth texture is required instead of a depth buffer
  85509. */
  85510. generateDepthTexture?: boolean;
  85511. /**
  85512. * Define the number of desired draw buffers
  85513. */
  85514. textureCount?: number;
  85515. /**
  85516. * Define if aspect ratio should be adapted to the texture or stay the scene one
  85517. */
  85518. doNotChangeAspectRatio?: boolean;
  85519. /**
  85520. * Define the default type of the buffers we are creating
  85521. */
  85522. defaultType?: number;
  85523. }
  85524. /**
  85525. * A multi render target, like a render target provides the ability to render to a texture.
  85526. * Unlike the render target, it can render to several draw buffers in one draw.
  85527. * This is specially interesting in deferred rendering or for any effects requiring more than
  85528. * just one color from a single pass.
  85529. */
  85530. export class MultiRenderTarget extends RenderTargetTexture {
  85531. private _internalTextures;
  85532. private _textures;
  85533. private _multiRenderTargetOptions;
  85534. /**
  85535. * Get if draw buffers are currently supported by the used hardware and browser.
  85536. */
  85537. readonly isSupported: boolean;
  85538. /**
  85539. * Get the list of textures generated by the multi render target.
  85540. */
  85541. readonly textures: Texture[];
  85542. /**
  85543. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  85544. */
  85545. readonly depthTexture: Texture;
  85546. /**
  85547. * Set the wrapping mode on U of all the textures we are rendering to.
  85548. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  85549. */
  85550. wrapU: number;
  85551. /**
  85552. * Set the wrapping mode on V of all the textures we are rendering to.
  85553. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  85554. */
  85555. wrapV: number;
  85556. /**
  85557. * Instantiate a new multi render target texture.
  85558. * A multi render target, like a render target provides the ability to render to a texture.
  85559. * Unlike the render target, it can render to several draw buffers in one draw.
  85560. * This is specially interesting in deferred rendering or for any effects requiring more than
  85561. * just one color from a single pass.
  85562. * @param name Define the name of the texture
  85563. * @param size Define the size of the buffers to render to
  85564. * @param count Define the number of target we are rendering into
  85565. * @param scene Define the scene the texture belongs to
  85566. * @param options Define the options used to create the multi render target
  85567. */
  85568. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  85569. /** @hidden */
  85570. _rebuild(): void;
  85571. private _createInternalTextures;
  85572. private _createTextures;
  85573. /**
  85574. * Define the number of samples used if MSAA is enabled.
  85575. */
  85576. samples: number;
  85577. /**
  85578. * Resize all the textures in the multi render target.
  85579. * Be carrefull as it will recreate all the data in the new texture.
  85580. * @param size Define the new size
  85581. */
  85582. resize(size: any): void;
  85583. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  85584. /**
  85585. * Dispose the render targets and their associated resources
  85586. */
  85587. dispose(): void;
  85588. /**
  85589. * Release all the underlying texture used as draw buffers.
  85590. */
  85591. releaseInternalTextures(): void;
  85592. }
  85593. }
  85594. declare module BABYLON {
  85595. /**
  85596. * Class used to work with sound analyzer using fast fourier transform (FFT)
  85597. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  85598. */
  85599. export class Analyser {
  85600. /**
  85601. * Gets or sets the smoothing
  85602. * @ignorenaming
  85603. */
  85604. SMOOTHING: number;
  85605. /**
  85606. * Gets or sets the FFT table size
  85607. * @ignorenaming
  85608. */
  85609. FFT_SIZE: number;
  85610. /**
  85611. * Gets or sets the bar graph amplitude
  85612. * @ignorenaming
  85613. */
  85614. BARGRAPHAMPLITUDE: number;
  85615. /**
  85616. * Gets or sets the position of the debug canvas
  85617. * @ignorenaming
  85618. */
  85619. DEBUGCANVASPOS: {
  85620. x: number;
  85621. y: number;
  85622. };
  85623. /**
  85624. * Gets or sets the debug canvas size
  85625. * @ignorenaming
  85626. */
  85627. DEBUGCANVASSIZE: {
  85628. width: number;
  85629. height: number;
  85630. };
  85631. private _byteFreqs;
  85632. private _byteTime;
  85633. private _floatFreqs;
  85634. private _webAudioAnalyser;
  85635. private _debugCanvas;
  85636. private _debugCanvasContext;
  85637. private _scene;
  85638. private _registerFunc;
  85639. private _audioEngine;
  85640. /**
  85641. * Creates a new analyser
  85642. * @param scene defines hosting scene
  85643. */
  85644. constructor(scene: Scene);
  85645. /**
  85646. * Get the number of data values you will have to play with for the visualization
  85647. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  85648. * @returns a number
  85649. */
  85650. getFrequencyBinCount(): number;
  85651. /**
  85652. * Gets the current frequency data as a byte array
  85653. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  85654. * @returns a Uint8Array
  85655. */
  85656. getByteFrequencyData(): Uint8Array;
  85657. /**
  85658. * Gets the current waveform as a byte array
  85659. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  85660. * @returns a Uint8Array
  85661. */
  85662. getByteTimeDomainData(): Uint8Array;
  85663. /**
  85664. * Gets the current frequency data as a float array
  85665. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  85666. * @returns a Float32Array
  85667. */
  85668. getFloatFrequencyData(): Float32Array;
  85669. /**
  85670. * Renders the debug canvas
  85671. */
  85672. drawDebugCanvas(): void;
  85673. /**
  85674. * Stops rendering the debug canvas and removes it
  85675. */
  85676. stopDebugCanvas(): void;
  85677. /**
  85678. * Connects two audio nodes
  85679. * @param inputAudioNode defines first node to connect
  85680. * @param outputAudioNode defines second node to connect
  85681. */
  85682. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  85683. /**
  85684. * Releases all associated resources
  85685. */
  85686. dispose(): void;
  85687. }
  85688. }
  85689. declare module BABYLON {
  85690. /**
  85691. * This represents an audio engine and it is responsible
  85692. * to play, synchronize and analyse sounds throughout the application.
  85693. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  85694. */
  85695. export interface IAudioEngine extends IDisposable {
  85696. /**
  85697. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  85698. */
  85699. readonly canUseWebAudio: boolean;
  85700. /**
  85701. * Gets the current AudioContext if available.
  85702. */
  85703. readonly audioContext: Nullable<AudioContext>;
  85704. /**
  85705. * The master gain node defines the global audio volume of your audio engine.
  85706. */
  85707. readonly masterGain: GainNode;
  85708. /**
  85709. * Gets whether or not mp3 are supported by your browser.
  85710. */
  85711. readonly isMP3supported: boolean;
  85712. /**
  85713. * Gets whether or not ogg are supported by your browser.
  85714. */
  85715. readonly isOGGsupported: boolean;
  85716. /**
  85717. * Defines if Babylon should emit a warning if WebAudio is not supported.
  85718. * @ignoreNaming
  85719. */
  85720. WarnedWebAudioUnsupported: boolean;
  85721. /**
  85722. * Defines if the audio engine relies on a custom unlocked button.
  85723. * In this case, the embedded button will not be displayed.
  85724. */
  85725. useCustomUnlockedButton: boolean;
  85726. /**
  85727. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  85728. */
  85729. readonly unlocked: boolean;
  85730. /**
  85731. * Event raised when audio has been unlocked on the browser.
  85732. */
  85733. onAudioUnlockedObservable: Observable<AudioEngine>;
  85734. /**
  85735. * Event raised when audio has been locked on the browser.
  85736. */
  85737. onAudioLockedObservable: Observable<AudioEngine>;
  85738. /**
  85739. * Flags the audio engine in Locked state.
  85740. * This happens due to new browser policies preventing audio to autoplay.
  85741. */
  85742. lock(): void;
  85743. /**
  85744. * Unlocks the audio engine once a user action has been done on the dom.
  85745. * This is helpful to resume play once browser policies have been satisfied.
  85746. */
  85747. unlock(): void;
  85748. }
  85749. /**
  85750. * This represents the default audio engine used in babylon.
  85751. * It is responsible to play, synchronize and analyse sounds throughout the application.
  85752. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  85753. */
  85754. export class AudioEngine implements IAudioEngine {
  85755. private _audioContext;
  85756. private _audioContextInitialized;
  85757. private _muteButton;
  85758. private _hostElement;
  85759. /**
  85760. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  85761. */
  85762. canUseWebAudio: boolean;
  85763. /**
  85764. * The master gain node defines the global audio volume of your audio engine.
  85765. */
  85766. masterGain: GainNode;
  85767. /**
  85768. * Defines if Babylon should emit a warning if WebAudio is not supported.
  85769. * @ignoreNaming
  85770. */
  85771. WarnedWebAudioUnsupported: boolean;
  85772. /**
  85773. * Gets whether or not mp3 are supported by your browser.
  85774. */
  85775. isMP3supported: boolean;
  85776. /**
  85777. * Gets whether or not ogg are supported by your browser.
  85778. */
  85779. isOGGsupported: boolean;
  85780. /**
  85781. * Gets whether audio has been unlocked on the device.
  85782. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  85783. * a user interaction has happened.
  85784. */
  85785. unlocked: boolean;
  85786. /**
  85787. * Defines if the audio engine relies on a custom unlocked button.
  85788. * In this case, the embedded button will not be displayed.
  85789. */
  85790. useCustomUnlockedButton: boolean;
  85791. /**
  85792. * Event raised when audio has been unlocked on the browser.
  85793. */
  85794. onAudioUnlockedObservable: Observable<AudioEngine>;
  85795. /**
  85796. * Event raised when audio has been locked on the browser.
  85797. */
  85798. onAudioLockedObservable: Observable<AudioEngine>;
  85799. /**
  85800. * Gets the current AudioContext if available.
  85801. */
  85802. readonly audioContext: Nullable<AudioContext>;
  85803. private _connectedAnalyser;
  85804. /**
  85805. * Instantiates a new audio engine.
  85806. *
  85807. * There should be only one per page as some browsers restrict the number
  85808. * of audio contexts you can create.
  85809. * @param hostElement defines the host element where to display the mute icon if necessary
  85810. */
  85811. constructor(hostElement?: Nullable<HTMLElement>);
  85812. /**
  85813. * Flags the audio engine in Locked state.
  85814. * This happens due to new browser policies preventing audio to autoplay.
  85815. */
  85816. lock(): void;
  85817. /**
  85818. * Unlocks the audio engine once a user action has been done on the dom.
  85819. * This is helpful to resume play once browser policies have been satisfied.
  85820. */
  85821. unlock(): void;
  85822. private _resumeAudioContext;
  85823. private _initializeAudioContext;
  85824. private _tryToRun;
  85825. private _triggerRunningState;
  85826. private _triggerSuspendedState;
  85827. private _displayMuteButton;
  85828. private _moveButtonToTopLeft;
  85829. private _onResize;
  85830. private _hideMuteButton;
  85831. /**
  85832. * Destroy and release the resources associated with the audio ccontext.
  85833. */
  85834. dispose(): void;
  85835. /**
  85836. * Gets the global volume sets on the master gain.
  85837. * @returns the global volume if set or -1 otherwise
  85838. */
  85839. getGlobalVolume(): number;
  85840. /**
  85841. * Sets the global volume of your experience (sets on the master gain).
  85842. * @param newVolume Defines the new global volume of the application
  85843. */
  85844. setGlobalVolume(newVolume: number): void;
  85845. /**
  85846. * Connect the audio engine to an audio analyser allowing some amazing
  85847. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  85848. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  85849. * @param analyser The analyser to connect to the engine
  85850. */
  85851. connectToAnalyser(analyser: Analyser): void;
  85852. }
  85853. }
  85854. declare module BABYLON {
  85855. /**
  85856. * Interface used to present a loading screen while loading a scene
  85857. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  85858. */
  85859. export interface ILoadingScreen {
  85860. /**
  85861. * Function called to display the loading screen
  85862. */
  85863. displayLoadingUI: () => void;
  85864. /**
  85865. * Function called to hide the loading screen
  85866. */
  85867. hideLoadingUI: () => void;
  85868. /**
  85869. * Gets or sets the color to use for the background
  85870. */
  85871. loadingUIBackgroundColor: string;
  85872. /**
  85873. * Gets or sets the text to display while loading
  85874. */
  85875. loadingUIText: string;
  85876. }
  85877. /**
  85878. * Class used for the default loading screen
  85879. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  85880. */
  85881. export class DefaultLoadingScreen implements ILoadingScreen {
  85882. private _renderingCanvas;
  85883. private _loadingText;
  85884. private _loadingDivBackgroundColor;
  85885. private _loadingDiv;
  85886. private _loadingTextDiv;
  85887. /**
  85888. * Creates a new default loading screen
  85889. * @param _renderingCanvas defines the canvas used to render the scene
  85890. * @param _loadingText defines the default text to display
  85891. * @param _loadingDivBackgroundColor defines the default background color
  85892. */
  85893. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  85894. /**
  85895. * Function called to display the loading screen
  85896. */
  85897. displayLoadingUI(): void;
  85898. /**
  85899. * Function called to hide the loading screen
  85900. */
  85901. hideLoadingUI(): void;
  85902. /**
  85903. * Gets or sets the text to display while loading
  85904. */
  85905. loadingUIText: string;
  85906. /**
  85907. * Gets or sets the color to use for the background
  85908. */
  85909. loadingUIBackgroundColor: string;
  85910. private _resizeLoadingUI;
  85911. }
  85912. }
  85913. declare module BABYLON {
  85914. /**
  85915. * Settings for finer control over video usage
  85916. */
  85917. export interface VideoTextureSettings {
  85918. /**
  85919. * Applies `autoplay` to video, if specified
  85920. */
  85921. autoPlay?: boolean;
  85922. /**
  85923. * Applies `loop` to video, if specified
  85924. */
  85925. loop?: boolean;
  85926. /**
  85927. * Automatically updates internal texture from video at every frame in the render loop
  85928. */
  85929. autoUpdateTexture: boolean;
  85930. /**
  85931. * Image src displayed during the video loading or until the user interacts with the video.
  85932. */
  85933. poster?: string;
  85934. }
  85935. /**
  85936. * If you want to display a video in your scene, this is the special texture for that.
  85937. * This special texture works similar to other textures, with the exception of a few parameters.
  85938. * @see https://doc.babylonjs.com/how_to/video_texture
  85939. */
  85940. export class VideoTexture extends Texture {
  85941. /**
  85942. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  85943. */
  85944. readonly autoUpdateTexture: boolean;
  85945. /**
  85946. * The video instance used by the texture internally
  85947. */
  85948. readonly video: HTMLVideoElement;
  85949. private _onUserActionRequestedObservable;
  85950. /**
  85951. * Event triggerd when a dom action is required by the user to play the video.
  85952. * This happens due to recent changes in browser policies preventing video to auto start.
  85953. */
  85954. readonly onUserActionRequestedObservable: Observable<Texture>;
  85955. private _generateMipMaps;
  85956. private _engine;
  85957. private _stillImageCaptured;
  85958. private _displayingPosterTexture;
  85959. private _settings;
  85960. private _createInternalTextureOnEvent;
  85961. /**
  85962. * Creates a video texture.
  85963. * If you want to display a video in your scene, this is the special texture for that.
  85964. * This special texture works similar to other textures, with the exception of a few parameters.
  85965. * @see https://doc.babylonjs.com/how_to/video_texture
  85966. * @param name optional name, will detect from video source, if not defined
  85967. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  85968. * @param scene is obviously the current scene.
  85969. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  85970. * @param invertY is false by default but can be used to invert video on Y axis
  85971. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  85972. * @param settings allows finer control over video usage
  85973. */
  85974. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  85975. private _getName;
  85976. private _getVideo;
  85977. private _createInternalTexture;
  85978. private reset;
  85979. /**
  85980. * @hidden Internal method to initiate `update`.
  85981. */
  85982. _rebuild(): void;
  85983. /**
  85984. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  85985. */
  85986. update(): void;
  85987. /**
  85988. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  85989. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  85990. */
  85991. updateTexture(isVisible: boolean): void;
  85992. protected _updateInternalTexture: () => void;
  85993. /**
  85994. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  85995. * @param url New url.
  85996. */
  85997. updateURL(url: string): void;
  85998. /**
  85999. * Dispose the texture and release its associated resources.
  86000. */
  86001. dispose(): void;
  86002. /**
  86003. * Creates a video texture straight from a stream.
  86004. * @param scene Define the scene the texture should be created in
  86005. * @param stream Define the stream the texture should be created from
  86006. * @returns The created video texture as a promise
  86007. */
  86008. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  86009. /**
  86010. * Creates a video texture straight from your WebCam video feed.
  86011. * @param scene Define the scene the texture should be created in
  86012. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  86013. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  86014. * @returns The created video texture as a promise
  86015. */
  86016. static CreateFromWebCamAsync(scene: Scene, constraints: {
  86017. minWidth: number;
  86018. maxWidth: number;
  86019. minHeight: number;
  86020. maxHeight: number;
  86021. deviceId: string;
  86022. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  86023. /**
  86024. * Creates a video texture straight from your WebCam video feed.
  86025. * @param scene Define the scene the texture should be created in
  86026. * @param onReady Define a callback to triggered once the texture will be ready
  86027. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  86028. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  86029. */
  86030. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  86031. minWidth: number;
  86032. maxWidth: number;
  86033. minHeight: number;
  86034. maxHeight: number;
  86035. deviceId: string;
  86036. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  86037. }
  86038. }
  86039. declare module BABYLON {
  86040. /**
  86041. * Interface for attribute information associated with buffer instanciation
  86042. */
  86043. export class InstancingAttributeInfo {
  86044. /**
  86045. * Index/offset of the attribute in the vertex shader
  86046. */
  86047. index: number;
  86048. /**
  86049. * size of the attribute, 1, 2, 3 or 4
  86050. */
  86051. attributeSize: number;
  86052. /**
  86053. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  86054. * default is FLOAT
  86055. */
  86056. attribyteType: number;
  86057. /**
  86058. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  86059. */
  86060. normalized: boolean;
  86061. /**
  86062. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  86063. */
  86064. offset: number;
  86065. /**
  86066. * Name of the GLSL attribute, for debugging purpose only
  86067. */
  86068. attributeName: string;
  86069. }
  86070. /**
  86071. * Define options used to create a depth texture
  86072. */
  86073. export class DepthTextureCreationOptions {
  86074. /** Specifies whether or not a stencil should be allocated in the texture */
  86075. generateStencil?: boolean;
  86076. /** Specifies whether or not bilinear filtering is enable on the texture */
  86077. bilinearFiltering?: boolean;
  86078. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  86079. comparisonFunction?: number;
  86080. /** Specifies if the created texture is a cube texture */
  86081. isCube?: boolean;
  86082. }
  86083. /**
  86084. * Class used to describe the capabilities of the engine relatively to the current browser
  86085. */
  86086. export class EngineCapabilities {
  86087. /** Maximum textures units per fragment shader */
  86088. maxTexturesImageUnits: number;
  86089. /** Maximum texture units per vertex shader */
  86090. maxVertexTextureImageUnits: number;
  86091. /** Maximum textures units in the entire pipeline */
  86092. maxCombinedTexturesImageUnits: number;
  86093. /** Maximum texture size */
  86094. maxTextureSize: number;
  86095. /** Maximum cube texture size */
  86096. maxCubemapTextureSize: number;
  86097. /** Maximum render texture size */
  86098. maxRenderTextureSize: number;
  86099. /** Maximum number of vertex attributes */
  86100. maxVertexAttribs: number;
  86101. /** Maximum number of varyings */
  86102. maxVaryingVectors: number;
  86103. /** Maximum number of uniforms per vertex shader */
  86104. maxVertexUniformVectors: number;
  86105. /** Maximum number of uniforms per fragment shader */
  86106. maxFragmentUniformVectors: number;
  86107. /** Defines if standard derivates (dx/dy) are supported */
  86108. standardDerivatives: boolean;
  86109. /** Defines if s3tc texture compression is supported */
  86110. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  86111. /** Defines if pvrtc texture compression is supported */
  86112. pvrtc: any;
  86113. /** Defines if etc1 texture compression is supported */
  86114. etc1: any;
  86115. /** Defines if etc2 texture compression is supported */
  86116. etc2: any;
  86117. /** Defines if astc texture compression is supported */
  86118. astc: any;
  86119. /** Defines if float textures are supported */
  86120. textureFloat: boolean;
  86121. /** Defines if vertex array objects are supported */
  86122. vertexArrayObject: boolean;
  86123. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  86124. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  86125. /** Gets the maximum level of anisotropy supported */
  86126. maxAnisotropy: number;
  86127. /** Defines if instancing is supported */
  86128. instancedArrays: boolean;
  86129. /** Defines if 32 bits indices are supported */
  86130. uintIndices: boolean;
  86131. /** Defines if high precision shaders are supported */
  86132. highPrecisionShaderSupported: boolean;
  86133. /** Defines if depth reading in the fragment shader is supported */
  86134. fragmentDepthSupported: boolean;
  86135. /** Defines if float texture linear filtering is supported*/
  86136. textureFloatLinearFiltering: boolean;
  86137. /** Defines if rendering to float textures is supported */
  86138. textureFloatRender: boolean;
  86139. /** Defines if half float textures are supported*/
  86140. textureHalfFloat: boolean;
  86141. /** Defines if half float texture linear filtering is supported*/
  86142. textureHalfFloatLinearFiltering: boolean;
  86143. /** Defines if rendering to half float textures is supported */
  86144. textureHalfFloatRender: boolean;
  86145. /** Defines if textureLOD shader command is supported */
  86146. textureLOD: boolean;
  86147. /** Defines if draw buffers extension is supported */
  86148. drawBuffersExtension: boolean;
  86149. /** Defines if depth textures are supported */
  86150. depthTextureExtension: boolean;
  86151. /** Defines if float color buffer are supported */
  86152. colorBufferFloat: boolean;
  86153. /** Gets disjoint timer query extension (null if not supported) */
  86154. timerQuery: EXT_disjoint_timer_query;
  86155. /** Defines if timestamp can be used with timer query */
  86156. canUseTimestampForTimerQuery: boolean;
  86157. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  86158. multiview: any;
  86159. /** Function used to let the system compiles shaders in background */
  86160. parallelShaderCompile: {
  86161. COMPLETION_STATUS_KHR: number;
  86162. };
  86163. }
  86164. /** Interface defining initialization parameters for Engine class */
  86165. export interface EngineOptions extends WebGLContextAttributes {
  86166. /**
  86167. * Defines if the engine should no exceed a specified device ratio
  86168. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  86169. */
  86170. limitDeviceRatio?: number;
  86171. /**
  86172. * Defines if webvr should be enabled automatically
  86173. * @see http://doc.babylonjs.com/how_to/webvr_camera
  86174. */
  86175. autoEnableWebVR?: boolean;
  86176. /**
  86177. * Defines if webgl2 should be turned off even if supported
  86178. * @see http://doc.babylonjs.com/features/webgl2
  86179. */
  86180. disableWebGL2Support?: boolean;
  86181. /**
  86182. * Defines if webaudio should be initialized as well
  86183. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  86184. */
  86185. audioEngine?: boolean;
  86186. /**
  86187. * Defines if animations should run using a deterministic lock step
  86188. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  86189. */
  86190. deterministicLockstep?: boolean;
  86191. /** Defines the maximum steps to use with deterministic lock step mode */
  86192. lockstepMaxSteps?: number;
  86193. /**
  86194. * Defines that engine should ignore context lost events
  86195. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  86196. */
  86197. doNotHandleContextLost?: boolean;
  86198. /**
  86199. * Defines that engine should ignore modifying touch action attribute and style
  86200. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  86201. */
  86202. doNotHandleTouchAction?: boolean;
  86203. /**
  86204. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  86205. */
  86206. useHighPrecisionFloats?: boolean;
  86207. }
  86208. /**
  86209. * Defines the interface used by display changed events
  86210. */
  86211. export interface IDisplayChangedEventArgs {
  86212. /** Gets the vrDisplay object (if any) */
  86213. vrDisplay: Nullable<any>;
  86214. /** Gets a boolean indicating if webVR is supported */
  86215. vrSupported: boolean;
  86216. }
  86217. /**
  86218. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  86219. */
  86220. export class Engine {
  86221. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  86222. static ExceptionList: ({
  86223. key: string;
  86224. capture: string;
  86225. captureConstraint: number;
  86226. targets: string[];
  86227. } | {
  86228. key: string;
  86229. capture: null;
  86230. captureConstraint: null;
  86231. targets: string[];
  86232. })[];
  86233. /** Gets the list of created engines */
  86234. static readonly Instances: Engine[];
  86235. /**
  86236. * Gets the latest created engine
  86237. */
  86238. static readonly LastCreatedEngine: Nullable<Engine>;
  86239. /**
  86240. * Gets the latest created scene
  86241. */
  86242. static readonly LastCreatedScene: Nullable<Scene>;
  86243. /**
  86244. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  86245. * @param flag defines which part of the materials must be marked as dirty
  86246. * @param predicate defines a predicate used to filter which materials should be affected
  86247. */
  86248. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  86249. /**
  86250. * Hidden
  86251. */
  86252. static _TextureLoaders: IInternalTextureLoader[];
  86253. /** Defines that alpha blending is disabled */
  86254. static readonly ALPHA_DISABLE: number;
  86255. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  86256. static readonly ALPHA_ADD: number;
  86257. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  86258. static readonly ALPHA_COMBINE: number;
  86259. /** Defines that alpha blending to DEST - SRC * DEST */
  86260. static readonly ALPHA_SUBTRACT: number;
  86261. /** Defines that alpha blending to SRC * DEST */
  86262. static readonly ALPHA_MULTIPLY: number;
  86263. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  86264. static readonly ALPHA_MAXIMIZED: number;
  86265. /** Defines that alpha blending to SRC + DEST */
  86266. static readonly ALPHA_ONEONE: number;
  86267. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  86268. static readonly ALPHA_PREMULTIPLIED: number;
  86269. /**
  86270. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  86271. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  86272. */
  86273. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  86274. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  86275. static readonly ALPHA_INTERPOLATE: number;
  86276. /**
  86277. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  86278. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  86279. */
  86280. static readonly ALPHA_SCREENMODE: number;
  86281. /** Defines that the ressource is not delayed*/
  86282. static readonly DELAYLOADSTATE_NONE: number;
  86283. /** Defines that the ressource was successfully delay loaded */
  86284. static readonly DELAYLOADSTATE_LOADED: number;
  86285. /** Defines that the ressource is currently delay loading */
  86286. static readonly DELAYLOADSTATE_LOADING: number;
  86287. /** Defines that the ressource is delayed and has not started loading */
  86288. static readonly DELAYLOADSTATE_NOTLOADED: number;
  86289. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  86290. static readonly NEVER: number;
  86291. /** 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 */
  86292. static readonly ALWAYS: number;
  86293. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  86294. static readonly LESS: number;
  86295. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  86296. static readonly EQUAL: number;
  86297. /** 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 */
  86298. static readonly LEQUAL: number;
  86299. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  86300. static readonly GREATER: number;
  86301. /** 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 */
  86302. static readonly GEQUAL: number;
  86303. /** 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 */
  86304. static readonly NOTEQUAL: number;
  86305. /** Passed to stencilOperation to specify that stencil value must be kept */
  86306. static readonly KEEP: number;
  86307. /** Passed to stencilOperation to specify that stencil value must be replaced */
  86308. static readonly REPLACE: number;
  86309. /** Passed to stencilOperation to specify that stencil value must be incremented */
  86310. static readonly INCR: number;
  86311. /** Passed to stencilOperation to specify that stencil value must be decremented */
  86312. static readonly DECR: number;
  86313. /** Passed to stencilOperation to specify that stencil value must be inverted */
  86314. static readonly INVERT: number;
  86315. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  86316. static readonly INCR_WRAP: number;
  86317. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  86318. static readonly DECR_WRAP: number;
  86319. /** Texture is not repeating outside of 0..1 UVs */
  86320. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  86321. /** Texture is repeating outside of 0..1 UVs */
  86322. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  86323. /** Texture is repeating and mirrored */
  86324. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  86325. /** ALPHA */
  86326. static readonly TEXTUREFORMAT_ALPHA: number;
  86327. /** LUMINANCE */
  86328. static readonly TEXTUREFORMAT_LUMINANCE: number;
  86329. /** LUMINANCE_ALPHA */
  86330. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  86331. /** RGB */
  86332. static readonly TEXTUREFORMAT_RGB: number;
  86333. /** RGBA */
  86334. static readonly TEXTUREFORMAT_RGBA: number;
  86335. /** RED */
  86336. static readonly TEXTUREFORMAT_RED: number;
  86337. /** RED (2nd reference) */
  86338. static readonly TEXTUREFORMAT_R: number;
  86339. /** RG */
  86340. static readonly TEXTUREFORMAT_RG: number;
  86341. /** RED_INTEGER */
  86342. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  86343. /** RED_INTEGER (2nd reference) */
  86344. static readonly TEXTUREFORMAT_R_INTEGER: number;
  86345. /** RG_INTEGER */
  86346. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  86347. /** RGB_INTEGER */
  86348. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  86349. /** RGBA_INTEGER */
  86350. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  86351. /** UNSIGNED_BYTE */
  86352. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  86353. /** UNSIGNED_BYTE (2nd reference) */
  86354. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  86355. /** FLOAT */
  86356. static readonly TEXTURETYPE_FLOAT: number;
  86357. /** HALF_FLOAT */
  86358. static readonly TEXTURETYPE_HALF_FLOAT: number;
  86359. /** BYTE */
  86360. static readonly TEXTURETYPE_BYTE: number;
  86361. /** SHORT */
  86362. static readonly TEXTURETYPE_SHORT: number;
  86363. /** UNSIGNED_SHORT */
  86364. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  86365. /** INT */
  86366. static readonly TEXTURETYPE_INT: number;
  86367. /** UNSIGNED_INT */
  86368. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  86369. /** UNSIGNED_SHORT_4_4_4_4 */
  86370. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  86371. /** UNSIGNED_SHORT_5_5_5_1 */
  86372. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  86373. /** UNSIGNED_SHORT_5_6_5 */
  86374. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  86375. /** UNSIGNED_INT_2_10_10_10_REV */
  86376. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  86377. /** UNSIGNED_INT_24_8 */
  86378. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  86379. /** UNSIGNED_INT_10F_11F_11F_REV */
  86380. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  86381. /** UNSIGNED_INT_5_9_9_9_REV */
  86382. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  86383. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  86384. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  86385. /** nearest is mag = nearest and min = nearest and mip = linear */
  86386. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  86387. /** Bilinear is mag = linear and min = linear and mip = nearest */
  86388. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  86389. /** Trilinear is mag = linear and min = linear and mip = linear */
  86390. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  86391. /** nearest is mag = nearest and min = nearest and mip = linear */
  86392. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  86393. /** Bilinear is mag = linear and min = linear and mip = nearest */
  86394. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  86395. /** Trilinear is mag = linear and min = linear and mip = linear */
  86396. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  86397. /** mag = nearest and min = nearest and mip = nearest */
  86398. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  86399. /** mag = nearest and min = linear and mip = nearest */
  86400. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  86401. /** mag = nearest and min = linear and mip = linear */
  86402. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  86403. /** mag = nearest and min = linear and mip = none */
  86404. static readonly TEXTURE_NEAREST_LINEAR: number;
  86405. /** mag = nearest and min = nearest and mip = none */
  86406. static readonly TEXTURE_NEAREST_NEAREST: number;
  86407. /** mag = linear and min = nearest and mip = nearest */
  86408. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  86409. /** mag = linear and min = nearest and mip = linear */
  86410. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  86411. /** mag = linear and min = linear and mip = none */
  86412. static readonly TEXTURE_LINEAR_LINEAR: number;
  86413. /** mag = linear and min = nearest and mip = none */
  86414. static readonly TEXTURE_LINEAR_NEAREST: number;
  86415. /** Explicit coordinates mode */
  86416. static readonly TEXTURE_EXPLICIT_MODE: number;
  86417. /** Spherical coordinates mode */
  86418. static readonly TEXTURE_SPHERICAL_MODE: number;
  86419. /** Planar coordinates mode */
  86420. static readonly TEXTURE_PLANAR_MODE: number;
  86421. /** Cubic coordinates mode */
  86422. static readonly TEXTURE_CUBIC_MODE: number;
  86423. /** Projection coordinates mode */
  86424. static readonly TEXTURE_PROJECTION_MODE: number;
  86425. /** Skybox coordinates mode */
  86426. static readonly TEXTURE_SKYBOX_MODE: number;
  86427. /** Inverse Cubic coordinates mode */
  86428. static readonly TEXTURE_INVCUBIC_MODE: number;
  86429. /** Equirectangular coordinates mode */
  86430. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  86431. /** Equirectangular Fixed coordinates mode */
  86432. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  86433. /** Equirectangular Fixed Mirrored coordinates mode */
  86434. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  86435. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  86436. static readonly SCALEMODE_FLOOR: number;
  86437. /** Defines that texture rescaling will look for the nearest power of 2 size */
  86438. static readonly SCALEMODE_NEAREST: number;
  86439. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  86440. static readonly SCALEMODE_CEILING: number;
  86441. /**
  86442. * Returns the current npm package of the sdk
  86443. */
  86444. static readonly NpmPackage: string;
  86445. /**
  86446. * Returns the current version of the framework
  86447. */
  86448. static readonly Version: string;
  86449. /**
  86450. * Returns a string describing the current engine
  86451. */
  86452. readonly description: string;
  86453. /**
  86454. * Gets or sets the epsilon value used by collision engine
  86455. */
  86456. static CollisionsEpsilon: number;
  86457. /**
  86458. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  86459. */
  86460. static ShadersRepository: string;
  86461. /**
  86462. * Method called to create the default loading screen.
  86463. * This can be overriden in your own app.
  86464. * @param canvas The rendering canvas element
  86465. * @returns The loading screen
  86466. */
  86467. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  86468. /**
  86469. * Method called to create the default rescale post process on each engine.
  86470. */
  86471. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  86472. /**
  86473. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  86474. */
  86475. forcePOTTextures: boolean;
  86476. /**
  86477. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  86478. */
  86479. isFullscreen: boolean;
  86480. /**
  86481. * Gets a boolean indicating if the pointer is currently locked
  86482. */
  86483. isPointerLock: boolean;
  86484. /**
  86485. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  86486. */
  86487. cullBackFaces: boolean;
  86488. /**
  86489. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  86490. */
  86491. renderEvenInBackground: boolean;
  86492. /**
  86493. * Gets or sets a boolean indicating that cache can be kept between frames
  86494. */
  86495. preventCacheWipeBetweenFrames: boolean;
  86496. /**
  86497. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  86498. **/
  86499. enableOfflineSupport: boolean;
  86500. /**
  86501. * 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)
  86502. **/
  86503. disableManifestCheck: boolean;
  86504. /**
  86505. * Gets the list of created scenes
  86506. */
  86507. scenes: Scene[];
  86508. /**
  86509. * Event raised when a new scene is created
  86510. */
  86511. onNewSceneAddedObservable: Observable<Scene>;
  86512. /**
  86513. * Gets the list of created postprocesses
  86514. */
  86515. postProcesses: PostProcess[];
  86516. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  86517. validateShaderPrograms: boolean;
  86518. /**
  86519. * Observable event triggered each time the rendering canvas is resized
  86520. */
  86521. onResizeObservable: Observable<Engine>;
  86522. /**
  86523. * Observable event triggered each time the canvas loses focus
  86524. */
  86525. onCanvasBlurObservable: Observable<Engine>;
  86526. /**
  86527. * Observable event triggered each time the canvas gains focus
  86528. */
  86529. onCanvasFocusObservable: Observable<Engine>;
  86530. /**
  86531. * Observable event triggered each time the canvas receives pointerout event
  86532. */
  86533. onCanvasPointerOutObservable: Observable<PointerEvent>;
  86534. /**
  86535. * Observable event triggered before each texture is initialized
  86536. */
  86537. onBeforeTextureInitObservable: Observable<Texture>;
  86538. private _vrDisplay;
  86539. private _vrSupported;
  86540. private _oldSize;
  86541. private _oldHardwareScaleFactor;
  86542. private _vrExclusivePointerMode;
  86543. private _webVRInitPromise;
  86544. /**
  86545. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  86546. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  86547. */
  86548. readonly isInVRExclusivePointerMode: boolean;
  86549. /**
  86550. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  86551. */
  86552. disableUniformBuffers: boolean;
  86553. /** @hidden */
  86554. _uniformBuffers: UniformBuffer[];
  86555. /**
  86556. * Gets a boolean indicating that the engine supports uniform buffers
  86557. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  86558. */
  86559. readonly supportsUniformBuffers: boolean;
  86560. /**
  86561. * Observable raised when the engine begins a new frame
  86562. */
  86563. onBeginFrameObservable: Observable<Engine>;
  86564. /**
  86565. * If set, will be used to request the next animation frame for the render loop
  86566. */
  86567. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  86568. /**
  86569. * Observable raised when the engine ends the current frame
  86570. */
  86571. onEndFrameObservable: Observable<Engine>;
  86572. /**
  86573. * Observable raised when the engine is about to compile a shader
  86574. */
  86575. onBeforeShaderCompilationObservable: Observable<Engine>;
  86576. /**
  86577. * Observable raised when the engine has jsut compiled a shader
  86578. */
  86579. onAfterShaderCompilationObservable: Observable<Engine>;
  86580. /** @hidden */
  86581. _gl: WebGLRenderingContext;
  86582. private _renderingCanvas;
  86583. private _windowIsBackground;
  86584. private _webGLVersion;
  86585. protected _highPrecisionShadersAllowed: boolean;
  86586. /** @hidden */
  86587. readonly _shouldUseHighPrecisionShader: boolean;
  86588. /**
  86589. * Gets a boolean indicating that only power of 2 textures are supported
  86590. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  86591. */
  86592. readonly needPOTTextures: boolean;
  86593. /** @hidden */
  86594. _badOS: boolean;
  86595. /** @hidden */
  86596. _badDesktopOS: boolean;
  86597. /**
  86598. * Gets the audio engine
  86599. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  86600. * @ignorenaming
  86601. */
  86602. static audioEngine: IAudioEngine;
  86603. /**
  86604. * Default AudioEngine factory responsible of creating the Audio Engine.
  86605. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  86606. */
  86607. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  86608. /**
  86609. * Default offline support factory responsible of creating a tool used to store data locally.
  86610. * By default, this will create a Database object if the workload has been embedded.
  86611. */
  86612. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  86613. private _onFocus;
  86614. private _onBlur;
  86615. private _onCanvasPointerOut;
  86616. private _onCanvasBlur;
  86617. private _onCanvasFocus;
  86618. private _onFullscreenChange;
  86619. private _onPointerLockChange;
  86620. private _onVRDisplayPointerRestricted;
  86621. private _onVRDisplayPointerUnrestricted;
  86622. private _onVrDisplayConnect;
  86623. private _onVrDisplayDisconnect;
  86624. private _onVrDisplayPresentChange;
  86625. /**
  86626. * Observable signaled when VR display mode changes
  86627. */
  86628. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  86629. /**
  86630. * Observable signaled when VR request present is complete
  86631. */
  86632. onVRRequestPresentComplete: Observable<boolean>;
  86633. /**
  86634. * Observable signaled when VR request present starts
  86635. */
  86636. onVRRequestPresentStart: Observable<Engine>;
  86637. private _hardwareScalingLevel;
  86638. /** @hidden */
  86639. protected _caps: EngineCapabilities;
  86640. private _pointerLockRequested;
  86641. private _isStencilEnable;
  86642. private _colorWrite;
  86643. private _loadingScreen;
  86644. /** @hidden */
  86645. _drawCalls: PerfCounter;
  86646. private _glVersion;
  86647. private _glRenderer;
  86648. private _glVendor;
  86649. private _videoTextureSupported;
  86650. private _renderingQueueLaunched;
  86651. private _activeRenderLoops;
  86652. private _deterministicLockstep;
  86653. private _lockstepMaxSteps;
  86654. /**
  86655. * Observable signaled when a context lost event is raised
  86656. */
  86657. onContextLostObservable: Observable<Engine>;
  86658. /**
  86659. * Observable signaled when a context restored event is raised
  86660. */
  86661. onContextRestoredObservable: Observable<Engine>;
  86662. private _onContextLost;
  86663. private _onContextRestored;
  86664. private _contextWasLost;
  86665. private _doNotHandleContextLost;
  86666. /**
  86667. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  86668. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  86669. */
  86670. doNotHandleContextLost: boolean;
  86671. private _performanceMonitor;
  86672. private _fps;
  86673. private _deltaTime;
  86674. /**
  86675. * Turn this value on if you want to pause FPS computation when in background
  86676. */
  86677. disablePerformanceMonitorInBackground: boolean;
  86678. /**
  86679. * Gets the performance monitor attached to this engine
  86680. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  86681. */
  86682. readonly performanceMonitor: PerformanceMonitor;
  86683. /**
  86684. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  86685. */
  86686. disableVertexArrayObjects: boolean;
  86687. /** @hidden */
  86688. protected _depthCullingState: _DepthCullingState;
  86689. /** @hidden */
  86690. protected _stencilState: _StencilState;
  86691. /** @hidden */
  86692. protected _alphaState: _AlphaState;
  86693. /** @hidden */
  86694. protected _alphaMode: number;
  86695. protected _internalTexturesCache: InternalTexture[];
  86696. /** @hidden */
  86697. protected _activeChannel: number;
  86698. private _currentTextureChannel;
  86699. /** @hidden */
  86700. protected _boundTexturesCache: {
  86701. [key: string]: Nullable<InternalTexture>;
  86702. };
  86703. /** @hidden */
  86704. protected _currentEffect: Nullable<Effect>;
  86705. /** @hidden */
  86706. protected _currentProgram: Nullable<WebGLProgram>;
  86707. private _compiledEffects;
  86708. private _vertexAttribArraysEnabled;
  86709. /** @hidden */
  86710. protected _cachedViewport: Nullable<Viewport>;
  86711. private _cachedVertexArrayObject;
  86712. /** @hidden */
  86713. protected _cachedVertexBuffers: any;
  86714. /** @hidden */
  86715. protected _cachedIndexBuffer: Nullable<WebGLBuffer>;
  86716. /** @hidden */
  86717. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  86718. /** @hidden */
  86719. protected _currentRenderTarget: Nullable<InternalTexture>;
  86720. private _uintIndicesCurrentlySet;
  86721. private _currentBoundBuffer;
  86722. /** @hidden */
  86723. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  86724. private _currentBufferPointers;
  86725. private _currentInstanceLocations;
  86726. private _currentInstanceBuffers;
  86727. private _textureUnits;
  86728. private _workingCanvas;
  86729. private _workingContext;
  86730. private _rescalePostProcess;
  86731. private _dummyFramebuffer;
  86732. private _externalData;
  86733. private _bindedRenderFunction;
  86734. private _vaoRecordInProgress;
  86735. private _mustWipeVertexAttributes;
  86736. private _emptyTexture;
  86737. private _emptyCubeTexture;
  86738. private _emptyTexture3D;
  86739. /** @hidden */
  86740. _frameHandler: number;
  86741. private _nextFreeTextureSlots;
  86742. private _maxSimultaneousTextures;
  86743. private _activeRequests;
  86744. private _texturesSupported;
  86745. private _textureFormatInUse;
  86746. /**
  86747. * Gets the list of texture formats supported
  86748. */
  86749. readonly texturesSupported: Array<string>;
  86750. /**
  86751. * Gets the list of texture formats in use
  86752. */
  86753. readonly textureFormatInUse: Nullable<string>;
  86754. /**
  86755. * Gets the current viewport
  86756. */
  86757. readonly currentViewport: Nullable<Viewport>;
  86758. /**
  86759. * Gets the default empty texture
  86760. */
  86761. readonly emptyTexture: InternalTexture;
  86762. /**
  86763. * Gets the default empty 3D texture
  86764. */
  86765. readonly emptyTexture3D: InternalTexture;
  86766. /**
  86767. * Gets the default empty cube texture
  86768. */
  86769. readonly emptyCubeTexture: InternalTexture;
  86770. /**
  86771. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  86772. */
  86773. readonly premultipliedAlpha: boolean;
  86774. /**
  86775. * Creates a new engine
  86776. * @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
  86777. * @param antialias defines enable antialiasing (default: false)
  86778. * @param options defines further options to be sent to the getContext() function
  86779. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  86780. */
  86781. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  86782. private _disableTouchAction;
  86783. private _rebuildInternalTextures;
  86784. private _rebuildEffects;
  86785. /**
  86786. * Gets a boolean indicating if all created effects are ready
  86787. * @returns true if all effects are ready
  86788. */
  86789. areAllEffectsReady(): boolean;
  86790. private _rebuildBuffers;
  86791. private _initGLContext;
  86792. /**
  86793. * Gets version of the current webGL context
  86794. */
  86795. readonly webGLVersion: number;
  86796. /**
  86797. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  86798. */
  86799. readonly isStencilEnable: boolean;
  86800. private _prepareWorkingCanvas;
  86801. /**
  86802. * Reset the texture cache to empty state
  86803. */
  86804. resetTextureCache(): void;
  86805. /**
  86806. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  86807. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  86808. * @returns true if engine is in deterministic lock step mode
  86809. */
  86810. isDeterministicLockStep(): boolean;
  86811. /**
  86812. * Gets the max steps when engine is running in deterministic lock step
  86813. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  86814. * @returns the max steps
  86815. */
  86816. getLockstepMaxSteps(): number;
  86817. /**
  86818. * Gets an object containing information about the current webGL context
  86819. * @returns an object containing the vender, the renderer and the version of the current webGL context
  86820. */
  86821. getGlInfo(): {
  86822. vendor: string;
  86823. renderer: string;
  86824. version: string;
  86825. };
  86826. /**
  86827. * Gets current aspect ratio
  86828. * @param camera defines the camera to use to get the aspect ratio
  86829. * @param useScreen defines if screen size must be used (or the current render target if any)
  86830. * @returns a number defining the aspect ratio
  86831. */
  86832. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  86833. /**
  86834. * Gets current screen aspect ratio
  86835. * @returns a number defining the aspect ratio
  86836. */
  86837. getScreenAspectRatio(): number;
  86838. /**
  86839. * Gets the current render width
  86840. * @param useScreen defines if screen size must be used (or the current render target if any)
  86841. * @returns a number defining the current render width
  86842. */
  86843. getRenderWidth(useScreen?: boolean): number;
  86844. /**
  86845. * Gets the current render height
  86846. * @param useScreen defines if screen size must be used (or the current render target if any)
  86847. * @returns a number defining the current render height
  86848. */
  86849. getRenderHeight(useScreen?: boolean): number;
  86850. /**
  86851. * Gets the HTML canvas attached with the current webGL context
  86852. * @returns a HTML canvas
  86853. */
  86854. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  86855. /**
  86856. * Gets the client rect of the HTML canvas attached with the current webGL context
  86857. * @returns a client rectanglee
  86858. */
  86859. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  86860. /**
  86861. * Defines the hardware scaling level.
  86862. * By default the hardware scaling level is computed from the window device ratio.
  86863. * 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.
  86864. * @param level defines the level to use
  86865. */
  86866. setHardwareScalingLevel(level: number): void;
  86867. /**
  86868. * Gets the current hardware scaling level.
  86869. * By default the hardware scaling level is computed from the window device ratio.
  86870. * 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.
  86871. * @returns a number indicating the current hardware scaling level
  86872. */
  86873. getHardwareScalingLevel(): number;
  86874. /**
  86875. * Gets the list of loaded textures
  86876. * @returns an array containing all loaded textures
  86877. */
  86878. getLoadedTexturesCache(): InternalTexture[];
  86879. /**
  86880. * Gets the object containing all engine capabilities
  86881. * @returns the EngineCapabilities object
  86882. */
  86883. getCaps(): EngineCapabilities;
  86884. /**
  86885. * Gets the current depth function
  86886. * @returns a number defining the depth function
  86887. */
  86888. getDepthFunction(): Nullable<number>;
  86889. /**
  86890. * Sets the current depth function
  86891. * @param depthFunc defines the function to use
  86892. */
  86893. setDepthFunction(depthFunc: number): void;
  86894. /**
  86895. * Sets the current depth function to GREATER
  86896. */
  86897. setDepthFunctionToGreater(): void;
  86898. /**
  86899. * Sets the current depth function to GEQUAL
  86900. */
  86901. setDepthFunctionToGreaterOrEqual(): void;
  86902. /**
  86903. * Sets the current depth function to LESS
  86904. */
  86905. setDepthFunctionToLess(): void;
  86906. private _cachedStencilBuffer;
  86907. private _cachedStencilFunction;
  86908. private _cachedStencilMask;
  86909. private _cachedStencilOperationPass;
  86910. private _cachedStencilOperationFail;
  86911. private _cachedStencilOperationDepthFail;
  86912. private _cachedStencilReference;
  86913. /**
  86914. * Caches the the state of the stencil buffer
  86915. */
  86916. cacheStencilState(): void;
  86917. /**
  86918. * Restores the state of the stencil buffer
  86919. */
  86920. restoreStencilState(): void;
  86921. /**
  86922. * Sets the current depth function to LEQUAL
  86923. */
  86924. setDepthFunctionToLessOrEqual(): void;
  86925. /**
  86926. * Gets a boolean indicating if stencil buffer is enabled
  86927. * @returns the current stencil buffer state
  86928. */
  86929. getStencilBuffer(): boolean;
  86930. /**
  86931. * Enable or disable the stencil buffer
  86932. * @param enable defines if the stencil buffer must be enabled or disabled
  86933. */
  86934. setStencilBuffer(enable: boolean): void;
  86935. /**
  86936. * Gets the current stencil mask
  86937. * @returns a number defining the new stencil mask to use
  86938. */
  86939. getStencilMask(): number;
  86940. /**
  86941. * Sets the current stencil mask
  86942. * @param mask defines the new stencil mask to use
  86943. */
  86944. setStencilMask(mask: number): void;
  86945. /**
  86946. * Gets the current stencil function
  86947. * @returns a number defining the stencil function to use
  86948. */
  86949. getStencilFunction(): number;
  86950. /**
  86951. * Gets the current stencil reference value
  86952. * @returns a number defining the stencil reference value to use
  86953. */
  86954. getStencilFunctionReference(): number;
  86955. /**
  86956. * Gets the current stencil mask
  86957. * @returns a number defining the stencil mask to use
  86958. */
  86959. getStencilFunctionMask(): number;
  86960. /**
  86961. * Sets the current stencil function
  86962. * @param stencilFunc defines the new stencil function to use
  86963. */
  86964. setStencilFunction(stencilFunc: number): void;
  86965. /**
  86966. * Sets the current stencil reference
  86967. * @param reference defines the new stencil reference to use
  86968. */
  86969. setStencilFunctionReference(reference: number): void;
  86970. /**
  86971. * Sets the current stencil mask
  86972. * @param mask defines the new stencil mask to use
  86973. */
  86974. setStencilFunctionMask(mask: number): void;
  86975. /**
  86976. * Gets the current stencil operation when stencil fails
  86977. * @returns a number defining stencil operation to use when stencil fails
  86978. */
  86979. getStencilOperationFail(): number;
  86980. /**
  86981. * Gets the current stencil operation when depth fails
  86982. * @returns a number defining stencil operation to use when depth fails
  86983. */
  86984. getStencilOperationDepthFail(): number;
  86985. /**
  86986. * Gets the current stencil operation when stencil passes
  86987. * @returns a number defining stencil operation to use when stencil passes
  86988. */
  86989. getStencilOperationPass(): number;
  86990. /**
  86991. * Sets the stencil operation to use when stencil fails
  86992. * @param operation defines the stencil operation to use when stencil fails
  86993. */
  86994. setStencilOperationFail(operation: number): void;
  86995. /**
  86996. * Sets the stencil operation to use when depth fails
  86997. * @param operation defines the stencil operation to use when depth fails
  86998. */
  86999. setStencilOperationDepthFail(operation: number): void;
  87000. /**
  87001. * Sets the stencil operation to use when stencil passes
  87002. * @param operation defines the stencil operation to use when stencil passes
  87003. */
  87004. setStencilOperationPass(operation: number): void;
  87005. /**
  87006. * Sets a boolean indicating if the dithering state is enabled or disabled
  87007. * @param value defines the dithering state
  87008. */
  87009. setDitheringState(value: boolean): void;
  87010. /**
  87011. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  87012. * @param value defines the rasterizer state
  87013. */
  87014. setRasterizerState(value: boolean): void;
  87015. /**
  87016. * stop executing a render loop function and remove it from the execution array
  87017. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  87018. */
  87019. stopRenderLoop(renderFunction?: () => void): void;
  87020. /** @hidden */
  87021. _renderLoop(): void;
  87022. /**
  87023. * Register and execute a render loop. The engine can have more than one render function
  87024. * @param renderFunction defines the function to continuously execute
  87025. */
  87026. runRenderLoop(renderFunction: () => void): void;
  87027. /**
  87028. * Toggle full screen mode
  87029. * @param requestPointerLock defines if a pointer lock should be requested from the user
  87030. */
  87031. switchFullscreen(requestPointerLock: boolean): void;
  87032. /**
  87033. * Enters full screen mode
  87034. * @param requestPointerLock defines if a pointer lock should be requested from the user
  87035. */
  87036. enterFullscreen(requestPointerLock: boolean): void;
  87037. /**
  87038. * Exits full screen mode
  87039. */
  87040. exitFullscreen(): void;
  87041. /**
  87042. * Clear the current render buffer or the current render target (if any is set up)
  87043. * @param color defines the color to use
  87044. * @param backBuffer defines if the back buffer must be cleared
  87045. * @param depth defines if the depth buffer must be cleared
  87046. * @param stencil defines if the stencil buffer must be cleared
  87047. */
  87048. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  87049. /**
  87050. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  87051. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  87052. * @param y defines the y-coordinate of the corner of the clear rectangle
  87053. * @param width defines the width of the clear rectangle
  87054. * @param height defines the height of the clear rectangle
  87055. * @param clearColor defines the clear color
  87056. */
  87057. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  87058. /**
  87059. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  87060. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  87061. * @param y defines the y-coordinate of the corner of the clear rectangle
  87062. * @param width defines the width of the clear rectangle
  87063. * @param height defines the height of the clear rectangle
  87064. */
  87065. enableScissor(x: number, y: number, width: number, height: number): void;
  87066. /**
  87067. * Disable previously set scissor test rectangle
  87068. */
  87069. disableScissor(): void;
  87070. private _viewportCached;
  87071. /** @hidden */
  87072. _viewport(x: number, y: number, width: number, height: number): void;
  87073. /**
  87074. * Set the WebGL's viewport
  87075. * @param viewport defines the viewport element to be used
  87076. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  87077. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  87078. */
  87079. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  87080. /**
  87081. * Directly set the WebGL Viewport
  87082. * @param x defines the x coordinate of the viewport (in screen space)
  87083. * @param y defines the y coordinate of the viewport (in screen space)
  87084. * @param width defines the width of the viewport (in screen space)
  87085. * @param height defines the height of the viewport (in screen space)
  87086. * @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
  87087. */
  87088. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  87089. /**
  87090. * Begin a new frame
  87091. */
  87092. beginFrame(): void;
  87093. /**
  87094. * Enf the current frame
  87095. */
  87096. endFrame(): void;
  87097. /**
  87098. * Resize the view according to the canvas' size
  87099. */
  87100. resize(): void;
  87101. /**
  87102. * Force a specific size of the canvas
  87103. * @param width defines the new canvas' width
  87104. * @param height defines the new canvas' height
  87105. */
  87106. setSize(width: number, height: number): void;
  87107. /**
  87108. * Gets a boolean indicating if a webVR device was detected
  87109. * @returns true if a webVR device was detected
  87110. */
  87111. isVRDevicePresent(): boolean;
  87112. /**
  87113. * Gets the current webVR device
  87114. * @returns the current webVR device (or null)
  87115. */
  87116. getVRDevice(): any;
  87117. /**
  87118. * Initializes a webVR display and starts listening to display change events
  87119. * The onVRDisplayChangedObservable will be notified upon these changes
  87120. * @returns The onVRDisplayChangedObservable
  87121. */
  87122. initWebVR(): Observable<IDisplayChangedEventArgs>;
  87123. /**
  87124. * Initializes a webVR display and starts listening to display change events
  87125. * The onVRDisplayChangedObservable will be notified upon these changes
  87126. * @returns A promise containing a VRDisplay and if vr is supported
  87127. */
  87128. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  87129. /**
  87130. * Call this function to switch to webVR mode
  87131. * Will do nothing if webVR is not supported or if there is no webVR device
  87132. * @see http://doc.babylonjs.com/how_to/webvr_camera
  87133. */
  87134. enableVR(): void;
  87135. /**
  87136. * Call this function to leave webVR mode
  87137. * Will do nothing if webVR is not supported or if there is no webVR device
  87138. * @see http://doc.babylonjs.com/how_to/webvr_camera
  87139. */
  87140. disableVR(): void;
  87141. private _onVRFullScreenTriggered;
  87142. private _getVRDisplaysAsync;
  87143. /**
  87144. * Binds the frame buffer to the specified texture.
  87145. * @param texture The texture to render to or null for the default canvas
  87146. * @param faceIndex The face of the texture to render to in case of cube texture
  87147. * @param requiredWidth The width of the target to render to
  87148. * @param requiredHeight The height of the target to render to
  87149. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  87150. * @param depthStencilTexture The depth stencil texture to use to render
  87151. * @param lodLevel defines le lod level to bind to the frame buffer
  87152. */
  87153. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  87154. private bindUnboundFramebuffer;
  87155. /**
  87156. * Unbind the current render target texture from the webGL context
  87157. * @param texture defines the render target texture to unbind
  87158. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  87159. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  87160. */
  87161. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  87162. /**
  87163. * Unbind a list of render target textures from the webGL context
  87164. * This is used only when drawBuffer extension or webGL2 are active
  87165. * @param textures defines the render target textures to unbind
  87166. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  87167. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  87168. */
  87169. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  87170. /**
  87171. * Force the mipmap generation for the given render target texture
  87172. * @param texture defines the render target texture to use
  87173. */
  87174. generateMipMapsForCubemap(texture: InternalTexture): void;
  87175. /**
  87176. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  87177. */
  87178. flushFramebuffer(): void;
  87179. /**
  87180. * Unbind the current render target and bind the default framebuffer
  87181. */
  87182. restoreDefaultFramebuffer(): void;
  87183. /**
  87184. * Create an uniform buffer
  87185. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  87186. * @param elements defines the content of the uniform buffer
  87187. * @returns the webGL uniform buffer
  87188. */
  87189. createUniformBuffer(elements: FloatArray): WebGLBuffer;
  87190. /**
  87191. * Create a dynamic uniform buffer
  87192. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  87193. * @param elements defines the content of the uniform buffer
  87194. * @returns the webGL uniform buffer
  87195. */
  87196. createDynamicUniformBuffer(elements: FloatArray): WebGLBuffer;
  87197. /**
  87198. * Update an existing uniform buffer
  87199. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  87200. * @param uniformBuffer defines the target uniform buffer
  87201. * @param elements defines the content to update
  87202. * @param offset defines the offset in the uniform buffer where update should start
  87203. * @param count defines the size of the data to update
  87204. */
  87205. updateUniformBuffer(uniformBuffer: WebGLBuffer, elements: FloatArray, offset?: number, count?: number): void;
  87206. private _resetVertexBufferBinding;
  87207. /**
  87208. * Creates a vertex buffer
  87209. * @param data the data for the vertex buffer
  87210. * @returns the new WebGL static buffer
  87211. */
  87212. createVertexBuffer(data: DataArray): WebGLBuffer;
  87213. /**
  87214. * Creates a dynamic vertex buffer
  87215. * @param data the data for the dynamic vertex buffer
  87216. * @returns the new WebGL dynamic buffer
  87217. */
  87218. createDynamicVertexBuffer(data: DataArray): WebGLBuffer;
  87219. /**
  87220. * Update a dynamic index buffer
  87221. * @param indexBuffer defines the target index buffer
  87222. * @param indices defines the data to update
  87223. * @param offset defines the offset in the target index buffer where update should start
  87224. */
  87225. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  87226. /**
  87227. * Updates a dynamic vertex buffer.
  87228. * @param vertexBuffer the vertex buffer to update
  87229. * @param data the data used to update the vertex buffer
  87230. * @param byteOffset the byte offset of the data
  87231. * @param byteLength the byte length of the data
  87232. */
  87233. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  87234. private _resetIndexBufferBinding;
  87235. /**
  87236. * Creates a new index buffer
  87237. * @param indices defines the content of the index buffer
  87238. * @param updatable defines if the index buffer must be updatable
  87239. * @returns a new webGL buffer
  87240. */
  87241. createIndexBuffer(indices: IndicesArray, updatable?: boolean): WebGLBuffer;
  87242. /**
  87243. * Bind a webGL buffer to the webGL context
  87244. * @param buffer defines the buffer to bind
  87245. */
  87246. bindArrayBuffer(buffer: Nullable<WebGLBuffer>): void;
  87247. /**
  87248. * Bind an uniform buffer to the current webGL context
  87249. * @param buffer defines the buffer to bind
  87250. */
  87251. bindUniformBuffer(buffer: Nullable<WebGLBuffer>): void;
  87252. /**
  87253. * Bind a buffer to the current webGL context at a given location
  87254. * @param buffer defines the buffer to bind
  87255. * @param location defines the index where to bind the buffer
  87256. */
  87257. bindUniformBufferBase(buffer: WebGLBuffer, location: number): void;
  87258. /**
  87259. * Bind a specific block at a given index in a specific shader program
  87260. * @param shaderProgram defines the shader program
  87261. * @param blockName defines the block name
  87262. * @param index defines the index where to bind the block
  87263. */
  87264. bindUniformBlock(shaderProgram: WebGLProgram, blockName: string, index: number): void;
  87265. private bindIndexBuffer;
  87266. private bindBuffer;
  87267. /**
  87268. * update the bound buffer with the given data
  87269. * @param data defines the data to update
  87270. */
  87271. updateArrayBuffer(data: Float32Array): void;
  87272. private _vertexAttribPointer;
  87273. private _bindIndexBufferWithCache;
  87274. private _bindVertexBuffersAttributes;
  87275. /**
  87276. * Records a vertex array object
  87277. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  87278. * @param vertexBuffers defines the list of vertex buffers to store
  87279. * @param indexBuffer defines the index buffer to store
  87280. * @param effect defines the effect to store
  87281. * @returns the new vertex array object
  87282. */
  87283. recordVertexArrayObject(vertexBuffers: {
  87284. [key: string]: VertexBuffer;
  87285. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): WebGLVertexArrayObject;
  87286. /**
  87287. * Bind a specific vertex array object
  87288. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  87289. * @param vertexArrayObject defines the vertex array object to bind
  87290. * @param indexBuffer defines the index buffer to bind
  87291. */
  87292. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<WebGLBuffer>): void;
  87293. /**
  87294. * Bind webGl buffers directly to the webGL context
  87295. * @param vertexBuffer defines the vertex buffer to bind
  87296. * @param indexBuffer defines the index buffer to bind
  87297. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  87298. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  87299. * @param effect defines the effect associated with the vertex buffer
  87300. */
  87301. bindBuffersDirectly(vertexBuffer: WebGLBuffer, indexBuffer: WebGLBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  87302. private _unbindVertexArrayObject;
  87303. /**
  87304. * Bind a list of vertex buffers to the webGL context
  87305. * @param vertexBuffers defines the list of vertex buffers to bind
  87306. * @param indexBuffer defines the index buffer to bind
  87307. * @param effect defines the effect associated with the vertex buffers
  87308. */
  87309. bindBuffers(vertexBuffers: {
  87310. [key: string]: Nullable<VertexBuffer>;
  87311. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): void;
  87312. /**
  87313. * Unbind all instance attributes
  87314. */
  87315. unbindInstanceAttributes(): void;
  87316. /**
  87317. * Release and free the memory of a vertex array object
  87318. * @param vao defines the vertex array object to delete
  87319. */
  87320. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  87321. /** @hidden */
  87322. _releaseBuffer(buffer: WebGLBuffer): boolean;
  87323. /**
  87324. * Creates a webGL buffer to use with instanciation
  87325. * @param capacity defines the size of the buffer
  87326. * @returns the webGL buffer
  87327. */
  87328. createInstancesBuffer(capacity: number): WebGLBuffer;
  87329. /**
  87330. * Delete a webGL buffer used with instanciation
  87331. * @param buffer defines the webGL buffer to delete
  87332. */
  87333. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  87334. /**
  87335. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  87336. * @param instancesBuffer defines the webGL buffer to update and bind
  87337. * @param data defines the data to store in the buffer
  87338. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  87339. */
  87340. updateAndBindInstancesBuffer(instancesBuffer: WebGLBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  87341. /**
  87342. * Apply all cached states (depth, culling, stencil and alpha)
  87343. */
  87344. applyStates(): void;
  87345. /**
  87346. * Send a draw order
  87347. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  87348. * @param indexStart defines the starting index
  87349. * @param indexCount defines the number of index to draw
  87350. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  87351. */
  87352. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  87353. /**
  87354. * Draw a list of points
  87355. * @param verticesStart defines the index of first vertex to draw
  87356. * @param verticesCount defines the count of vertices to draw
  87357. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  87358. */
  87359. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  87360. /**
  87361. * Draw a list of unindexed primitives
  87362. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  87363. * @param verticesStart defines the index of first vertex to draw
  87364. * @param verticesCount defines the count of vertices to draw
  87365. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  87366. */
  87367. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  87368. /**
  87369. * Draw a list of indexed primitives
  87370. * @param fillMode defines the primitive to use
  87371. * @param indexStart defines the starting index
  87372. * @param indexCount defines the number of index to draw
  87373. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  87374. */
  87375. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  87376. /**
  87377. * Draw a list of unindexed primitives
  87378. * @param fillMode defines the primitive to use
  87379. * @param verticesStart defines the index of first vertex to draw
  87380. * @param verticesCount defines the count of vertices to draw
  87381. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  87382. */
  87383. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  87384. private _drawMode;
  87385. /** @hidden */
  87386. _releaseEffect(effect: Effect): void;
  87387. /** @hidden */
  87388. _deleteProgram(program: WebGLProgram): void;
  87389. /**
  87390. * Create a new effect (used to store vertex/fragment shaders)
  87391. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  87392. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  87393. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  87394. * @param samplers defines an array of string used to represent textures
  87395. * @param defines defines the string containing the defines to use to compile the shaders
  87396. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  87397. * @param onCompiled defines a function to call when the effect creation is successful
  87398. * @param onError defines a function to call when the effect creation has failed
  87399. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  87400. * @returns the new Effect
  87401. */
  87402. createEffect(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | Engine, samplers?: string[], defines?: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, indexParameters?: any): Effect;
  87403. private _compileShader;
  87404. private _compileRawShader;
  87405. /**
  87406. * Directly creates a webGL program
  87407. * @param vertexCode defines the vertex shader code to use
  87408. * @param fragmentCode defines the fragment shader code to use
  87409. * @param context defines the webGL context to use (if not set, the current one will be used)
  87410. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  87411. * @returns the new webGL program
  87412. */
  87413. createRawShaderProgram(vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  87414. /**
  87415. * Creates a webGL program
  87416. * @param vertexCode defines the vertex shader code to use
  87417. * @param fragmentCode defines the fragment shader code to use
  87418. * @param defines defines the string containing the defines to use to compile the shaders
  87419. * @param context defines the webGL context to use (if not set, the current one will be used)
  87420. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  87421. * @returns the new webGL program
  87422. */
  87423. createShaderProgram(vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  87424. private _createShaderProgram;
  87425. private _finalizeProgram;
  87426. /** @hidden */
  87427. _isProgramCompiled(shaderProgram: WebGLProgram): boolean;
  87428. /** @hidden */
  87429. _executeWhenProgramIsCompiled(shaderProgram: WebGLProgram, action: () => void): void;
  87430. /**
  87431. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  87432. * @param shaderProgram defines the webGL program to use
  87433. * @param uniformsNames defines the list of uniform names
  87434. * @returns an array of webGL uniform locations
  87435. */
  87436. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  87437. /**
  87438. * Gets the lsit of active attributes for a given webGL program
  87439. * @param shaderProgram defines the webGL program to use
  87440. * @param attributesNames defines the list of attribute names to get
  87441. * @returns an array of indices indicating the offset of each attribute
  87442. */
  87443. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  87444. /**
  87445. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  87446. * @param effect defines the effect to activate
  87447. */
  87448. enableEffect(effect: Nullable<Effect>): void;
  87449. /**
  87450. * Set the value of an uniform to an array of int32
  87451. * @param uniform defines the webGL uniform location where to store the value
  87452. * @param array defines the array of int32 to store
  87453. */
  87454. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  87455. /**
  87456. * Set the value of an uniform to an array of int32 (stored as vec2)
  87457. * @param uniform defines the webGL uniform location where to store the value
  87458. * @param array defines the array of int32 to store
  87459. */
  87460. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  87461. /**
  87462. * Set the value of an uniform to an array of int32 (stored as vec3)
  87463. * @param uniform defines the webGL uniform location where to store the value
  87464. * @param array defines the array of int32 to store
  87465. */
  87466. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  87467. /**
  87468. * Set the value of an uniform to an array of int32 (stored as vec4)
  87469. * @param uniform defines the webGL uniform location where to store the value
  87470. * @param array defines the array of int32 to store
  87471. */
  87472. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  87473. /**
  87474. * Set the value of an uniform to an array of float32
  87475. * @param uniform defines the webGL uniform location where to store the value
  87476. * @param array defines the array of float32 to store
  87477. */
  87478. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  87479. /**
  87480. * Set the value of an uniform to an array of float32 (stored as vec2)
  87481. * @param uniform defines the webGL uniform location where to store the value
  87482. * @param array defines the array of float32 to store
  87483. */
  87484. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  87485. /**
  87486. * Set the value of an uniform to an array of float32 (stored as vec3)
  87487. * @param uniform defines the webGL uniform location where to store the value
  87488. * @param array defines the array of float32 to store
  87489. */
  87490. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  87491. /**
  87492. * Set the value of an uniform to an array of float32 (stored as vec4)
  87493. * @param uniform defines the webGL uniform location where to store the value
  87494. * @param array defines the array of float32 to store
  87495. */
  87496. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  87497. /**
  87498. * Set the value of an uniform to an array of number
  87499. * @param uniform defines the webGL uniform location where to store the value
  87500. * @param array defines the array of number to store
  87501. */
  87502. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  87503. /**
  87504. * Set the value of an uniform to an array of number (stored as vec2)
  87505. * @param uniform defines the webGL uniform location where to store the value
  87506. * @param array defines the array of number to store
  87507. */
  87508. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  87509. /**
  87510. * Set the value of an uniform to an array of number (stored as vec3)
  87511. * @param uniform defines the webGL uniform location where to store the value
  87512. * @param array defines the array of number to store
  87513. */
  87514. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  87515. /**
  87516. * Set the value of an uniform to an array of number (stored as vec4)
  87517. * @param uniform defines the webGL uniform location where to store the value
  87518. * @param array defines the array of number to store
  87519. */
  87520. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  87521. /**
  87522. * Set the value of an uniform to an array of float32 (stored as matrices)
  87523. * @param uniform defines the webGL uniform location where to store the value
  87524. * @param matrices defines the array of float32 to store
  87525. */
  87526. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  87527. /**
  87528. * Set the value of an uniform to a matrix
  87529. * @param uniform defines the webGL uniform location where to store the value
  87530. * @param matrix defines the matrix to store
  87531. */
  87532. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  87533. /**
  87534. * Set the value of an uniform to a matrix (3x3)
  87535. * @param uniform defines the webGL uniform location where to store the value
  87536. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  87537. */
  87538. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  87539. /**
  87540. * Set the value of an uniform to a matrix (2x2)
  87541. * @param uniform defines the webGL uniform location where to store the value
  87542. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  87543. */
  87544. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  87545. /**
  87546. * Set the value of an uniform to a number (int)
  87547. * @param uniform defines the webGL uniform location where to store the value
  87548. * @param value defines the int number to store
  87549. */
  87550. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  87551. /**
  87552. * Set the value of an uniform to a number (float)
  87553. * @param uniform defines the webGL uniform location where to store the value
  87554. * @param value defines the float number to store
  87555. */
  87556. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  87557. /**
  87558. * Set the value of an uniform to a vec2
  87559. * @param uniform defines the webGL uniform location where to store the value
  87560. * @param x defines the 1st component of the value
  87561. * @param y defines the 2nd component of the value
  87562. */
  87563. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  87564. /**
  87565. * Set the value of an uniform to a vec3
  87566. * @param uniform defines the webGL uniform location where to store the value
  87567. * @param x defines the 1st component of the value
  87568. * @param y defines the 2nd component of the value
  87569. * @param z defines the 3rd component of the value
  87570. */
  87571. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  87572. /**
  87573. * Set the value of an uniform to a boolean
  87574. * @param uniform defines the webGL uniform location where to store the value
  87575. * @param bool defines the boolean to store
  87576. */
  87577. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  87578. /**
  87579. * Set the value of an uniform to a vec4
  87580. * @param uniform defines the webGL uniform location where to store the value
  87581. * @param x defines the 1st component of the value
  87582. * @param y defines the 2nd component of the value
  87583. * @param z defines the 3rd component of the value
  87584. * @param w defines the 4th component of the value
  87585. */
  87586. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  87587. /**
  87588. * Set the value of an uniform to a Color3
  87589. * @param uniform defines the webGL uniform location where to store the value
  87590. * @param color3 defines the color to store
  87591. */
  87592. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  87593. /**
  87594. * Set the value of an uniform to a Color3 and an alpha value
  87595. * @param uniform defines the webGL uniform location where to store the value
  87596. * @param color3 defines the color to store
  87597. * @param alpha defines the alpha component to store
  87598. */
  87599. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  87600. /**
  87601. * Sets a Color4 on a uniform variable
  87602. * @param uniform defines the uniform location
  87603. * @param color4 defines the value to be set
  87604. */
  87605. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  87606. /**
  87607. * Set various states to the webGL context
  87608. * @param culling defines backface culling state
  87609. * @param zOffset defines the value to apply to zOffset (0 by default)
  87610. * @param force defines if states must be applied even if cache is up to date
  87611. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  87612. */
  87613. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  87614. /**
  87615. * Set the z offset to apply to current rendering
  87616. * @param value defines the offset to apply
  87617. */
  87618. setZOffset(value: number): void;
  87619. /**
  87620. * Gets the current value of the zOffset
  87621. * @returns the current zOffset state
  87622. */
  87623. getZOffset(): number;
  87624. /**
  87625. * Enable or disable depth buffering
  87626. * @param enable defines the state to set
  87627. */
  87628. setDepthBuffer(enable: boolean): void;
  87629. /**
  87630. * Gets a boolean indicating if depth writing is enabled
  87631. * @returns the current depth writing state
  87632. */
  87633. getDepthWrite(): boolean;
  87634. /**
  87635. * Enable or disable depth writing
  87636. * @param enable defines the state to set
  87637. */
  87638. setDepthWrite(enable: boolean): void;
  87639. /**
  87640. * Enable or disable color writing
  87641. * @param enable defines the state to set
  87642. */
  87643. setColorWrite(enable: boolean): void;
  87644. /**
  87645. * Gets a boolean indicating if color writing is enabled
  87646. * @returns the current color writing state
  87647. */
  87648. getColorWrite(): boolean;
  87649. /**
  87650. * Sets alpha constants used by some alpha blending modes
  87651. * @param r defines the red component
  87652. * @param g defines the green component
  87653. * @param b defines the blue component
  87654. * @param a defines the alpha component
  87655. */
  87656. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  87657. /**
  87658. * Sets the current alpha mode
  87659. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  87660. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  87661. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  87662. */
  87663. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  87664. /**
  87665. * Gets the current alpha mode
  87666. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  87667. * @returns the current alpha mode
  87668. */
  87669. getAlphaMode(): number;
  87670. /**
  87671. * Clears the list of texture accessible through engine.
  87672. * This can help preventing texture load conflict due to name collision.
  87673. */
  87674. clearInternalTexturesCache(): void;
  87675. /**
  87676. * Force the entire cache to be cleared
  87677. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  87678. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  87679. */
  87680. wipeCaches(bruteForce?: boolean): void;
  87681. /**
  87682. * Set the compressed texture format to use, based on the formats you have, and the formats
  87683. * supported by the hardware / browser.
  87684. *
  87685. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  87686. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  87687. * to API arguments needed to compressed textures. This puts the burden on the container
  87688. * generator to house the arcane code for determining these for current & future formats.
  87689. *
  87690. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  87691. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  87692. *
  87693. * Note: The result of this call is not taken into account when a texture is base64.
  87694. *
  87695. * @param formatsAvailable defines the list of those format families you have created
  87696. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  87697. *
  87698. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  87699. * @returns The extension selected.
  87700. */
  87701. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  87702. private _getSamplingParameters;
  87703. private _partialLoadImg;
  87704. private _cascadeLoadImgs;
  87705. /** @hidden */
  87706. _createTexture(): WebGLTexture;
  87707. /**
  87708. * Usually called from Texture.ts.
  87709. * Passed information to create a WebGLTexture
  87710. * @param urlArg defines a value which contains one of the following:
  87711. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  87712. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  87713. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  87714. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  87715. * @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)
  87716. * @param scene needed for loading to the correct scene
  87717. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  87718. * @param onLoad optional callback to be called upon successful completion
  87719. * @param onError optional callback to be called upon failure
  87720. * @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
  87721. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  87722. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  87723. * @param forcedExtension defines the extension to use to pick the right loader
  87724. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  87725. * @returns a InternalTexture for assignment back into BABYLON.Texture
  87726. */
  87727. 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;
  87728. private _rescaleTexture;
  87729. /**
  87730. * Update a raw texture
  87731. * @param texture defines the texture to update
  87732. * @param data defines the data to store in the texture
  87733. * @param format defines the format of the data
  87734. * @param invertY defines if data must be stored with Y axis inverted
  87735. * @param compression defines the compression used (null by default)
  87736. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  87737. */
  87738. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, type?: number): void;
  87739. /**
  87740. * Creates a raw texture
  87741. * @param data defines the data to store in the texture
  87742. * @param width defines the width of the texture
  87743. * @param height defines the height of the texture
  87744. * @param format defines the format of the data
  87745. * @param generateMipMaps defines if the engine should generate the mip levels
  87746. * @param invertY defines if data must be stored with Y axis inverted
  87747. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  87748. * @param compression defines the compression used (null by default)
  87749. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  87750. * @returns the raw texture inside an InternalTexture
  87751. */
  87752. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  87753. private _unpackFlipYCached;
  87754. /**
  87755. * In case you are sharing the context with other applications, it might
  87756. * be interested to not cache the unpack flip y state to ensure a consistent
  87757. * value would be set.
  87758. */
  87759. enableUnpackFlipYCached: boolean;
  87760. /** @hidden */
  87761. _unpackFlipY(value: boolean): void;
  87762. /** @hidden */
  87763. _getUnpackAlignement(): number;
  87764. /**
  87765. * Creates a dynamic texture
  87766. * @param width defines the width of the texture
  87767. * @param height defines the height of the texture
  87768. * @param generateMipMaps defines if the engine should generate the mip levels
  87769. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  87770. * @returns the dynamic texture inside an InternalTexture
  87771. */
  87772. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  87773. /**
  87774. * Update the sampling mode of a given texture
  87775. * @param samplingMode defines the required sampling mode
  87776. * @param texture defines the texture to update
  87777. */
  87778. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  87779. /**
  87780. * Update the content of a dynamic texture
  87781. * @param texture defines the texture to update
  87782. * @param canvas defines the canvas containing the source
  87783. * @param invertY defines if data must be stored with Y axis inverted
  87784. * @param premulAlpha defines if alpha is stored as premultiplied
  87785. * @param format defines the format of the data
  87786. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  87787. */
  87788. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  87789. /**
  87790. * Update a video texture
  87791. * @param texture defines the texture to update
  87792. * @param video defines the video element to use
  87793. * @param invertY defines if data must be stored with Y axis inverted
  87794. */
  87795. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  87796. /**
  87797. * Updates a depth texture Comparison Mode and Function.
  87798. * If the comparison Function is equal to 0, the mode will be set to none.
  87799. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  87800. * @param texture The texture to set the comparison function for
  87801. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  87802. */
  87803. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  87804. private _setupDepthStencilTexture;
  87805. /**
  87806. * Creates a depth stencil texture.
  87807. * This is only available in WebGL 2 or with the depth texture extension available.
  87808. * @param size The size of face edge in the texture.
  87809. * @param options The options defining the texture.
  87810. * @returns The texture
  87811. */
  87812. createDepthStencilTexture(size: number | {
  87813. width: number;
  87814. height: number;
  87815. }, options: DepthTextureCreationOptions): InternalTexture;
  87816. /**
  87817. * Creates a depth stencil texture.
  87818. * This is only available in WebGL 2 or with the depth texture extension available.
  87819. * @param size The size of face edge in the texture.
  87820. * @param options The options defining the texture.
  87821. * @returns The texture
  87822. */
  87823. private _createDepthStencilTexture;
  87824. /**
  87825. * Creates a depth stencil cube texture.
  87826. * This is only available in WebGL 2.
  87827. * @param size The size of face edge in the cube texture.
  87828. * @param options The options defining the cube texture.
  87829. * @returns The cube texture
  87830. */
  87831. private _createDepthStencilCubeTexture;
  87832. /**
  87833. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  87834. * @param renderTarget The render target to set the frame buffer for
  87835. */
  87836. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  87837. /**
  87838. * Creates a new render target texture
  87839. * @param size defines the size of the texture
  87840. * @param options defines the options used to create the texture
  87841. * @returns a new render target texture stored in an InternalTexture
  87842. */
  87843. createRenderTargetTexture(size: number | {
  87844. width: number;
  87845. height: number;
  87846. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  87847. /**
  87848. * Create a multi render target texture
  87849. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  87850. * @param size defines the size of the texture
  87851. * @param options defines the creation options
  87852. * @returns the cube texture as an InternalTexture
  87853. */
  87854. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  87855. private _setupFramebufferDepthAttachments;
  87856. /**
  87857. * Updates the sample count of a render target texture
  87858. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  87859. * @param texture defines the texture to update
  87860. * @param samples defines the sample count to set
  87861. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  87862. */
  87863. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  87864. /**
  87865. * Update the sample count for a given multiple render target texture
  87866. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  87867. * @param textures defines the textures to update
  87868. * @param samples defines the sample count to set
  87869. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  87870. */
  87871. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  87872. /** @hidden */
  87873. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  87874. /** @hidden */
  87875. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  87876. /** @hidden */
  87877. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  87878. /** @hidden */
  87879. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  87880. /**
  87881. * Creates a new render target cube texture
  87882. * @param size defines the size of the texture
  87883. * @param options defines the options used to create the texture
  87884. * @returns a new render target cube texture stored in an InternalTexture
  87885. */
  87886. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  87887. /**
  87888. * Creates a cube texture
  87889. * @param rootUrl defines the url where the files to load is located
  87890. * @param scene defines the current scene
  87891. * @param files defines the list of files to load (1 per face)
  87892. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  87893. * @param onLoad defines an optional callback raised when the texture is loaded
  87894. * @param onError defines an optional callback raised if there is an issue to load the texture
  87895. * @param format defines the format of the data
  87896. * @param forcedExtension defines the extension to use to pick the right loader
  87897. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  87898. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  87899. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  87900. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  87901. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  87902. * @returns the cube texture as an InternalTexture
  87903. */
  87904. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap?: boolean, onLoad?: Nullable<(data?: any) => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, forcedExtension?: any, createPolynomials?: boolean, lodScale?: number, lodOffset?: number, fallback?: Nullable<InternalTexture>, excludeLoaders?: Array<IInternalTextureLoader>): InternalTexture;
  87905. /**
  87906. * @hidden
  87907. */
  87908. _setCubeMapTextureParams(loadMipmap: boolean): void;
  87909. /**
  87910. * Update a raw cube texture
  87911. * @param texture defines the texture to udpdate
  87912. * @param data defines the data to store
  87913. * @param format defines the data format
  87914. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  87915. * @param invertY defines if data must be stored with Y axis inverted
  87916. * @param compression defines the compression used (null by default)
  87917. * @param level defines which level of the texture to update
  87918. */
  87919. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  87920. /**
  87921. * Creates a new raw cube texture
  87922. * @param data defines the array of data to use to create each face
  87923. * @param size defines the size of the textures
  87924. * @param format defines the format of the data
  87925. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  87926. * @param generateMipMaps defines if the engine should generate the mip levels
  87927. * @param invertY defines if data must be stored with Y axis inverted
  87928. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  87929. * @param compression defines the compression used (null by default)
  87930. * @returns the cube texture as an InternalTexture
  87931. */
  87932. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  87933. /**
  87934. * Creates a new raw cube texture from a specified url
  87935. * @param url defines the url where the data is located
  87936. * @param scene defines the current scene
  87937. * @param size defines the size of the textures
  87938. * @param format defines the format of the data
  87939. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  87940. * @param noMipmap defines if the engine should avoid generating the mip levels
  87941. * @param callback defines a callback used to extract texture data from loaded data
  87942. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  87943. * @param onLoad defines a callback called when texture is loaded
  87944. * @param onError defines a callback called if there is an error
  87945. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  87946. * @param invertY defines if data must be stored with Y axis inverted
  87947. * @returns the cube texture as an InternalTexture
  87948. */
  87949. 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;
  87950. /**
  87951. * Update a raw 3D texture
  87952. * @param texture defines the texture to update
  87953. * @param data defines the data to store
  87954. * @param format defines the data format
  87955. * @param invertY defines if data must be stored with Y axis inverted
  87956. * @param compression defines the used compression (can be null)
  87957. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  87958. */
  87959. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, textureType?: number): void;
  87960. /**
  87961. * Creates a new raw 3D texture
  87962. * @param data defines the data used to create the texture
  87963. * @param width defines the width of the texture
  87964. * @param height defines the height of the texture
  87965. * @param depth defines the depth of the texture
  87966. * @param format defines the format of the texture
  87967. * @param generateMipMaps defines if the engine must generate mip levels
  87968. * @param invertY defines if data must be stored with Y axis inverted
  87969. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  87970. * @param compression defines the compressed used (can be null)
  87971. * @param textureType defines the compressed used (can be null)
  87972. * @returns a new raw 3D texture (stored in an InternalTexture)
  87973. */
  87974. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  87975. private _prepareWebGLTextureContinuation;
  87976. private _prepareWebGLTexture;
  87977. private _convertRGBtoRGBATextureData;
  87978. /** @hidden */
  87979. _releaseFramebufferObjects(texture: InternalTexture): void;
  87980. /** @hidden */
  87981. _releaseTexture(texture: InternalTexture): void;
  87982. private setProgram;
  87983. private _boundUniforms;
  87984. /**
  87985. * Binds an effect to the webGL context
  87986. * @param effect defines the effect to bind
  87987. */
  87988. bindSamplers(effect: Effect): void;
  87989. private _activateCurrentTexture;
  87990. /** @hidden */
  87991. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  87992. /** @hidden */
  87993. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  87994. /**
  87995. * Sets a texture to the webGL context from a postprocess
  87996. * @param channel defines the channel to use
  87997. * @param postProcess defines the source postprocess
  87998. */
  87999. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  88000. /**
  88001. * Binds the output of the passed in post process to the texture channel specified
  88002. * @param channel The channel the texture should be bound to
  88003. * @param postProcess The post process which's output should be bound
  88004. */
  88005. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  88006. /**
  88007. * Unbind all textures from the webGL context
  88008. */
  88009. unbindAllTextures(): void;
  88010. /**
  88011. * Sets a texture to the according uniform.
  88012. * @param channel The texture channel
  88013. * @param uniform The uniform to set
  88014. * @param texture The texture to apply
  88015. */
  88016. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  88017. /**
  88018. * Sets a depth stencil texture from a render target to the according uniform.
  88019. * @param channel The texture channel
  88020. * @param uniform The uniform to set
  88021. * @param texture The render target texture containing the depth stencil texture to apply
  88022. */
  88023. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  88024. private _bindSamplerUniformToChannel;
  88025. private _getTextureWrapMode;
  88026. private _setTexture;
  88027. /**
  88028. * Sets an array of texture to the webGL context
  88029. * @param channel defines the channel where the texture array must be set
  88030. * @param uniform defines the associated uniform location
  88031. * @param textures defines the array of textures to bind
  88032. */
  88033. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  88034. /** @hidden */
  88035. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  88036. private _setTextureParameterFloat;
  88037. private _setTextureParameterInteger;
  88038. /**
  88039. * Reads pixels from the current frame buffer. Please note that this function can be slow
  88040. * @param x defines the x coordinate of the rectangle where pixels must be read
  88041. * @param y defines the y coordinate of the rectangle where pixels must be read
  88042. * @param width defines the width of the rectangle where pixels must be read
  88043. * @param height defines the height of the rectangle where pixels must be read
  88044. * @returns a Uint8Array containing RGBA colors
  88045. */
  88046. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  88047. /**
  88048. * Add an externaly attached data from its key.
  88049. * This method call will fail and return false, if such key already exists.
  88050. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  88051. * @param key the unique key that identifies the data
  88052. * @param data the data object to associate to the key for this Engine instance
  88053. * @return true if no such key were already present and the data was added successfully, false otherwise
  88054. */
  88055. addExternalData<T>(key: string, data: T): boolean;
  88056. /**
  88057. * Get an externaly attached data from its key
  88058. * @param key the unique key that identifies the data
  88059. * @return the associated data, if present (can be null), or undefined if not present
  88060. */
  88061. getExternalData<T>(key: string): T;
  88062. /**
  88063. * Get an externaly attached data from its key, create it using a factory if it's not already present
  88064. * @param key the unique key that identifies the data
  88065. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  88066. * @return the associated data, can be null if the factory returned null.
  88067. */
  88068. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  88069. /**
  88070. * Remove an externaly attached data from the Engine instance
  88071. * @param key the unique key that identifies the data
  88072. * @return true if the data was successfully removed, false if it doesn't exist
  88073. */
  88074. removeExternalData(key: string): boolean;
  88075. /**
  88076. * Unbind all vertex attributes from the webGL context
  88077. */
  88078. unbindAllAttributes(): void;
  88079. /**
  88080. * 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
  88081. */
  88082. releaseEffects(): void;
  88083. /**
  88084. * Dispose and release all associated resources
  88085. */
  88086. dispose(): void;
  88087. /**
  88088. * Display the loading screen
  88089. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  88090. */
  88091. displayLoadingUI(): void;
  88092. /**
  88093. * Hide the loading screen
  88094. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  88095. */
  88096. hideLoadingUI(): void;
  88097. /**
  88098. * Gets the current loading screen object
  88099. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  88100. */
  88101. /**
  88102. * Sets the current loading screen object
  88103. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  88104. */
  88105. loadingScreen: ILoadingScreen;
  88106. /**
  88107. * Sets the current loading screen text
  88108. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  88109. */
  88110. loadingUIText: string;
  88111. /**
  88112. * Sets the current loading screen background color
  88113. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  88114. */
  88115. loadingUIBackgroundColor: string;
  88116. /**
  88117. * Attach a new callback raised when context lost event is fired
  88118. * @param callback defines the callback to call
  88119. */
  88120. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  88121. /**
  88122. * Attach a new callback raised when context restored event is fired
  88123. * @param callback defines the callback to call
  88124. */
  88125. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  88126. /**
  88127. * Gets the source code of the vertex shader associated with a specific webGL program
  88128. * @param program defines the program to use
  88129. * @returns a string containing the source code of the vertex shader associated with the program
  88130. */
  88131. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  88132. /**
  88133. * Gets the source code of the fragment shader associated with a specific webGL program
  88134. * @param program defines the program to use
  88135. * @returns a string containing the source code of the fragment shader associated with the program
  88136. */
  88137. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  88138. /**
  88139. * Get the current error code of the webGL context
  88140. * @returns the error code
  88141. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  88142. */
  88143. getError(): number;
  88144. /**
  88145. * Gets the current framerate
  88146. * @returns a number representing the framerate
  88147. */
  88148. getFps(): number;
  88149. /**
  88150. * Gets the time spent between current and previous frame
  88151. * @returns a number representing the delta time in ms
  88152. */
  88153. getDeltaTime(): number;
  88154. private _measureFps;
  88155. /** @hidden */
  88156. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  88157. private _canRenderToFloatFramebuffer;
  88158. private _canRenderToHalfFloatFramebuffer;
  88159. private _canRenderToFramebuffer;
  88160. /** @hidden */
  88161. _getWebGLTextureType(type: number): number;
  88162. private _getInternalFormat;
  88163. /** @hidden */
  88164. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  88165. /** @hidden */
  88166. _getRGBAMultiSampleBufferFormat(type: number): number;
  88167. /** @hidden */
  88168. _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;
  88169. /** @hidden */
  88170. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  88171. private _partialLoadFile;
  88172. private _cascadeLoadFiles;
  88173. /**
  88174. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  88175. * @returns true if the engine can be created
  88176. * @ignorenaming
  88177. */
  88178. static isSupported(): boolean;
  88179. }
  88180. }
  88181. declare module BABYLON {
  88182. /**
  88183. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  88184. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  88185. */
  88186. export class EffectFallbacks {
  88187. private _defines;
  88188. private _currentRank;
  88189. private _maxRank;
  88190. private _mesh;
  88191. /**
  88192. * Removes the fallback from the bound mesh.
  88193. */
  88194. unBindMesh(): void;
  88195. /**
  88196. * Adds a fallback on the specified property.
  88197. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  88198. * @param define The name of the define in the shader
  88199. */
  88200. addFallback(rank: number, define: string): void;
  88201. /**
  88202. * Sets the mesh to use CPU skinning when needing to fallback.
  88203. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  88204. * @param mesh The mesh to use the fallbacks.
  88205. */
  88206. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  88207. /**
  88208. * Checks to see if more fallbacks are still availible.
  88209. */
  88210. readonly isMoreFallbacks: boolean;
  88211. /**
  88212. * Removes the defines that shoould be removed when falling back.
  88213. * @param currentDefines defines the current define statements for the shader.
  88214. * @param effect defines the current effect we try to compile
  88215. * @returns The resulting defines with defines of the current rank removed.
  88216. */
  88217. reduce(currentDefines: string, effect: Effect): string;
  88218. }
  88219. /**
  88220. * Options to be used when creating an effect.
  88221. */
  88222. export class EffectCreationOptions {
  88223. /**
  88224. * Atrributes that will be used in the shader.
  88225. */
  88226. attributes: string[];
  88227. /**
  88228. * Uniform varible names that will be set in the shader.
  88229. */
  88230. uniformsNames: string[];
  88231. /**
  88232. * Uniform buffer varible names that will be set in the shader.
  88233. */
  88234. uniformBuffersNames: string[];
  88235. /**
  88236. * Sampler texture variable names that will be set in the shader.
  88237. */
  88238. samplers: string[];
  88239. /**
  88240. * Define statements that will be set in the shader.
  88241. */
  88242. defines: any;
  88243. /**
  88244. * Possible fallbacks for this effect to improve performance when needed.
  88245. */
  88246. fallbacks: Nullable<EffectFallbacks>;
  88247. /**
  88248. * Callback that will be called when the shader is compiled.
  88249. */
  88250. onCompiled: Nullable<(effect: Effect) => void>;
  88251. /**
  88252. * Callback that will be called if an error occurs during shader compilation.
  88253. */
  88254. onError: Nullable<(effect: Effect, errors: string) => void>;
  88255. /**
  88256. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  88257. */
  88258. indexParameters: any;
  88259. /**
  88260. * Max number of lights that can be used in the shader.
  88261. */
  88262. maxSimultaneousLights: number;
  88263. /**
  88264. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  88265. */
  88266. transformFeedbackVaryings: Nullable<string[]>;
  88267. }
  88268. /**
  88269. * Effect containing vertex and fragment shader that can be executed on an object.
  88270. */
  88271. export class Effect {
  88272. /**
  88273. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  88274. */
  88275. static ShadersRepository: string;
  88276. /**
  88277. * Name of the effect.
  88278. */
  88279. name: any;
  88280. /**
  88281. * String container all the define statements that should be set on the shader.
  88282. */
  88283. defines: string;
  88284. /**
  88285. * Callback that will be called when the shader is compiled.
  88286. */
  88287. onCompiled: Nullable<(effect: Effect) => void>;
  88288. /**
  88289. * Callback that will be called if an error occurs during shader compilation.
  88290. */
  88291. onError: Nullable<(effect: Effect, errors: string) => void>;
  88292. /**
  88293. * Callback that will be called when effect is bound.
  88294. */
  88295. onBind: Nullable<(effect: Effect) => void>;
  88296. /**
  88297. * Unique ID of the effect.
  88298. */
  88299. uniqueId: number;
  88300. /**
  88301. * Observable that will be called when the shader is compiled.
  88302. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  88303. */
  88304. onCompileObservable: Observable<Effect>;
  88305. /**
  88306. * Observable that will be called if an error occurs during shader compilation.
  88307. */
  88308. onErrorObservable: Observable<Effect>;
  88309. /** @hidden */
  88310. _onBindObservable: Nullable<Observable<Effect>>;
  88311. /**
  88312. * Observable that will be called when effect is bound.
  88313. */
  88314. readonly onBindObservable: Observable<Effect>;
  88315. /** @hidden */
  88316. _bonesComputationForcedToCPU: boolean;
  88317. private static _uniqueIdSeed;
  88318. private _engine;
  88319. private _uniformBuffersNames;
  88320. private _uniformsNames;
  88321. private _samplers;
  88322. private _isReady;
  88323. private _compilationError;
  88324. private _attributesNames;
  88325. private _attributes;
  88326. private _uniforms;
  88327. /**
  88328. * Key for the effect.
  88329. * @hidden
  88330. */
  88331. _key: string;
  88332. private _indexParameters;
  88333. private _fallbacks;
  88334. private _vertexSourceCode;
  88335. private _fragmentSourceCode;
  88336. private _vertexSourceCodeOverride;
  88337. private _fragmentSourceCodeOverride;
  88338. private _transformFeedbackVaryings;
  88339. /**
  88340. * Compiled shader to webGL program.
  88341. * @hidden
  88342. */
  88343. _program: WebGLProgram;
  88344. private _valueCache;
  88345. private static _baseCache;
  88346. /**
  88347. * Instantiates an effect.
  88348. * An effect can be used to create/manage/execute vertex and fragment shaders.
  88349. * @param baseName Name of the effect.
  88350. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  88351. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  88352. * @param samplers List of sampler variables that will be passed to the shader.
  88353. * @param engine Engine to be used to render the effect
  88354. * @param defines Define statements to be added to the shader.
  88355. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  88356. * @param onCompiled Callback that will be called when the shader is compiled.
  88357. * @param onError Callback that will be called if an error occurs during shader compilation.
  88358. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  88359. */
  88360. 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);
  88361. /**
  88362. * Unique key for this effect
  88363. */
  88364. readonly key: string;
  88365. /**
  88366. * If the effect has been compiled and prepared.
  88367. * @returns if the effect is compiled and prepared.
  88368. */
  88369. isReady(): boolean;
  88370. /**
  88371. * The engine the effect was initialized with.
  88372. * @returns the engine.
  88373. */
  88374. getEngine(): Engine;
  88375. /**
  88376. * The compiled webGL program for the effect
  88377. * @returns the webGL program.
  88378. */
  88379. getProgram(): WebGLProgram;
  88380. /**
  88381. * The set of names of attribute variables for the shader.
  88382. * @returns An array of attribute names.
  88383. */
  88384. getAttributesNames(): string[];
  88385. /**
  88386. * Returns the attribute at the given index.
  88387. * @param index The index of the attribute.
  88388. * @returns The location of the attribute.
  88389. */
  88390. getAttributeLocation(index: number): number;
  88391. /**
  88392. * Returns the attribute based on the name of the variable.
  88393. * @param name of the attribute to look up.
  88394. * @returns the attribute location.
  88395. */
  88396. getAttributeLocationByName(name: string): number;
  88397. /**
  88398. * The number of attributes.
  88399. * @returns the numnber of attributes.
  88400. */
  88401. getAttributesCount(): number;
  88402. /**
  88403. * Gets the index of a uniform variable.
  88404. * @param uniformName of the uniform to look up.
  88405. * @returns the index.
  88406. */
  88407. getUniformIndex(uniformName: string): number;
  88408. /**
  88409. * Returns the attribute based on the name of the variable.
  88410. * @param uniformName of the uniform to look up.
  88411. * @returns the location of the uniform.
  88412. */
  88413. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  88414. /**
  88415. * Returns an array of sampler variable names
  88416. * @returns The array of sampler variable neames.
  88417. */
  88418. getSamplers(): string[];
  88419. /**
  88420. * The error from the last compilation.
  88421. * @returns the error string.
  88422. */
  88423. getCompilationError(): string;
  88424. /**
  88425. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  88426. * @param func The callback to be used.
  88427. */
  88428. executeWhenCompiled(func: (effect: Effect) => void): void;
  88429. private _checkIsReady;
  88430. /** @hidden */
  88431. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  88432. /** @hidden */
  88433. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  88434. /** @hidden */
  88435. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  88436. private _processShaderConversion;
  88437. private _processIncludes;
  88438. private _processPrecision;
  88439. /**
  88440. * Recompiles the webGL program
  88441. * @param vertexSourceCode The source code for the vertex shader.
  88442. * @param fragmentSourceCode The source code for the fragment shader.
  88443. * @param onCompiled Callback called when completed.
  88444. * @param onError Callback called on error.
  88445. * @hidden
  88446. */
  88447. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void): void;
  88448. /**
  88449. * Gets the uniform locations of the the specified variable names
  88450. * @param names THe names of the variables to lookup.
  88451. * @returns Array of locations in the same order as variable names.
  88452. */
  88453. getSpecificUniformLocations(names: string[]): Nullable<WebGLUniformLocation>[];
  88454. /**
  88455. * Prepares the effect
  88456. * @hidden
  88457. */
  88458. _prepareEffect(): void;
  88459. /**
  88460. * Checks if the effect is supported. (Must be called after compilation)
  88461. */
  88462. readonly isSupported: boolean;
  88463. /**
  88464. * Binds a texture to the engine to be used as output of the shader.
  88465. * @param channel Name of the output variable.
  88466. * @param texture Texture to bind.
  88467. * @hidden
  88468. */
  88469. _bindTexture(channel: string, texture: InternalTexture): void;
  88470. /**
  88471. * Sets a texture on the engine to be used in the shader.
  88472. * @param channel Name of the sampler variable.
  88473. * @param texture Texture to set.
  88474. */
  88475. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  88476. /**
  88477. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  88478. * @param channel Name of the sampler variable.
  88479. * @param texture Texture to set.
  88480. */
  88481. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  88482. /**
  88483. * Sets an array of textures on the engine to be used in the shader.
  88484. * @param channel Name of the variable.
  88485. * @param textures Textures to set.
  88486. */
  88487. setTextureArray(channel: string, textures: BaseTexture[]): void;
  88488. /**
  88489. * 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)
  88490. * @param channel Name of the sampler variable.
  88491. * @param postProcess Post process to get the input texture from.
  88492. */
  88493. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  88494. /**
  88495. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  88496. * 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)
  88497. * @param channel Name of the sampler variable.
  88498. * @param postProcess Post process to get the output texture from.
  88499. */
  88500. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  88501. /** @hidden */
  88502. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  88503. /** @hidden */
  88504. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  88505. /** @hidden */
  88506. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  88507. /** @hidden */
  88508. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  88509. /**
  88510. * Binds a buffer to a uniform.
  88511. * @param buffer Buffer to bind.
  88512. * @param name Name of the uniform variable to bind to.
  88513. */
  88514. bindUniformBuffer(buffer: WebGLBuffer, name: string): void;
  88515. /**
  88516. * Binds block to a uniform.
  88517. * @param blockName Name of the block to bind.
  88518. * @param index Index to bind.
  88519. */
  88520. bindUniformBlock(blockName: string, index: number): void;
  88521. /**
  88522. * Sets an interger value on a uniform variable.
  88523. * @param uniformName Name of the variable.
  88524. * @param value Value to be set.
  88525. * @returns this effect.
  88526. */
  88527. setInt(uniformName: string, value: number): Effect;
  88528. /**
  88529. * Sets an int array on a uniform variable.
  88530. * @param uniformName Name of the variable.
  88531. * @param array array to be set.
  88532. * @returns this effect.
  88533. */
  88534. setIntArray(uniformName: string, array: Int32Array): Effect;
  88535. /**
  88536. * 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)
  88537. * @param uniformName Name of the variable.
  88538. * @param array array to be set.
  88539. * @returns this effect.
  88540. */
  88541. setIntArray2(uniformName: string, array: Int32Array): Effect;
  88542. /**
  88543. * 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)
  88544. * @param uniformName Name of the variable.
  88545. * @param array array to be set.
  88546. * @returns this effect.
  88547. */
  88548. setIntArray3(uniformName: string, array: Int32Array): Effect;
  88549. /**
  88550. * 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)
  88551. * @param uniformName Name of the variable.
  88552. * @param array array to be set.
  88553. * @returns this effect.
  88554. */
  88555. setIntArray4(uniformName: string, array: Int32Array): Effect;
  88556. /**
  88557. * Sets an float array on a uniform variable.
  88558. * @param uniformName Name of the variable.
  88559. * @param array array to be set.
  88560. * @returns this effect.
  88561. */
  88562. setFloatArray(uniformName: string, array: Float32Array): Effect;
  88563. /**
  88564. * 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)
  88565. * @param uniformName Name of the variable.
  88566. * @param array array to be set.
  88567. * @returns this effect.
  88568. */
  88569. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  88570. /**
  88571. * 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)
  88572. * @param uniformName Name of the variable.
  88573. * @param array array to be set.
  88574. * @returns this effect.
  88575. */
  88576. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  88577. /**
  88578. * 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)
  88579. * @param uniformName Name of the variable.
  88580. * @param array array to be set.
  88581. * @returns this effect.
  88582. */
  88583. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  88584. /**
  88585. * Sets an array on a uniform variable.
  88586. * @param uniformName Name of the variable.
  88587. * @param array array to be set.
  88588. * @returns this effect.
  88589. */
  88590. setArray(uniformName: string, array: number[]): Effect;
  88591. /**
  88592. * 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)
  88593. * @param uniformName Name of the variable.
  88594. * @param array array to be set.
  88595. * @returns this effect.
  88596. */
  88597. setArray2(uniformName: string, array: number[]): Effect;
  88598. /**
  88599. * 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)
  88600. * @param uniformName Name of the variable.
  88601. * @param array array to be set.
  88602. * @returns this effect.
  88603. */
  88604. setArray3(uniformName: string, array: number[]): Effect;
  88605. /**
  88606. * 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)
  88607. * @param uniformName Name of the variable.
  88608. * @param array array to be set.
  88609. * @returns this effect.
  88610. */
  88611. setArray4(uniformName: string, array: number[]): Effect;
  88612. /**
  88613. * Sets matrices on a uniform variable.
  88614. * @param uniformName Name of the variable.
  88615. * @param matrices matrices to be set.
  88616. * @returns this effect.
  88617. */
  88618. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  88619. /**
  88620. * Sets matrix on a uniform variable.
  88621. * @param uniformName Name of the variable.
  88622. * @param matrix matrix to be set.
  88623. * @returns this effect.
  88624. */
  88625. setMatrix(uniformName: string, matrix: Matrix): Effect;
  88626. /**
  88627. * 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)
  88628. * @param uniformName Name of the variable.
  88629. * @param matrix matrix to be set.
  88630. * @returns this effect.
  88631. */
  88632. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  88633. /**
  88634. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  88635. * @param uniformName Name of the variable.
  88636. * @param matrix matrix to be set.
  88637. * @returns this effect.
  88638. */
  88639. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  88640. /**
  88641. * Sets a float on a uniform variable.
  88642. * @param uniformName Name of the variable.
  88643. * @param value value to be set.
  88644. * @returns this effect.
  88645. */
  88646. setFloat(uniformName: string, value: number): Effect;
  88647. /**
  88648. * Sets a boolean on a uniform variable.
  88649. * @param uniformName Name of the variable.
  88650. * @param bool value to be set.
  88651. * @returns this effect.
  88652. */
  88653. setBool(uniformName: string, bool: boolean): Effect;
  88654. /**
  88655. * Sets a Vector2 on a uniform variable.
  88656. * @param uniformName Name of the variable.
  88657. * @param vector2 vector2 to be set.
  88658. * @returns this effect.
  88659. */
  88660. setVector2(uniformName: string, vector2: Vector2): Effect;
  88661. /**
  88662. * Sets a float2 on a uniform variable.
  88663. * @param uniformName Name of the variable.
  88664. * @param x First float in float2.
  88665. * @param y Second float in float2.
  88666. * @returns this effect.
  88667. */
  88668. setFloat2(uniformName: string, x: number, y: number): Effect;
  88669. /**
  88670. * Sets a Vector3 on a uniform variable.
  88671. * @param uniformName Name of the variable.
  88672. * @param vector3 Value to be set.
  88673. * @returns this effect.
  88674. */
  88675. setVector3(uniformName: string, vector3: Vector3): Effect;
  88676. /**
  88677. * Sets a float3 on a uniform variable.
  88678. * @param uniformName Name of the variable.
  88679. * @param x First float in float3.
  88680. * @param y Second float in float3.
  88681. * @param z Third float in float3.
  88682. * @returns this effect.
  88683. */
  88684. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  88685. /**
  88686. * Sets a Vector4 on a uniform variable.
  88687. * @param uniformName Name of the variable.
  88688. * @param vector4 Value to be set.
  88689. * @returns this effect.
  88690. */
  88691. setVector4(uniformName: string, vector4: Vector4): Effect;
  88692. /**
  88693. * Sets a float4 on a uniform variable.
  88694. * @param uniformName Name of the variable.
  88695. * @param x First float in float4.
  88696. * @param y Second float in float4.
  88697. * @param z Third float in float4.
  88698. * @param w Fourth float in float4.
  88699. * @returns this effect.
  88700. */
  88701. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  88702. /**
  88703. * Sets a Color3 on a uniform variable.
  88704. * @param uniformName Name of the variable.
  88705. * @param color3 Value to be set.
  88706. * @returns this effect.
  88707. */
  88708. setColor3(uniformName: string, color3: Color3): Effect;
  88709. /**
  88710. * Sets a Color4 on a uniform variable.
  88711. * @param uniformName Name of the variable.
  88712. * @param color3 Value to be set.
  88713. * @param alpha Alpha value to be set.
  88714. * @returns this effect.
  88715. */
  88716. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  88717. /**
  88718. * Sets a Color4 on a uniform variable
  88719. * @param uniformName defines the name of the variable
  88720. * @param color4 defines the value to be set
  88721. * @returns this effect.
  88722. */
  88723. setDirectColor4(uniformName: string, color4: Color4): Effect;
  88724. /**
  88725. * This function will add a new shader to the shader store
  88726. * @param name the name of the shader
  88727. * @param pixelShader optional pixel shader content
  88728. * @param vertexShader optional vertex shader content
  88729. */
  88730. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  88731. /**
  88732. * Store of each shader (The can be looked up using effect.key)
  88733. */
  88734. static ShadersStore: {
  88735. [key: string]: string;
  88736. };
  88737. /**
  88738. * Store of each included file for a shader (The can be looked up using effect.key)
  88739. */
  88740. static IncludesShadersStore: {
  88741. [key: string]: string;
  88742. };
  88743. /**
  88744. * Resets the cache of effects.
  88745. */
  88746. static ResetCache(): void;
  88747. }
  88748. }
  88749. declare module BABYLON {
  88750. /**
  88751. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  88752. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  88753. * 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;
  88754. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  88755. */
  88756. export class ColorCurves {
  88757. private _dirty;
  88758. private _tempColor;
  88759. private _globalCurve;
  88760. private _highlightsCurve;
  88761. private _midtonesCurve;
  88762. private _shadowsCurve;
  88763. private _positiveCurve;
  88764. private _negativeCurve;
  88765. private _globalHue;
  88766. private _globalDensity;
  88767. private _globalSaturation;
  88768. private _globalExposure;
  88769. /**
  88770. * Gets the global Hue value.
  88771. * 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).
  88772. */
  88773. /**
  88774. * Sets the global Hue value.
  88775. * 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).
  88776. */
  88777. globalHue: number;
  88778. /**
  88779. * Gets the global Density value.
  88780. * 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.
  88781. * Values less than zero provide a filter of opposite hue.
  88782. */
  88783. /**
  88784. * Sets the global Density value.
  88785. * 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.
  88786. * Values less than zero provide a filter of opposite hue.
  88787. */
  88788. globalDensity: number;
  88789. /**
  88790. * Gets the global Saturation value.
  88791. * 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.
  88792. */
  88793. /**
  88794. * Sets the global Saturation value.
  88795. * 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.
  88796. */
  88797. globalSaturation: number;
  88798. /**
  88799. * Gets the global Exposure value.
  88800. * 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.
  88801. */
  88802. /**
  88803. * Sets the global Exposure value.
  88804. * 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.
  88805. */
  88806. globalExposure: number;
  88807. private _highlightsHue;
  88808. private _highlightsDensity;
  88809. private _highlightsSaturation;
  88810. private _highlightsExposure;
  88811. /**
  88812. * Gets the highlights Hue value.
  88813. * 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).
  88814. */
  88815. /**
  88816. * Sets the highlights Hue value.
  88817. * 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).
  88818. */
  88819. highlightsHue: number;
  88820. /**
  88821. * Gets the highlights Density value.
  88822. * 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.
  88823. * Values less than zero provide a filter of opposite hue.
  88824. */
  88825. /**
  88826. * Sets the highlights Density value.
  88827. * 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.
  88828. * Values less than zero provide a filter of opposite hue.
  88829. */
  88830. highlightsDensity: number;
  88831. /**
  88832. * Gets the highlights Saturation value.
  88833. * 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.
  88834. */
  88835. /**
  88836. * Sets the highlights Saturation value.
  88837. * 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.
  88838. */
  88839. highlightsSaturation: number;
  88840. /**
  88841. * Gets the highlights Exposure value.
  88842. * 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.
  88843. */
  88844. /**
  88845. * Sets the highlights Exposure value.
  88846. * 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.
  88847. */
  88848. highlightsExposure: number;
  88849. private _midtonesHue;
  88850. private _midtonesDensity;
  88851. private _midtonesSaturation;
  88852. private _midtonesExposure;
  88853. /**
  88854. * Gets the midtones Hue value.
  88855. * 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).
  88856. */
  88857. /**
  88858. * Sets the midtones Hue value.
  88859. * 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).
  88860. */
  88861. midtonesHue: number;
  88862. /**
  88863. * Gets the midtones Density value.
  88864. * 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.
  88865. * Values less than zero provide a filter of opposite hue.
  88866. */
  88867. /**
  88868. * Sets the midtones Density value.
  88869. * 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.
  88870. * Values less than zero provide a filter of opposite hue.
  88871. */
  88872. midtonesDensity: number;
  88873. /**
  88874. * Gets the midtones Saturation value.
  88875. * 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.
  88876. */
  88877. /**
  88878. * Sets the midtones Saturation value.
  88879. * 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.
  88880. */
  88881. midtonesSaturation: number;
  88882. /**
  88883. * Gets the midtones Exposure value.
  88884. * 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.
  88885. */
  88886. /**
  88887. * Sets the midtones Exposure value.
  88888. * 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.
  88889. */
  88890. midtonesExposure: number;
  88891. private _shadowsHue;
  88892. private _shadowsDensity;
  88893. private _shadowsSaturation;
  88894. private _shadowsExposure;
  88895. /**
  88896. * Gets the shadows Hue value.
  88897. * 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).
  88898. */
  88899. /**
  88900. * Sets the shadows Hue value.
  88901. * 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).
  88902. */
  88903. shadowsHue: number;
  88904. /**
  88905. * Gets the shadows Density value.
  88906. * 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.
  88907. * Values less than zero provide a filter of opposite hue.
  88908. */
  88909. /**
  88910. * Sets the shadows Density value.
  88911. * 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.
  88912. * Values less than zero provide a filter of opposite hue.
  88913. */
  88914. shadowsDensity: number;
  88915. /**
  88916. * Gets the shadows Saturation value.
  88917. * 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.
  88918. */
  88919. /**
  88920. * Sets the shadows Saturation value.
  88921. * 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.
  88922. */
  88923. shadowsSaturation: number;
  88924. /**
  88925. * Gets the shadows Exposure value.
  88926. * 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.
  88927. */
  88928. /**
  88929. * Sets the shadows Exposure value.
  88930. * 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.
  88931. */
  88932. shadowsExposure: number;
  88933. /**
  88934. * Returns the class name
  88935. * @returns The class name
  88936. */
  88937. getClassName(): string;
  88938. /**
  88939. * Binds the color curves to the shader.
  88940. * @param colorCurves The color curve to bind
  88941. * @param effect The effect to bind to
  88942. * @param positiveUniform The positive uniform shader parameter
  88943. * @param neutralUniform The neutral uniform shader parameter
  88944. * @param negativeUniform The negative uniform shader parameter
  88945. */
  88946. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  88947. /**
  88948. * Prepare the list of uniforms associated with the ColorCurves effects.
  88949. * @param uniformsList The list of uniforms used in the effect
  88950. */
  88951. static PrepareUniforms(uniformsList: string[]): void;
  88952. /**
  88953. * Returns color grading data based on a hue, density, saturation and exposure value.
  88954. * @param filterHue The hue of the color filter.
  88955. * @param filterDensity The density of the color filter.
  88956. * @param saturation The saturation.
  88957. * @param exposure The exposure.
  88958. * @param result The result data container.
  88959. */
  88960. private getColorGradingDataToRef;
  88961. /**
  88962. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  88963. * @param value The input slider value in range [-100,100].
  88964. * @returns Adjusted value.
  88965. */
  88966. private static applyColorGradingSliderNonlinear;
  88967. /**
  88968. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  88969. * @param hue The hue (H) input.
  88970. * @param saturation The saturation (S) input.
  88971. * @param brightness The brightness (B) input.
  88972. * @result An RGBA color represented as Vector4.
  88973. */
  88974. private static fromHSBToRef;
  88975. /**
  88976. * Returns a value clamped between min and max
  88977. * @param value The value to clamp
  88978. * @param min The minimum of value
  88979. * @param max The maximum of value
  88980. * @returns The clamped value.
  88981. */
  88982. private static clamp;
  88983. /**
  88984. * Clones the current color curve instance.
  88985. * @return The cloned curves
  88986. */
  88987. clone(): ColorCurves;
  88988. /**
  88989. * Serializes the current color curve instance to a json representation.
  88990. * @return a JSON representation
  88991. */
  88992. serialize(): any;
  88993. /**
  88994. * Parses the color curve from a json representation.
  88995. * @param source the JSON source to parse
  88996. * @return The parsed curves
  88997. */
  88998. static Parse(source: any): ColorCurves;
  88999. }
  89000. }
  89001. declare module BABYLON {
  89002. /**
  89003. * Interface to follow in your material defines to integrate easily the
  89004. * Image proccessing functions.
  89005. * @hidden
  89006. */
  89007. export interface IImageProcessingConfigurationDefines {
  89008. IMAGEPROCESSING: boolean;
  89009. VIGNETTE: boolean;
  89010. VIGNETTEBLENDMODEMULTIPLY: boolean;
  89011. VIGNETTEBLENDMODEOPAQUE: boolean;
  89012. TONEMAPPING: boolean;
  89013. TONEMAPPING_ACES: boolean;
  89014. CONTRAST: boolean;
  89015. EXPOSURE: boolean;
  89016. COLORCURVES: boolean;
  89017. COLORGRADING: boolean;
  89018. COLORGRADING3D: boolean;
  89019. SAMPLER3DGREENDEPTH: boolean;
  89020. SAMPLER3DBGRMAP: boolean;
  89021. IMAGEPROCESSINGPOSTPROCESS: boolean;
  89022. }
  89023. /**
  89024. * @hidden
  89025. */
  89026. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  89027. IMAGEPROCESSING: boolean;
  89028. VIGNETTE: boolean;
  89029. VIGNETTEBLENDMODEMULTIPLY: boolean;
  89030. VIGNETTEBLENDMODEOPAQUE: boolean;
  89031. TONEMAPPING: boolean;
  89032. TONEMAPPING_ACES: boolean;
  89033. CONTRAST: boolean;
  89034. COLORCURVES: boolean;
  89035. COLORGRADING: boolean;
  89036. COLORGRADING3D: boolean;
  89037. SAMPLER3DGREENDEPTH: boolean;
  89038. SAMPLER3DBGRMAP: boolean;
  89039. IMAGEPROCESSINGPOSTPROCESS: boolean;
  89040. EXPOSURE: boolean;
  89041. constructor();
  89042. }
  89043. /**
  89044. * This groups together the common properties used for image processing either in direct forward pass
  89045. * or through post processing effect depending on the use of the image processing pipeline in your scene
  89046. * or not.
  89047. */
  89048. export class ImageProcessingConfiguration {
  89049. /**
  89050. * Default tone mapping applied in BabylonJS.
  89051. */
  89052. static readonly TONEMAPPING_STANDARD: number;
  89053. /**
  89054. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  89055. * to other engines rendering to increase portability.
  89056. */
  89057. static readonly TONEMAPPING_ACES: number;
  89058. /**
  89059. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  89060. */
  89061. colorCurves: Nullable<ColorCurves>;
  89062. private _colorCurvesEnabled;
  89063. /**
  89064. * Gets wether the color curves effect is enabled.
  89065. */
  89066. /**
  89067. * Sets wether the color curves effect is enabled.
  89068. */
  89069. colorCurvesEnabled: boolean;
  89070. private _colorGradingTexture;
  89071. /**
  89072. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  89073. */
  89074. /**
  89075. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  89076. */
  89077. colorGradingTexture: Nullable<BaseTexture>;
  89078. private _colorGradingEnabled;
  89079. /**
  89080. * Gets wether the color grading effect is enabled.
  89081. */
  89082. /**
  89083. * Sets wether the color grading effect is enabled.
  89084. */
  89085. colorGradingEnabled: boolean;
  89086. private _colorGradingWithGreenDepth;
  89087. /**
  89088. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  89089. */
  89090. /**
  89091. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  89092. */
  89093. colorGradingWithGreenDepth: boolean;
  89094. private _colorGradingBGR;
  89095. /**
  89096. * Gets wether the color grading texture contains BGR values.
  89097. */
  89098. /**
  89099. * Sets wether the color grading texture contains BGR values.
  89100. */
  89101. colorGradingBGR: boolean;
  89102. /** @hidden */
  89103. _exposure: number;
  89104. /**
  89105. * Gets the Exposure used in the effect.
  89106. */
  89107. /**
  89108. * Sets the Exposure used in the effect.
  89109. */
  89110. exposure: number;
  89111. private _toneMappingEnabled;
  89112. /**
  89113. * Gets wether the tone mapping effect is enabled.
  89114. */
  89115. /**
  89116. * Sets wether the tone mapping effect is enabled.
  89117. */
  89118. toneMappingEnabled: boolean;
  89119. private _toneMappingType;
  89120. /**
  89121. * Gets the type of tone mapping effect.
  89122. */
  89123. /**
  89124. * Sets the type of tone mapping effect used in BabylonJS.
  89125. */
  89126. toneMappingType: number;
  89127. protected _contrast: number;
  89128. /**
  89129. * Gets the contrast used in the effect.
  89130. */
  89131. /**
  89132. * Sets the contrast used in the effect.
  89133. */
  89134. contrast: number;
  89135. /**
  89136. * Vignette stretch size.
  89137. */
  89138. vignetteStretch: number;
  89139. /**
  89140. * Vignette centre X Offset.
  89141. */
  89142. vignetteCentreX: number;
  89143. /**
  89144. * Vignette centre Y Offset.
  89145. */
  89146. vignetteCentreY: number;
  89147. /**
  89148. * Vignette weight or intensity of the vignette effect.
  89149. */
  89150. vignetteWeight: number;
  89151. /**
  89152. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  89153. * if vignetteEnabled is set to true.
  89154. */
  89155. vignetteColor: Color4;
  89156. /**
  89157. * Camera field of view used by the Vignette effect.
  89158. */
  89159. vignetteCameraFov: number;
  89160. private _vignetteBlendMode;
  89161. /**
  89162. * Gets the vignette blend mode allowing different kind of effect.
  89163. */
  89164. /**
  89165. * Sets the vignette blend mode allowing different kind of effect.
  89166. */
  89167. vignetteBlendMode: number;
  89168. private _vignetteEnabled;
  89169. /**
  89170. * Gets wether the vignette effect is enabled.
  89171. */
  89172. /**
  89173. * Sets wether the vignette effect is enabled.
  89174. */
  89175. vignetteEnabled: boolean;
  89176. private _applyByPostProcess;
  89177. /**
  89178. * Gets wether the image processing is applied through a post process or not.
  89179. */
  89180. /**
  89181. * Sets wether the image processing is applied through a post process or not.
  89182. */
  89183. applyByPostProcess: boolean;
  89184. private _isEnabled;
  89185. /**
  89186. * Gets wether the image processing is enabled or not.
  89187. */
  89188. /**
  89189. * Sets wether the image processing is enabled or not.
  89190. */
  89191. isEnabled: boolean;
  89192. /**
  89193. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  89194. */
  89195. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  89196. /**
  89197. * Method called each time the image processing information changes requires to recompile the effect.
  89198. */
  89199. protected _updateParameters(): void;
  89200. /**
  89201. * Gets the current class name.
  89202. * @return "ImageProcessingConfiguration"
  89203. */
  89204. getClassName(): string;
  89205. /**
  89206. * Prepare the list of uniforms associated with the Image Processing effects.
  89207. * @param uniforms The list of uniforms used in the effect
  89208. * @param defines the list of defines currently in use
  89209. */
  89210. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  89211. /**
  89212. * Prepare the list of samplers associated with the Image Processing effects.
  89213. * @param samplersList The list of uniforms used in the effect
  89214. * @param defines the list of defines currently in use
  89215. */
  89216. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  89217. /**
  89218. * Prepare the list of defines associated to the shader.
  89219. * @param defines the list of defines to complete
  89220. * @param forPostProcess Define if we are currently in post process mode or not
  89221. */
  89222. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  89223. /**
  89224. * Returns true if all the image processing information are ready.
  89225. * @returns True if ready, otherwise, false
  89226. */
  89227. isReady(): boolean;
  89228. /**
  89229. * Binds the image processing to the shader.
  89230. * @param effect The effect to bind to
  89231. * @param aspectRatio Define the current aspect ratio of the effect
  89232. */
  89233. bind(effect: Effect, aspectRatio?: number): void;
  89234. /**
  89235. * Clones the current image processing instance.
  89236. * @return The cloned image processing
  89237. */
  89238. clone(): ImageProcessingConfiguration;
  89239. /**
  89240. * Serializes the current image processing instance to a json representation.
  89241. * @return a JSON representation
  89242. */
  89243. serialize(): any;
  89244. /**
  89245. * Parses the image processing from a json representation.
  89246. * @param source the JSON source to parse
  89247. * @return The parsed image processing
  89248. */
  89249. static Parse(source: any): ImageProcessingConfiguration;
  89250. private static _VIGNETTEMODE_MULTIPLY;
  89251. private static _VIGNETTEMODE_OPAQUE;
  89252. /**
  89253. * Used to apply the vignette as a mix with the pixel color.
  89254. */
  89255. static readonly VIGNETTEMODE_MULTIPLY: number;
  89256. /**
  89257. * Used to apply the vignette as a replacement of the pixel color.
  89258. */
  89259. static readonly VIGNETTEMODE_OPAQUE: number;
  89260. }
  89261. }
  89262. declare module BABYLON {
  89263. /**
  89264. * This represents all the required information to add a fresnel effect on a material:
  89265. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  89266. */
  89267. export class FresnelParameters {
  89268. private _isEnabled;
  89269. /**
  89270. * Define if the fresnel effect is enable or not.
  89271. */
  89272. isEnabled: boolean;
  89273. /**
  89274. * Define the color used on edges (grazing angle)
  89275. */
  89276. leftColor: Color3;
  89277. /**
  89278. * Define the color used on center
  89279. */
  89280. rightColor: Color3;
  89281. /**
  89282. * Define bias applied to computed fresnel term
  89283. */
  89284. bias: number;
  89285. /**
  89286. * Defined the power exponent applied to fresnel term
  89287. */
  89288. power: number;
  89289. /**
  89290. * Clones the current fresnel and its valuues
  89291. * @returns a clone fresnel configuration
  89292. */
  89293. clone(): FresnelParameters;
  89294. /**
  89295. * Serializes the current fresnel parameters to a JSON representation.
  89296. * @return the JSON serialization
  89297. */
  89298. serialize(): any;
  89299. /**
  89300. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  89301. * @param parsedFresnelParameters Define the JSON representation
  89302. * @returns the parsed parameters
  89303. */
  89304. static Parse(parsedFresnelParameters: any): FresnelParameters;
  89305. }
  89306. }
  89307. declare module BABYLON {
  89308. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  89309. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  89310. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  89311. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  89312. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  89313. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  89314. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  89315. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  89316. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  89317. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  89318. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  89319. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  89320. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  89321. /**
  89322. * Decorator used to define property that can be serialized as reference to a camera
  89323. * @param sourceName defines the name of the property to decorate
  89324. */
  89325. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  89326. /**
  89327. * Class used to help serialization objects
  89328. */
  89329. export class SerializationHelper {
  89330. /** hidden */
  89331. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  89332. /** hidden */
  89333. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  89334. /** hidden */
  89335. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  89336. /** hidden */
  89337. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  89338. /**
  89339. * Appends the serialized animations from the source animations
  89340. * @param source Source containing the animations
  89341. * @param destination Target to store the animations
  89342. */
  89343. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  89344. /**
  89345. * Static function used to serialized a specific entity
  89346. * @param entity defines the entity to serialize
  89347. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  89348. * @returns a JSON compatible object representing the serialization of the entity
  89349. */
  89350. static Serialize<T>(entity: T, serializationObject?: any): any;
  89351. /**
  89352. * Creates a new entity from a serialization data object
  89353. * @param creationFunction defines a function used to instanciated the new entity
  89354. * @param source defines the source serialization data
  89355. * @param scene defines the hosting scene
  89356. * @param rootUrl defines the root url for resources
  89357. * @returns a new entity
  89358. */
  89359. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  89360. /**
  89361. * Clones an object
  89362. * @param creationFunction defines the function used to instanciate the new object
  89363. * @param source defines the source object
  89364. * @returns the cloned object
  89365. */
  89366. static Clone<T>(creationFunction: () => T, source: T): T;
  89367. /**
  89368. * Instanciates a new object based on a source one (some data will be shared between both object)
  89369. * @param creationFunction defines the function used to instanciate the new object
  89370. * @param source defines the source object
  89371. * @returns the new object
  89372. */
  89373. static Instanciate<T>(creationFunction: () => T, source: T): T;
  89374. }
  89375. }
  89376. declare module BABYLON {
  89377. /**
  89378. * This is the base class of all the camera used in the application.
  89379. * @see http://doc.babylonjs.com/features/cameras
  89380. */
  89381. export class Camera extends Node {
  89382. /** @hidden */
  89383. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  89384. /**
  89385. * This is the default projection mode used by the cameras.
  89386. * It helps recreating a feeling of perspective and better appreciate depth.
  89387. * This is the best way to simulate real life cameras.
  89388. */
  89389. static readonly PERSPECTIVE_CAMERA: number;
  89390. /**
  89391. * This helps creating camera with an orthographic mode.
  89392. * 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.
  89393. */
  89394. static readonly ORTHOGRAPHIC_CAMERA: number;
  89395. /**
  89396. * This is the default FOV mode for perspective cameras.
  89397. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  89398. */
  89399. static readonly FOVMODE_VERTICAL_FIXED: number;
  89400. /**
  89401. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  89402. */
  89403. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  89404. /**
  89405. * This specifies ther is no need for a camera rig.
  89406. * Basically only one eye is rendered corresponding to the camera.
  89407. */
  89408. static readonly RIG_MODE_NONE: number;
  89409. /**
  89410. * Simulates a camera Rig with one blue eye and one red eye.
  89411. * This can be use with 3d blue and red glasses.
  89412. */
  89413. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  89414. /**
  89415. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  89416. */
  89417. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  89418. /**
  89419. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  89420. */
  89421. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  89422. /**
  89423. * Defines that both eyes of the camera will be rendered over under each other.
  89424. */
  89425. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  89426. /**
  89427. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  89428. */
  89429. static readonly RIG_MODE_VR: number;
  89430. /**
  89431. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  89432. */
  89433. static readonly RIG_MODE_WEBVR: number;
  89434. /**
  89435. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  89436. */
  89437. static readonly RIG_MODE_CUSTOM: number;
  89438. /**
  89439. * Defines if by default attaching controls should prevent the default javascript event to continue.
  89440. */
  89441. static ForceAttachControlToAlwaysPreventDefault: boolean;
  89442. /**
  89443. * Define the input manager associated with the camera.
  89444. */
  89445. inputs: CameraInputsManager<Camera>;
  89446. /** @hidden */
  89447. _position: Vector3;
  89448. /**
  89449. * Define the current local position of the camera in the scene
  89450. */
  89451. position: Vector3;
  89452. /**
  89453. * The vector the camera should consider as up.
  89454. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  89455. */
  89456. upVector: Vector3;
  89457. /**
  89458. * Define the current limit on the left side for an orthographic camera
  89459. * In scene unit
  89460. */
  89461. orthoLeft: Nullable<number>;
  89462. /**
  89463. * Define the current limit on the right side for an orthographic camera
  89464. * In scene unit
  89465. */
  89466. orthoRight: Nullable<number>;
  89467. /**
  89468. * Define the current limit on the bottom side for an orthographic camera
  89469. * In scene unit
  89470. */
  89471. orthoBottom: Nullable<number>;
  89472. /**
  89473. * Define the current limit on the top side for an orthographic camera
  89474. * In scene unit
  89475. */
  89476. orthoTop: Nullable<number>;
  89477. /**
  89478. * Field Of View is set in Radians. (default is 0.8)
  89479. */
  89480. fov: number;
  89481. /**
  89482. * Define the minimum distance the camera can see from.
  89483. * This is important to note that the depth buffer are not infinite and the closer it starts
  89484. * the more your scene might encounter depth fighting issue.
  89485. */
  89486. minZ: number;
  89487. /**
  89488. * Define the maximum distance the camera can see to.
  89489. * This is important to note that the depth buffer are not infinite and the further it end
  89490. * the more your scene might encounter depth fighting issue.
  89491. */
  89492. maxZ: number;
  89493. /**
  89494. * Define the default inertia of the camera.
  89495. * This helps giving a smooth feeling to the camera movement.
  89496. */
  89497. inertia: number;
  89498. /**
  89499. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.PERSPECTIVE_ORTHOGRAPHIC)
  89500. */
  89501. mode: number;
  89502. /**
  89503. * Define wether the camera is intermediate.
  89504. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  89505. */
  89506. isIntermediate: boolean;
  89507. /**
  89508. * Define the viewport of the camera.
  89509. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  89510. */
  89511. viewport: Viewport;
  89512. /**
  89513. * Restricts the camera to viewing objects with the same layerMask.
  89514. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  89515. */
  89516. layerMask: number;
  89517. /**
  89518. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  89519. */
  89520. fovMode: number;
  89521. /**
  89522. * Rig mode of the camera.
  89523. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  89524. * This is normally controlled byt the camera themselves as internal use.
  89525. */
  89526. cameraRigMode: number;
  89527. /**
  89528. * Defines the distance between both "eyes" in case of a RIG
  89529. */
  89530. interaxialDistance: number;
  89531. /**
  89532. * Defines if stereoscopic rendering is done side by side or over under.
  89533. */
  89534. isStereoscopicSideBySide: boolean;
  89535. /**
  89536. * 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
  89537. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  89538. * else in the scene.
  89539. */
  89540. customRenderTargets: RenderTargetTexture[];
  89541. /**
  89542. * When set, the camera will render to this render target instead of the default canvas
  89543. */
  89544. outputRenderTarget: Nullable<RenderTargetTexture>;
  89545. /**
  89546. * Observable triggered when the camera view matrix has changed.
  89547. */
  89548. onViewMatrixChangedObservable: Observable<Camera>;
  89549. /**
  89550. * Observable triggered when the camera Projection matrix has changed.
  89551. */
  89552. onProjectionMatrixChangedObservable: Observable<Camera>;
  89553. /**
  89554. * Observable triggered when the inputs have been processed.
  89555. */
  89556. onAfterCheckInputsObservable: Observable<Camera>;
  89557. /**
  89558. * Observable triggered when reset has been called and applied to the camera.
  89559. */
  89560. onRestoreStateObservable: Observable<Camera>;
  89561. /** @hidden */
  89562. _cameraRigParams: any;
  89563. /** @hidden */
  89564. _rigCameras: Camera[];
  89565. /** @hidden */
  89566. _rigPostProcess: Nullable<PostProcess>;
  89567. protected _webvrViewMatrix: Matrix;
  89568. /** @hidden */
  89569. _skipRendering: boolean;
  89570. /** @hidden */
  89571. _projectionMatrix: Matrix;
  89572. /** @hidden */
  89573. _postProcesses: Nullable<PostProcess>[];
  89574. /** @hidden */
  89575. _activeMeshes: SmartArray<AbstractMesh>;
  89576. protected _globalPosition: Vector3;
  89577. /** hidden */
  89578. _computedViewMatrix: Matrix;
  89579. private _doNotComputeProjectionMatrix;
  89580. private _transformMatrix;
  89581. private _frustumPlanes;
  89582. private _refreshFrustumPlanes;
  89583. private _storedFov;
  89584. private _stateStored;
  89585. /**
  89586. * Instantiates a new camera object.
  89587. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  89588. * @see http://doc.babylonjs.com/features/cameras
  89589. * @param name Defines the name of the camera in the scene
  89590. * @param position Defines the position of the camera
  89591. * @param scene Defines the scene the camera belongs too
  89592. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  89593. */
  89594. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  89595. /**
  89596. * Store current camera state (fov, position, etc..)
  89597. * @returns the camera
  89598. */
  89599. storeState(): Camera;
  89600. /**
  89601. * Restores the camera state values if it has been stored. You must call storeState() first
  89602. */
  89603. protected _restoreStateValues(): boolean;
  89604. /**
  89605. * Restored camera state. You must call storeState() first.
  89606. * @returns true if restored and false otherwise
  89607. */
  89608. restoreState(): boolean;
  89609. /**
  89610. * Gets the class name of the camera.
  89611. * @returns the class name
  89612. */
  89613. getClassName(): string;
  89614. /** @hidden */
  89615. readonly _isCamera: boolean;
  89616. /**
  89617. * Gets a string representation of the camera useful for debug purpose.
  89618. * @param fullDetails Defines that a more verboe level of logging is required
  89619. * @returns the string representation
  89620. */
  89621. toString(fullDetails?: boolean): string;
  89622. /**
  89623. * Gets the current world space position of the camera.
  89624. */
  89625. readonly globalPosition: Vector3;
  89626. /**
  89627. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  89628. * @returns the active meshe list
  89629. */
  89630. getActiveMeshes(): SmartArray<AbstractMesh>;
  89631. /**
  89632. * Check wether a mesh is part of the current active mesh list of the camera
  89633. * @param mesh Defines the mesh to check
  89634. * @returns true if active, false otherwise
  89635. */
  89636. isActiveMesh(mesh: Mesh): boolean;
  89637. /**
  89638. * Is this camera ready to be used/rendered
  89639. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  89640. * @return true if the camera is ready
  89641. */
  89642. isReady(completeCheck?: boolean): boolean;
  89643. /** @hidden */
  89644. _initCache(): void;
  89645. /** @hidden */
  89646. _updateCache(ignoreParentClass?: boolean): void;
  89647. /** @hidden */
  89648. _isSynchronized(): boolean;
  89649. /** @hidden */
  89650. _isSynchronizedViewMatrix(): boolean;
  89651. /** @hidden */
  89652. _isSynchronizedProjectionMatrix(): boolean;
  89653. /**
  89654. * Attach the input controls to a specific dom element to get the input from.
  89655. * @param element Defines the element the controls should be listened from
  89656. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  89657. */
  89658. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  89659. /**
  89660. * Detach the current controls from the specified dom element.
  89661. * @param element Defines the element to stop listening the inputs from
  89662. */
  89663. detachControl(element: HTMLElement): void;
  89664. /**
  89665. * Update the camera state according to the different inputs gathered during the frame.
  89666. */
  89667. update(): void;
  89668. /** @hidden */
  89669. _checkInputs(): void;
  89670. /** @hidden */
  89671. readonly rigCameras: Camera[];
  89672. /**
  89673. * Gets the post process used by the rig cameras
  89674. */
  89675. readonly rigPostProcess: Nullable<PostProcess>;
  89676. /**
  89677. * Internal, gets the first post proces.
  89678. * @returns the first post process to be run on this camera.
  89679. */
  89680. _getFirstPostProcess(): Nullable<PostProcess>;
  89681. private _cascadePostProcessesToRigCams;
  89682. /**
  89683. * Attach a post process to the camera.
  89684. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  89685. * @param postProcess The post process to attach to the camera
  89686. * @param insertAt The position of the post process in case several of them are in use in the scene
  89687. * @returns the position the post process has been inserted at
  89688. */
  89689. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  89690. /**
  89691. * Detach a post process to the camera.
  89692. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  89693. * @param postProcess The post process to detach from the camera
  89694. */
  89695. detachPostProcess(postProcess: PostProcess): void;
  89696. /**
  89697. * Gets the current world matrix of the camera
  89698. */
  89699. getWorldMatrix(): Matrix;
  89700. /** @hidden */
  89701. _getViewMatrix(): Matrix;
  89702. /**
  89703. * Gets the current view matrix of the camera.
  89704. * @param force forces the camera to recompute the matrix without looking at the cached state
  89705. * @returns the view matrix
  89706. */
  89707. getViewMatrix(force?: boolean): Matrix;
  89708. /**
  89709. * Freeze the projection matrix.
  89710. * It will prevent the cache check of the camera projection compute and can speed up perf
  89711. * if no parameter of the camera are meant to change
  89712. * @param projection Defines manually a projection if necessary
  89713. */
  89714. freezeProjectionMatrix(projection?: Matrix): void;
  89715. /**
  89716. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  89717. */
  89718. unfreezeProjectionMatrix(): void;
  89719. /**
  89720. * Gets the current projection matrix of the camera.
  89721. * @param force forces the camera to recompute the matrix without looking at the cached state
  89722. * @returns the projection matrix
  89723. */
  89724. getProjectionMatrix(force?: boolean): Matrix;
  89725. /**
  89726. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  89727. * @returns a Matrix
  89728. */
  89729. getTransformationMatrix(): Matrix;
  89730. private _updateFrustumPlanes;
  89731. /**
  89732. * Checks if a cullable object (mesh...) is in the camera frustum
  89733. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  89734. * @param target The object to check
  89735. * @returns true if the object is in frustum otherwise false
  89736. */
  89737. isInFrustum(target: ICullable): boolean;
  89738. /**
  89739. * Checks if a cullable object (mesh...) is in the camera frustum
  89740. * Unlike isInFrustum this cheks the full bounding box
  89741. * @param target The object to check
  89742. * @returns true if the object is in frustum otherwise false
  89743. */
  89744. isCompletelyInFrustum(target: ICullable): boolean;
  89745. /**
  89746. * Gets a ray in the forward direction from the camera.
  89747. * @param length Defines the length of the ray to create
  89748. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  89749. * @param origin Defines the start point of the ray which defaults to the camera position
  89750. * @returns the forward ray
  89751. */
  89752. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  89753. /**
  89754. * Releases resources associated with this node.
  89755. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  89756. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  89757. */
  89758. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  89759. /** @hidden */
  89760. _isLeftCamera: boolean;
  89761. /**
  89762. * Gets the left camera of a rig setup in case of Rigged Camera
  89763. */
  89764. readonly isLeftCamera: boolean;
  89765. /** @hidden */
  89766. _isRightCamera: boolean;
  89767. /**
  89768. * Gets the right camera of a rig setup in case of Rigged Camera
  89769. */
  89770. readonly isRightCamera: boolean;
  89771. /**
  89772. * Gets the left camera of a rig setup in case of Rigged Camera
  89773. */
  89774. readonly leftCamera: Nullable<FreeCamera>;
  89775. /**
  89776. * Gets the right camera of a rig setup in case of Rigged Camera
  89777. */
  89778. readonly rightCamera: Nullable<FreeCamera>;
  89779. /**
  89780. * Gets the left camera target of a rig setup in case of Rigged Camera
  89781. * @returns the target position
  89782. */
  89783. getLeftTarget(): Nullable<Vector3>;
  89784. /**
  89785. * Gets the right camera target of a rig setup in case of Rigged Camera
  89786. * @returns the target position
  89787. */
  89788. getRightTarget(): Nullable<Vector3>;
  89789. /**
  89790. * @hidden
  89791. */
  89792. setCameraRigMode(mode: number, rigParams: any): void;
  89793. /** @hidden */
  89794. static _setStereoscopicRigMode(camera: Camera): void;
  89795. /** @hidden */
  89796. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  89797. /** @hidden */
  89798. static _setVRRigMode(camera: Camera, rigParams: any): void;
  89799. /** @hidden */
  89800. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  89801. /** @hidden */
  89802. _getVRProjectionMatrix(): Matrix;
  89803. protected _updateCameraRotationMatrix(): void;
  89804. protected _updateWebVRCameraRotationMatrix(): void;
  89805. /**
  89806. * This function MUST be overwritten by the different WebVR cameras available.
  89807. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  89808. * @hidden
  89809. */
  89810. _getWebVRProjectionMatrix(): Matrix;
  89811. /**
  89812. * This function MUST be overwritten by the different WebVR cameras available.
  89813. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  89814. * @hidden
  89815. */
  89816. _getWebVRViewMatrix(): Matrix;
  89817. /** @hidden */
  89818. setCameraRigParameter(name: string, value: any): void;
  89819. /**
  89820. * needs to be overridden by children so sub has required properties to be copied
  89821. * @hidden
  89822. */
  89823. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  89824. /**
  89825. * May need to be overridden by children
  89826. * @hidden
  89827. */
  89828. _updateRigCameras(): void;
  89829. /** @hidden */
  89830. _setupInputs(): void;
  89831. /**
  89832. * Serialiaze the camera setup to a json represention
  89833. * @returns the JSON representation
  89834. */
  89835. serialize(): any;
  89836. /**
  89837. * Clones the current camera.
  89838. * @param name The cloned camera name
  89839. * @returns the cloned camera
  89840. */
  89841. clone(name: string): Camera;
  89842. /**
  89843. * Gets the direction of the camera relative to a given local axis.
  89844. * @param localAxis Defines the reference axis to provide a relative direction.
  89845. * @return the direction
  89846. */
  89847. getDirection(localAxis: Vector3): Vector3;
  89848. /**
  89849. * Gets the direction of the camera relative to a given local axis into a passed vector.
  89850. * @param localAxis Defines the reference axis to provide a relative direction.
  89851. * @param result Defines the vector to store the result in
  89852. */
  89853. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  89854. /**
  89855. * Gets a camera constructor for a given camera type
  89856. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  89857. * @param name The name of the camera the result will be able to instantiate
  89858. * @param scene The scene the result will construct the camera in
  89859. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  89860. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  89861. * @returns a factory method to construc the camera
  89862. */
  89863. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  89864. /**
  89865. * Compute the world matrix of the camera.
  89866. * @returns the camera workd matrix
  89867. */
  89868. computeWorldMatrix(): Matrix;
  89869. /**
  89870. * Parse a JSON and creates the camera from the parsed information
  89871. * @param parsedCamera The JSON to parse
  89872. * @param scene The scene to instantiate the camera in
  89873. * @returns the newly constructed camera
  89874. */
  89875. static Parse(parsedCamera: any, scene: Scene): Camera;
  89876. }
  89877. }
  89878. declare module BABYLON {
  89879. /**
  89880. * Interface for any object that can request an animation frame
  89881. */
  89882. export interface ICustomAnimationFrameRequester {
  89883. /**
  89884. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  89885. */
  89886. renderFunction?: Function;
  89887. /**
  89888. * Called to request the next frame to render to
  89889. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  89890. */
  89891. requestAnimationFrame: Function;
  89892. /**
  89893. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  89894. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  89895. */
  89896. requestID?: number;
  89897. }
  89898. /**
  89899. * Interface containing an array of animations
  89900. */
  89901. export interface IAnimatable {
  89902. /**
  89903. * Array of animations
  89904. */
  89905. animations: Array<Animation>;
  89906. }
  89907. /** Interface used by value gradients (color, factor, ...) */
  89908. export interface IValueGradient {
  89909. /**
  89910. * Gets or sets the gradient value (between 0 and 1)
  89911. */
  89912. gradient: number;
  89913. }
  89914. /** Class used to store color4 gradient */
  89915. export class ColorGradient implements IValueGradient {
  89916. /**
  89917. * Gets or sets the gradient value (between 0 and 1)
  89918. */
  89919. gradient: number;
  89920. /**
  89921. * Gets or sets first associated color
  89922. */
  89923. color1: Color4;
  89924. /**
  89925. * Gets or sets second associated color
  89926. */
  89927. color2?: Color4;
  89928. /**
  89929. * Will get a color picked randomly between color1 and color2.
  89930. * If color2 is undefined then color1 will be used
  89931. * @param result defines the target Color4 to store the result in
  89932. */
  89933. getColorToRef(result: Color4): void;
  89934. }
  89935. /** Class used to store color 3 gradient */
  89936. export class Color3Gradient implements IValueGradient {
  89937. /**
  89938. * Gets or sets the gradient value (between 0 and 1)
  89939. */
  89940. gradient: number;
  89941. /**
  89942. * Gets or sets the associated color
  89943. */
  89944. color: Color3;
  89945. }
  89946. /** Class used to store factor gradient */
  89947. export class FactorGradient implements IValueGradient {
  89948. /**
  89949. * Gets or sets the gradient value (between 0 and 1)
  89950. */
  89951. gradient: number;
  89952. /**
  89953. * Gets or sets first associated factor
  89954. */
  89955. factor1: number;
  89956. /**
  89957. * Gets or sets second associated factor
  89958. */
  89959. factor2?: number;
  89960. /**
  89961. * Will get a number picked randomly between factor1 and factor2.
  89962. * If factor2 is undefined then factor1 will be used
  89963. * @returns the picked number
  89964. */
  89965. getFactor(): number;
  89966. }
  89967. /**
  89968. * @ignore
  89969. * Application error to support additional information when loading a file
  89970. */
  89971. export class LoadFileError extends Error {
  89972. /** defines the optional web request */
  89973. request?: WebRequest | undefined;
  89974. private static _setPrototypeOf;
  89975. /**
  89976. * Creates a new LoadFileError
  89977. * @param message defines the message of the error
  89978. * @param request defines the optional web request
  89979. */
  89980. constructor(message: string,
  89981. /** defines the optional web request */
  89982. request?: WebRequest | undefined);
  89983. }
  89984. /**
  89985. * Class used to define a retry strategy when error happens while loading assets
  89986. */
  89987. export class RetryStrategy {
  89988. /**
  89989. * Function used to defines an exponential back off strategy
  89990. * @param maxRetries defines the maximum number of retries (3 by default)
  89991. * @param baseInterval defines the interval between retries
  89992. * @returns the strategy function to use
  89993. */
  89994. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  89995. }
  89996. /**
  89997. * File request interface
  89998. */
  89999. export interface IFileRequest {
  90000. /**
  90001. * Raised when the request is complete (success or error).
  90002. */
  90003. onCompleteObservable: Observable<IFileRequest>;
  90004. /**
  90005. * Aborts the request for a file.
  90006. */
  90007. abort: () => void;
  90008. }
  90009. /**
  90010. * Class containing a set of static utilities functions
  90011. */
  90012. export class Tools {
  90013. /**
  90014. * Gets or sets the base URL to use to load assets
  90015. */
  90016. static BaseUrl: string;
  90017. /**
  90018. * Enable/Disable Custom HTTP Request Headers globally.
  90019. * default = false
  90020. * @see CustomRequestHeaders
  90021. */
  90022. static UseCustomRequestHeaders: boolean;
  90023. /**
  90024. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  90025. * i.e. when loading files, where the server/service expects an Authorization header
  90026. */
  90027. static CustomRequestHeaders: {
  90028. [key: string]: string;
  90029. };
  90030. /**
  90031. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  90032. */
  90033. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  90034. /**
  90035. * Default behaviour for cors in the application.
  90036. * It can be a string if the expected behavior is identical in the entire app.
  90037. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  90038. */
  90039. static CorsBehavior: string | ((url: string | string[]) => string);
  90040. /**
  90041. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  90042. * @ignorenaming
  90043. */
  90044. static UseFallbackTexture: boolean;
  90045. /**
  90046. * Use this object to register external classes like custom textures or material
  90047. * to allow the laoders to instantiate them
  90048. */
  90049. static RegisteredExternalClasses: {
  90050. [key: string]: Object;
  90051. };
  90052. /**
  90053. * Texture content used if a texture cannot loaded
  90054. * @ignorenaming
  90055. */
  90056. static fallbackTexture: string;
  90057. /**
  90058. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  90059. * @param u defines the coordinate on X axis
  90060. * @param v defines the coordinate on Y axis
  90061. * @param width defines the width of the source data
  90062. * @param height defines the height of the source data
  90063. * @param pixels defines the source byte array
  90064. * @param color defines the output color
  90065. */
  90066. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  90067. /**
  90068. * Interpolates between a and b via alpha
  90069. * @param a The lower value (returned when alpha = 0)
  90070. * @param b The upper value (returned when alpha = 1)
  90071. * @param alpha The interpolation-factor
  90072. * @return The mixed value
  90073. */
  90074. static Mix(a: number, b: number, alpha: number): number;
  90075. /**
  90076. * Tries to instantiate a new object from a given class name
  90077. * @param className defines the class name to instantiate
  90078. * @returns the new object or null if the system was not able to do the instantiation
  90079. */
  90080. static Instantiate(className: string): any;
  90081. /**
  90082. * Provides a slice function that will work even on IE
  90083. * @param data defines the array to slice
  90084. * @param start defines the start of the data (optional)
  90085. * @param end defines the end of the data (optional)
  90086. * @returns the new sliced array
  90087. */
  90088. static Slice<T>(data: T, start?: number, end?: number): T;
  90089. /**
  90090. * Polyfill for setImmediate
  90091. * @param action defines the action to execute after the current execution block
  90092. */
  90093. static SetImmediate(action: () => void): void;
  90094. /**
  90095. * Function indicating if a number is an exponent of 2
  90096. * @param value defines the value to test
  90097. * @returns true if the value is an exponent of 2
  90098. */
  90099. static IsExponentOfTwo(value: number): boolean;
  90100. private static _tmpFloatArray;
  90101. /**
  90102. * Returns the nearest 32-bit single precision float representation of a Number
  90103. * @param value A Number. If the parameter is of a different type, it will get converted
  90104. * to a number or to NaN if it cannot be converted
  90105. * @returns number
  90106. */
  90107. static FloatRound(value: number): number;
  90108. /**
  90109. * Find the next highest power of two.
  90110. * @param x Number to start search from.
  90111. * @return Next highest power of two.
  90112. */
  90113. static CeilingPOT(x: number): number;
  90114. /**
  90115. * Find the next lowest power of two.
  90116. * @param x Number to start search from.
  90117. * @return Next lowest power of two.
  90118. */
  90119. static FloorPOT(x: number): number;
  90120. /**
  90121. * Find the nearest power of two.
  90122. * @param x Number to start search from.
  90123. * @return Next nearest power of two.
  90124. */
  90125. static NearestPOT(x: number): number;
  90126. /**
  90127. * Get the closest exponent of two
  90128. * @param value defines the value to approximate
  90129. * @param max defines the maximum value to return
  90130. * @param mode defines how to define the closest value
  90131. * @returns closest exponent of two of the given value
  90132. */
  90133. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  90134. /**
  90135. * Extracts the filename from a path
  90136. * @param path defines the path to use
  90137. * @returns the filename
  90138. */
  90139. static GetFilename(path: string): string;
  90140. /**
  90141. * Extracts the "folder" part of a path (everything before the filename).
  90142. * @param uri The URI to extract the info from
  90143. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  90144. * @returns The "folder" part of the path
  90145. */
  90146. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  90147. /**
  90148. * Extracts text content from a DOM element hierarchy
  90149. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  90150. */
  90151. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  90152. /**
  90153. * Convert an angle in radians to degrees
  90154. * @param angle defines the angle to convert
  90155. * @returns the angle in degrees
  90156. */
  90157. static ToDegrees(angle: number): number;
  90158. /**
  90159. * Convert an angle in degrees to radians
  90160. * @param angle defines the angle to convert
  90161. * @returns the angle in radians
  90162. */
  90163. static ToRadians(angle: number): number;
  90164. /**
  90165. * Encode a buffer to a base64 string
  90166. * @param buffer defines the buffer to encode
  90167. * @returns the encoded string
  90168. */
  90169. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  90170. /**
  90171. * Extracts minimum and maximum values from a list of indexed positions
  90172. * @param positions defines the positions to use
  90173. * @param indices defines the indices to the positions
  90174. * @param indexStart defines the start index
  90175. * @param indexCount defines the end index
  90176. * @param bias defines bias value to add to the result
  90177. * @return minimum and maximum values
  90178. */
  90179. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  90180. minimum: Vector3;
  90181. maximum: Vector3;
  90182. };
  90183. /**
  90184. * Extracts minimum and maximum values from a list of positions
  90185. * @param positions defines the positions to use
  90186. * @param start defines the start index in the positions array
  90187. * @param count defines the number of positions to handle
  90188. * @param bias defines bias value to add to the result
  90189. * @param stride defines the stride size to use (distance between two positions in the positions array)
  90190. * @return minimum and maximum values
  90191. */
  90192. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  90193. minimum: Vector3;
  90194. maximum: Vector3;
  90195. };
  90196. /**
  90197. * Returns an array if obj is not an array
  90198. * @param obj defines the object to evaluate as an array
  90199. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  90200. * @returns either obj directly if obj is an array or a new array containing obj
  90201. */
  90202. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  90203. /**
  90204. * Gets the pointer prefix to use
  90205. * @returns "pointer" if touch is enabled. Else returns "mouse"
  90206. */
  90207. static GetPointerPrefix(): string;
  90208. /**
  90209. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  90210. * @param func - the function to be called
  90211. * @param requester - the object that will request the next frame. Falls back to window.
  90212. * @returns frame number
  90213. */
  90214. static QueueNewFrame(func: () => void, requester?: any): number;
  90215. /**
  90216. * Ask the browser to promote the current element to fullscreen rendering mode
  90217. * @param element defines the DOM element to promote
  90218. */
  90219. static RequestFullscreen(element: HTMLElement): void;
  90220. /**
  90221. * Asks the browser to exit fullscreen mode
  90222. */
  90223. static ExitFullscreen(): void;
  90224. /**
  90225. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  90226. * @param url define the url we are trying
  90227. * @param element define the dom element where to configure the cors policy
  90228. */
  90229. static SetCorsBehavior(url: string | string[], element: {
  90230. crossOrigin: string | null;
  90231. }): void;
  90232. /**
  90233. * Removes unwanted characters from an url
  90234. * @param url defines the url to clean
  90235. * @returns the cleaned url
  90236. */
  90237. static CleanUrl(url: string): string;
  90238. /**
  90239. * Gets or sets a function used to pre-process url before using them to load assets
  90240. */
  90241. static PreprocessUrl: (url: string) => string;
  90242. /**
  90243. * Loads an image as an HTMLImageElement.
  90244. * @param input url string, ArrayBuffer, or Blob to load
  90245. * @param onLoad callback called when the image successfully loads
  90246. * @param onError callback called when the image fails to load
  90247. * @param offlineProvider offline provider for caching
  90248. * @returns the HTMLImageElement of the loaded image
  90249. */
  90250. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  90251. /**
  90252. * Loads a file
  90253. * @param url url string, ArrayBuffer, or Blob to load
  90254. * @param onSuccess callback called when the file successfully loads
  90255. * @param onProgress callback called while file is loading (if the server supports this mode)
  90256. * @param offlineProvider defines the offline provider for caching
  90257. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  90258. * @param onError callback called when the file fails to load
  90259. * @returns a file request object
  90260. */
  90261. 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;
  90262. /**
  90263. * Load a script (identified by an url). When the url returns, the
  90264. * content of this file is added into a new script element, attached to the DOM (body element)
  90265. * @param scriptUrl defines the url of the script to laod
  90266. * @param onSuccess defines the callback called when the script is loaded
  90267. * @param onError defines the callback to call if an error occurs
  90268. * @param scriptId defines the id of the script element
  90269. */
  90270. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  90271. /**
  90272. * Load an asynchronous script (identified by an url). When the url returns, the
  90273. * content of this file is added into a new script element, attached to the DOM (body element)
  90274. * @param scriptUrl defines the url of the script to laod
  90275. * @param scriptId defines the id of the script element
  90276. * @returns a promise request object
  90277. */
  90278. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Nullable<Promise<boolean>>;
  90279. /**
  90280. * Loads a file from a blob
  90281. * @param fileToLoad defines the blob to use
  90282. * @param callback defines the callback to call when data is loaded
  90283. * @param progressCallback defines the callback to call during loading process
  90284. * @returns a file request object
  90285. */
  90286. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  90287. /**
  90288. * Loads a file
  90289. * @param fileToLoad defines the file to load
  90290. * @param callback defines the callback to call when data is loaded
  90291. * @param progressCallBack defines the callback to call during loading process
  90292. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  90293. * @returns a file request object
  90294. */
  90295. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  90296. /**
  90297. * Creates a data url from a given string content
  90298. * @param content defines the content to convert
  90299. * @returns the new data url link
  90300. */
  90301. static FileAsURL(content: string): string;
  90302. /**
  90303. * Format the given number to a specific decimal format
  90304. * @param value defines the number to format
  90305. * @param decimals defines the number of decimals to use
  90306. * @returns the formatted string
  90307. */
  90308. static Format(value: number, decimals?: number): string;
  90309. /**
  90310. * Checks if a given vector is inside a specific range
  90311. * @param v defines the vector to test
  90312. * @param min defines the minimum range
  90313. * @param max defines the maximum range
  90314. */
  90315. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  90316. /**
  90317. * Tries to copy an object by duplicating every property
  90318. * @param source defines the source object
  90319. * @param destination defines the target object
  90320. * @param doNotCopyList defines a list of properties to avoid
  90321. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  90322. */
  90323. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  90324. /**
  90325. * Gets a boolean indicating if the given object has no own property
  90326. * @param obj defines the object to test
  90327. * @returns true if object has no own property
  90328. */
  90329. static IsEmpty(obj: any): boolean;
  90330. /**
  90331. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  90332. * @param str Source string
  90333. * @param suffix Suffix to search for in the source string
  90334. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  90335. */
  90336. static EndsWith(str: string, suffix: string): boolean;
  90337. /**
  90338. * Function used to register events at window level
  90339. * @param events defines the events to register
  90340. */
  90341. static RegisterTopRootEvents(events: {
  90342. name: string;
  90343. handler: Nullable<(e: FocusEvent) => any>;
  90344. }[]): void;
  90345. /**
  90346. * Function used to unregister events from window level
  90347. * @param events defines the events to unregister
  90348. */
  90349. static UnregisterTopRootEvents(events: {
  90350. name: string;
  90351. handler: Nullable<(e: FocusEvent) => any>;
  90352. }[]): void;
  90353. /**
  90354. * @ignore
  90355. */
  90356. static _ScreenshotCanvas: HTMLCanvasElement;
  90357. /**
  90358. * Dumps the current bound framebuffer
  90359. * @param width defines the rendering width
  90360. * @param height defines the rendering height
  90361. * @param engine defines the hosting engine
  90362. * @param successCallback defines the callback triggered once the data are available
  90363. * @param mimeType defines the mime type of the result
  90364. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  90365. */
  90366. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  90367. /**
  90368. * Converts the canvas data to blob.
  90369. * This acts as a polyfill for browsers not supporting the to blob function.
  90370. * @param canvas Defines the canvas to extract the data from
  90371. * @param successCallback Defines the callback triggered once the data are available
  90372. * @param mimeType Defines the mime type of the result
  90373. */
  90374. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  90375. /**
  90376. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  90377. * @param successCallback defines the callback triggered once the data are available
  90378. * @param mimeType defines the mime type of the result
  90379. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  90380. */
  90381. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  90382. /**
  90383. * Downloads a blob in the browser
  90384. * @param blob defines the blob to download
  90385. * @param fileName defines the name of the downloaded file
  90386. */
  90387. static Download(blob: Blob, fileName: string): void;
  90388. /**
  90389. * Captures a screenshot of the current rendering
  90390. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  90391. * @param engine defines the rendering engine
  90392. * @param camera defines the source camera
  90393. * @param size This parameter can be set to a single number or to an object with the
  90394. * following (optional) properties: precision, width, height. If a single number is passed,
  90395. * it will be used for both width and height. If an object is passed, the screenshot size
  90396. * will be derived from the parameters. The precision property is a multiplier allowing
  90397. * rendering at a higher or lower resolution
  90398. * @param successCallback defines the callback receives a single parameter which contains the
  90399. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  90400. * src parameter of an <img> to display it
  90401. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  90402. * Check your browser for supported MIME types
  90403. */
  90404. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  90405. /**
  90406. * Generates an image screenshot from the specified camera.
  90407. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  90408. * @param engine The engine to use for rendering
  90409. * @param camera The camera to use for rendering
  90410. * @param size This parameter can be set to a single number or to an object with the
  90411. * following (optional) properties: precision, width, height. If a single number is passed,
  90412. * it will be used for both width and height. If an object is passed, the screenshot size
  90413. * will be derived from the parameters. The precision property is a multiplier allowing
  90414. * rendering at a higher or lower resolution
  90415. * @param successCallback The callback receives a single parameter which contains the
  90416. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  90417. * src parameter of an <img> to display it
  90418. * @param mimeType The MIME type of the screenshot image (default: image/png).
  90419. * Check your browser for supported MIME types
  90420. * @param samples Texture samples (default: 1)
  90421. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  90422. * @param fileName A name for for the downloaded file.
  90423. */
  90424. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  90425. /**
  90426. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  90427. * Be aware Math.random() could cause collisions, but:
  90428. * "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"
  90429. * @returns a pseudo random id
  90430. */
  90431. static RandomId(): string;
  90432. /**
  90433. * Test if the given uri is a base64 string
  90434. * @param uri The uri to test
  90435. * @return True if the uri is a base64 string or false otherwise
  90436. */
  90437. static IsBase64(uri: string): boolean;
  90438. /**
  90439. * Decode the given base64 uri.
  90440. * @param uri The uri to decode
  90441. * @return The decoded base64 data.
  90442. */
  90443. static DecodeBase64(uri: string): ArrayBuffer;
  90444. /**
  90445. * Gets the absolute url.
  90446. * @param url the input url
  90447. * @return the absolute url
  90448. */
  90449. static GetAbsoluteUrl(url: string): string;
  90450. /**
  90451. * No log
  90452. */
  90453. static readonly NoneLogLevel: number;
  90454. /**
  90455. * Only message logs
  90456. */
  90457. static readonly MessageLogLevel: number;
  90458. /**
  90459. * Only warning logs
  90460. */
  90461. static readonly WarningLogLevel: number;
  90462. /**
  90463. * Only error logs
  90464. */
  90465. static readonly ErrorLogLevel: number;
  90466. /**
  90467. * All logs
  90468. */
  90469. static readonly AllLogLevel: number;
  90470. /**
  90471. * Gets a value indicating the number of loading errors
  90472. * @ignorenaming
  90473. */
  90474. static readonly errorsCount: number;
  90475. /**
  90476. * Callback called when a new log is added
  90477. */
  90478. static OnNewCacheEntry: (entry: string) => void;
  90479. /**
  90480. * Log a message to the console
  90481. * @param message defines the message to log
  90482. */
  90483. static Log(message: string): void;
  90484. /**
  90485. * Write a warning message to the console
  90486. * @param message defines the message to log
  90487. */
  90488. static Warn(message: string): void;
  90489. /**
  90490. * Write an error message to the console
  90491. * @param message defines the message to log
  90492. */
  90493. static Error(message: string): void;
  90494. /**
  90495. * Gets current log cache (list of logs)
  90496. */
  90497. static readonly LogCache: string;
  90498. /**
  90499. * Clears the log cache
  90500. */
  90501. static ClearLogCache(): void;
  90502. /**
  90503. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  90504. */
  90505. static LogLevels: number;
  90506. /**
  90507. * Checks if the loaded document was accessed via `file:`-Protocol.
  90508. * @returns boolean
  90509. */
  90510. static IsFileURL(): boolean;
  90511. /**
  90512. * Checks if the window object exists
  90513. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  90514. */
  90515. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  90516. /**
  90517. * No performance log
  90518. */
  90519. static readonly PerformanceNoneLogLevel: number;
  90520. /**
  90521. * Use user marks to log performance
  90522. */
  90523. static readonly PerformanceUserMarkLogLevel: number;
  90524. /**
  90525. * Log performance to the console
  90526. */
  90527. static readonly PerformanceConsoleLogLevel: number;
  90528. private static _performance;
  90529. /**
  90530. * Sets the current performance log level
  90531. */
  90532. static PerformanceLogLevel: number;
  90533. private static _StartPerformanceCounterDisabled;
  90534. private static _EndPerformanceCounterDisabled;
  90535. private static _StartUserMark;
  90536. private static _EndUserMark;
  90537. private static _StartPerformanceConsole;
  90538. private static _EndPerformanceConsole;
  90539. /**
  90540. * Starts a performance counter
  90541. */
  90542. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  90543. /**
  90544. * Ends a specific performance coutner
  90545. */
  90546. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  90547. /**
  90548. * Gets either window.performance.now() if supported or Date.now() else
  90549. */
  90550. static readonly Now: number;
  90551. /**
  90552. * This method will return the name of the class used to create the instance of the given object.
  90553. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  90554. * @param object the object to get the class name from
  90555. * @param isType defines if the object is actually a type
  90556. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  90557. */
  90558. static GetClassName(object: any, isType?: boolean): string;
  90559. /**
  90560. * Gets the first element of an array satisfying a given predicate
  90561. * @param array defines the array to browse
  90562. * @param predicate defines the predicate to use
  90563. * @returns null if not found or the element
  90564. */
  90565. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  90566. /**
  90567. * This method will return the name of the full name of the class, including its owning module (if any).
  90568. * 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).
  90569. * @param object the object to get the class name from
  90570. * @param isType defines if the object is actually a type
  90571. * @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.
  90572. * @ignorenaming
  90573. */
  90574. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  90575. /**
  90576. * Returns a promise that resolves after the given amount of time.
  90577. * @param delay Number of milliseconds to delay
  90578. * @returns Promise that resolves after the given amount of time
  90579. */
  90580. static DelayAsync(delay: number): Promise<void>;
  90581. /**
  90582. * Gets the current gradient from an array of IValueGradient
  90583. * @param ratio defines the current ratio to get
  90584. * @param gradients defines the array of IValueGradient
  90585. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  90586. */
  90587. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  90588. }
  90589. /**
  90590. * This class is used to track a performance counter which is number based.
  90591. * The user has access to many properties which give statistics of different nature.
  90592. *
  90593. * The implementer can track two kinds of Performance Counter: time and count.
  90594. * 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.
  90595. * 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.
  90596. */
  90597. export class PerfCounter {
  90598. /**
  90599. * Gets or sets a global boolean to turn on and off all the counters
  90600. */
  90601. static Enabled: boolean;
  90602. /**
  90603. * Returns the smallest value ever
  90604. */
  90605. readonly min: number;
  90606. /**
  90607. * Returns the biggest value ever
  90608. */
  90609. readonly max: number;
  90610. /**
  90611. * Returns the average value since the performance counter is running
  90612. */
  90613. readonly average: number;
  90614. /**
  90615. * Returns the average value of the last second the counter was monitored
  90616. */
  90617. readonly lastSecAverage: number;
  90618. /**
  90619. * Returns the current value
  90620. */
  90621. readonly current: number;
  90622. /**
  90623. * Gets the accumulated total
  90624. */
  90625. readonly total: number;
  90626. /**
  90627. * Gets the total value count
  90628. */
  90629. readonly count: number;
  90630. /**
  90631. * Creates a new counter
  90632. */
  90633. constructor();
  90634. /**
  90635. * Call this method to start monitoring a new frame.
  90636. * 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.
  90637. */
  90638. fetchNewFrame(): void;
  90639. /**
  90640. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  90641. * @param newCount the count value to add to the monitored count
  90642. * @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.
  90643. */
  90644. addCount(newCount: number, fetchResult: boolean): void;
  90645. /**
  90646. * Start monitoring this performance counter
  90647. */
  90648. beginMonitoring(): void;
  90649. /**
  90650. * Compute the time lapsed since the previous beginMonitoring() call.
  90651. * @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
  90652. */
  90653. endMonitoring(newFrame?: boolean): void;
  90654. private _fetchResult;
  90655. private _startMonitoringTime;
  90656. private _min;
  90657. private _max;
  90658. private _average;
  90659. private _current;
  90660. private _totalValueCount;
  90661. private _totalAccumulated;
  90662. private _lastSecAverage;
  90663. private _lastSecAccumulated;
  90664. private _lastSecTime;
  90665. private _lastSecValueCount;
  90666. }
  90667. /**
  90668. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  90669. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  90670. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  90671. * @param name The name of the class, case should be preserved
  90672. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  90673. */
  90674. export function className(name: string, module?: string): (target: Object) => void;
  90675. /**
  90676. * An implementation of a loop for asynchronous functions.
  90677. */
  90678. export class AsyncLoop {
  90679. /**
  90680. * Defines the number of iterations for the loop
  90681. */
  90682. iterations: number;
  90683. /**
  90684. * Defines the current index of the loop.
  90685. */
  90686. index: number;
  90687. private _done;
  90688. private _fn;
  90689. private _successCallback;
  90690. /**
  90691. * Constructor.
  90692. * @param iterations the number of iterations.
  90693. * @param func the function to run each iteration
  90694. * @param successCallback the callback that will be called upon succesful execution
  90695. * @param offset starting offset.
  90696. */
  90697. constructor(
  90698. /**
  90699. * Defines the number of iterations for the loop
  90700. */
  90701. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  90702. /**
  90703. * Execute the next iteration. Must be called after the last iteration was finished.
  90704. */
  90705. executeNext(): void;
  90706. /**
  90707. * Break the loop and run the success callback.
  90708. */
  90709. breakLoop(): void;
  90710. /**
  90711. * Create and run an async loop.
  90712. * @param iterations the number of iterations.
  90713. * @param fn the function to run each iteration
  90714. * @param successCallback the callback that will be called upon succesful execution
  90715. * @param offset starting offset.
  90716. * @returns the created async loop object
  90717. */
  90718. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  90719. /**
  90720. * A for-loop that will run a given number of iterations synchronous and the rest async.
  90721. * @param iterations total number of iterations
  90722. * @param syncedIterations number of synchronous iterations in each async iteration.
  90723. * @param fn the function to call each iteration.
  90724. * @param callback a success call back that will be called when iterating stops.
  90725. * @param breakFunction a break condition (optional)
  90726. * @param timeout timeout settings for the setTimeout function. default - 0.
  90727. * @returns the created async loop object
  90728. */
  90729. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  90730. }
  90731. }
  90732. declare module BABYLON {
  90733. /** @hidden */
  90734. export interface ICollisionCoordinator {
  90735. createCollider(): Collider;
  90736. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  90737. init(scene: Scene): void;
  90738. }
  90739. /** @hidden */
  90740. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  90741. private _scene;
  90742. private _scaledPosition;
  90743. private _scaledVelocity;
  90744. private _finalPosition;
  90745. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  90746. createCollider(): Collider;
  90747. init(scene: Scene): void;
  90748. private _collideWithWorld;
  90749. }
  90750. }
  90751. declare module BABYLON {
  90752. /**
  90753. * This class defines the direct association between an animation and a target
  90754. */
  90755. export class TargetedAnimation {
  90756. /**
  90757. * Animation to perform
  90758. */
  90759. animation: Animation;
  90760. /**
  90761. * Target to animate
  90762. */
  90763. target: any;
  90764. }
  90765. /**
  90766. * Use this class to create coordinated animations on multiple targets
  90767. */
  90768. export class AnimationGroup implements IDisposable {
  90769. /** The name of the animation group */
  90770. name: string;
  90771. private _scene;
  90772. private _targetedAnimations;
  90773. private _animatables;
  90774. private _from;
  90775. private _to;
  90776. private _isStarted;
  90777. private _isPaused;
  90778. private _speedRatio;
  90779. /**
  90780. * Gets or sets the unique id of the node
  90781. */
  90782. uniqueId: number;
  90783. /**
  90784. * This observable will notify when one animation have ended
  90785. */
  90786. onAnimationEndObservable: Observable<TargetedAnimation>;
  90787. /**
  90788. * Observer raised when one animation loops
  90789. */
  90790. onAnimationLoopObservable: Observable<TargetedAnimation>;
  90791. /**
  90792. * This observable will notify when all animations have ended.
  90793. */
  90794. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  90795. /**
  90796. * This observable will notify when all animations have paused.
  90797. */
  90798. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  90799. /**
  90800. * This observable will notify when all animations are playing.
  90801. */
  90802. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  90803. /**
  90804. * Gets the first frame
  90805. */
  90806. readonly from: number;
  90807. /**
  90808. * Gets the last frame
  90809. */
  90810. readonly to: number;
  90811. /**
  90812. * Define if the animations are started
  90813. */
  90814. readonly isStarted: boolean;
  90815. /**
  90816. * Gets a value indicating that the current group is playing
  90817. */
  90818. readonly isPlaying: boolean;
  90819. /**
  90820. * Gets or sets the speed ratio to use for all animations
  90821. */
  90822. /**
  90823. * Gets or sets the speed ratio to use for all animations
  90824. */
  90825. speedRatio: number;
  90826. /**
  90827. * Gets the targeted animations for this animation group
  90828. */
  90829. readonly targetedAnimations: Array<TargetedAnimation>;
  90830. /**
  90831. * returning the list of animatables controlled by this animation group.
  90832. */
  90833. readonly animatables: Array<Animatable>;
  90834. /**
  90835. * Instantiates a new Animation Group.
  90836. * This helps managing several animations at once.
  90837. * @see http://doc.babylonjs.com/how_to/group
  90838. * @param name Defines the name of the group
  90839. * @param scene Defines the scene the group belongs to
  90840. */
  90841. constructor(
  90842. /** The name of the animation group */
  90843. name: string, scene?: Nullable<Scene>);
  90844. /**
  90845. * Add an animation (with its target) in the group
  90846. * @param animation defines the animation we want to add
  90847. * @param target defines the target of the animation
  90848. * @returns the TargetedAnimation object
  90849. */
  90850. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  90851. /**
  90852. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  90853. * It can add constant keys at begin or end
  90854. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  90855. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  90856. * @returns the animation group
  90857. */
  90858. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  90859. /**
  90860. * Start all animations on given targets
  90861. * @param loop defines if animations must loop
  90862. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  90863. * @param from defines the from key (optional)
  90864. * @param to defines the to key (optional)
  90865. * @returns the current animation group
  90866. */
  90867. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  90868. /**
  90869. * Pause all animations
  90870. * @returns the animation group
  90871. */
  90872. pause(): AnimationGroup;
  90873. /**
  90874. * Play all animations to initial state
  90875. * This function will start() the animations if they were not started or will restart() them if they were paused
  90876. * @param loop defines if animations must loop
  90877. * @returns the animation group
  90878. */
  90879. play(loop?: boolean): AnimationGroup;
  90880. /**
  90881. * Reset all animations to initial state
  90882. * @returns the animation group
  90883. */
  90884. reset(): AnimationGroup;
  90885. /**
  90886. * Restart animations from key 0
  90887. * @returns the animation group
  90888. */
  90889. restart(): AnimationGroup;
  90890. /**
  90891. * Stop all animations
  90892. * @returns the animation group
  90893. */
  90894. stop(): AnimationGroup;
  90895. /**
  90896. * Set animation weight for all animatables
  90897. * @param weight defines the weight to use
  90898. * @return the animationGroup
  90899. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  90900. */
  90901. setWeightForAllAnimatables(weight: number): AnimationGroup;
  90902. /**
  90903. * Synchronize and normalize all animatables with a source animatable
  90904. * @param root defines the root animatable to synchronize with
  90905. * @return the animationGroup
  90906. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  90907. */
  90908. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  90909. /**
  90910. * Goes to a specific frame in this animation group
  90911. * @param frame the frame number to go to
  90912. * @return the animationGroup
  90913. */
  90914. goToFrame(frame: number): AnimationGroup;
  90915. /**
  90916. * Dispose all associated resources
  90917. */
  90918. dispose(): void;
  90919. private _checkAnimationGroupEnded;
  90920. /**
  90921. * Clone the current animation group and returns a copy
  90922. * @param newName defines the name of the new group
  90923. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  90924. * @returns the new aniamtion group
  90925. */
  90926. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  90927. /**
  90928. * Returns a new AnimationGroup object parsed from the source provided.
  90929. * @param parsedAnimationGroup defines the source
  90930. * @param scene defines the scene that will receive the animationGroup
  90931. * @returns a new AnimationGroup
  90932. */
  90933. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  90934. /**
  90935. * Returns the string "AnimationGroup"
  90936. * @returns "AnimationGroup"
  90937. */
  90938. getClassName(): string;
  90939. /**
  90940. * Creates a detailled string about the object
  90941. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  90942. * @returns a string representing the object
  90943. */
  90944. toString(fullDetails?: boolean): string;
  90945. }
  90946. }
  90947. declare module BABYLON {
  90948. /**
  90949. * Define an interface for all classes that will hold resources
  90950. */
  90951. export interface IDisposable {
  90952. /**
  90953. * Releases all held resources
  90954. */
  90955. dispose(): void;
  90956. }
  90957. /** Interface defining initialization parameters for Scene class */
  90958. export interface SceneOptions {
  90959. /**
  90960. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  90961. * It will improve performance when the number of geometries becomes important.
  90962. */
  90963. useGeometryUniqueIdsMap?: boolean;
  90964. /**
  90965. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  90966. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  90967. */
  90968. useMaterialMeshMap?: boolean;
  90969. /**
  90970. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  90971. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  90972. */
  90973. useClonedMeshhMap?: boolean;
  90974. }
  90975. /**
  90976. * Represents a scene to be rendered by the engine.
  90977. * @see http://doc.babylonjs.com/features/scene
  90978. */
  90979. export class Scene extends AbstractScene implements IAnimatable {
  90980. private static _uniqueIdCounter;
  90981. /** The fog is deactivated */
  90982. static readonly FOGMODE_NONE: number;
  90983. /** The fog density is following an exponential function */
  90984. static readonly FOGMODE_EXP: number;
  90985. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  90986. static readonly FOGMODE_EXP2: number;
  90987. /** The fog density is following a linear function. */
  90988. static readonly FOGMODE_LINEAR: number;
  90989. /**
  90990. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  90991. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  90992. */
  90993. static MinDeltaTime: number;
  90994. /**
  90995. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  90996. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  90997. */
  90998. static MaxDeltaTime: number;
  90999. /**
  91000. * Factory used to create the default material.
  91001. * @param name The name of the material to create
  91002. * @param scene The scene to create the material for
  91003. * @returns The default material
  91004. */
  91005. static DefaultMaterialFactory(scene: Scene): Material;
  91006. /**
  91007. * Factory used to create the a collision coordinator.
  91008. * @returns The collision coordinator
  91009. */
  91010. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  91011. /** @hidden */
  91012. readonly _isScene: boolean;
  91013. /**
  91014. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  91015. */
  91016. autoClear: boolean;
  91017. /**
  91018. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  91019. */
  91020. autoClearDepthAndStencil: boolean;
  91021. /**
  91022. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  91023. */
  91024. clearColor: Color4;
  91025. /**
  91026. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  91027. */
  91028. ambientColor: Color3;
  91029. /**
  91030. * This is use to store the default BRDF lookup for PBR materials in your scene.
  91031. * It should only be one of the following (if not the default embedded one):
  91032. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  91033. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  91034. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  91035. * The material properties need to be setup according to the type of texture in use.
  91036. */
  91037. environmentBRDFTexture: BaseTexture;
  91038. /** @hidden */
  91039. protected _environmentTexture: Nullable<BaseTexture>;
  91040. /**
  91041. * Texture used in all pbr material as the reflection texture.
  91042. * As in the majority of the scene they are the same (exception for multi room and so on),
  91043. * this is easier to reference from here than from all the materials.
  91044. */
  91045. /**
  91046. * Texture used in all pbr material as the reflection texture.
  91047. * As in the majority of the scene they are the same (exception for multi room and so on),
  91048. * this is easier to set here than in all the materials.
  91049. */
  91050. environmentTexture: Nullable<BaseTexture>;
  91051. /** @hidden */
  91052. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  91053. /**
  91054. * Default image processing configuration used either in the rendering
  91055. * Forward main pass or through the imageProcessingPostProcess if present.
  91056. * As in the majority of the scene they are the same (exception for multi camera),
  91057. * this is easier to reference from here than from all the materials and post process.
  91058. *
  91059. * No setter as we it is a shared configuration, you can set the values instead.
  91060. */
  91061. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  91062. private _forceWireframe;
  91063. /**
  91064. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  91065. */
  91066. forceWireframe: boolean;
  91067. private _forcePointsCloud;
  91068. /**
  91069. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  91070. */
  91071. forcePointsCloud: boolean;
  91072. /**
  91073. * Gets or sets the active clipplane 1
  91074. */
  91075. clipPlane: Nullable<Plane>;
  91076. /**
  91077. * Gets or sets the active clipplane 2
  91078. */
  91079. clipPlane2: Nullable<Plane>;
  91080. /**
  91081. * Gets or sets the active clipplane 3
  91082. */
  91083. clipPlane3: Nullable<Plane>;
  91084. /**
  91085. * Gets or sets the active clipplane 4
  91086. */
  91087. clipPlane4: Nullable<Plane>;
  91088. /**
  91089. * Gets or sets a boolean indicating if animations are enabled
  91090. */
  91091. animationsEnabled: boolean;
  91092. private _animationPropertiesOverride;
  91093. /**
  91094. * Gets or sets the animation properties override
  91095. */
  91096. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  91097. /**
  91098. * Gets or sets a boolean indicating if a constant deltatime has to be used
  91099. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  91100. */
  91101. useConstantAnimationDeltaTime: boolean;
  91102. /**
  91103. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  91104. * Please note that it requires to run a ray cast through the scene on every frame
  91105. */
  91106. constantlyUpdateMeshUnderPointer: boolean;
  91107. /**
  91108. * Defines the HTML cursor to use when hovering over interactive elements
  91109. */
  91110. hoverCursor: string;
  91111. /**
  91112. * Defines the HTML default cursor to use (empty by default)
  91113. */
  91114. defaultCursor: string;
  91115. /**
  91116. * This is used to call preventDefault() on pointer down
  91117. * in order to block unwanted artifacts like system double clicks
  91118. */
  91119. preventDefaultOnPointerDown: boolean;
  91120. /**
  91121. * This is used to call preventDefault() on pointer up
  91122. * in order to block unwanted artifacts like system double clicks
  91123. */
  91124. preventDefaultOnPointerUp: boolean;
  91125. /**
  91126. * Gets or sets user defined metadata
  91127. */
  91128. metadata: any;
  91129. /**
  91130. * For internal use only. Please do not use.
  91131. */
  91132. reservedDataStore: any;
  91133. /**
  91134. * Gets the name of the plugin used to load this scene (null by default)
  91135. */
  91136. loadingPluginName: string;
  91137. /**
  91138. * Use this array to add regular expressions used to disable offline support for specific urls
  91139. */
  91140. disableOfflineSupportExceptionRules: RegExp[];
  91141. /**
  91142. * An event triggered when the scene is disposed.
  91143. */
  91144. onDisposeObservable: Observable<Scene>;
  91145. private _onDisposeObserver;
  91146. /** Sets a function to be executed when this scene is disposed. */
  91147. onDispose: () => void;
  91148. /**
  91149. * An event triggered before rendering the scene (right after animations and physics)
  91150. */
  91151. onBeforeRenderObservable: Observable<Scene>;
  91152. private _onBeforeRenderObserver;
  91153. /** Sets a function to be executed before rendering this scene */
  91154. beforeRender: Nullable<() => void>;
  91155. /**
  91156. * An event triggered after rendering the scene
  91157. */
  91158. onAfterRenderObservable: Observable<Scene>;
  91159. private _onAfterRenderObserver;
  91160. /** Sets a function to be executed after rendering this scene */
  91161. afterRender: Nullable<() => void>;
  91162. /**
  91163. * An event triggered before animating the scene
  91164. */
  91165. onBeforeAnimationsObservable: Observable<Scene>;
  91166. /**
  91167. * An event triggered after animations processing
  91168. */
  91169. onAfterAnimationsObservable: Observable<Scene>;
  91170. /**
  91171. * An event triggered before draw calls are ready to be sent
  91172. */
  91173. onBeforeDrawPhaseObservable: Observable<Scene>;
  91174. /**
  91175. * An event triggered after draw calls have been sent
  91176. */
  91177. onAfterDrawPhaseObservable: Observable<Scene>;
  91178. /**
  91179. * An event triggered when the scene is ready
  91180. */
  91181. onReadyObservable: Observable<Scene>;
  91182. /**
  91183. * An event triggered before rendering a camera
  91184. */
  91185. onBeforeCameraRenderObservable: Observable<Camera>;
  91186. private _onBeforeCameraRenderObserver;
  91187. /** Sets a function to be executed before rendering a camera*/
  91188. beforeCameraRender: () => void;
  91189. /**
  91190. * An event triggered after rendering a camera
  91191. */
  91192. onAfterCameraRenderObservable: Observable<Camera>;
  91193. private _onAfterCameraRenderObserver;
  91194. /** Sets a function to be executed after rendering a camera*/
  91195. afterCameraRender: () => void;
  91196. /**
  91197. * An event triggered when active meshes evaluation is about to start
  91198. */
  91199. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  91200. /**
  91201. * An event triggered when active meshes evaluation is done
  91202. */
  91203. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  91204. /**
  91205. * An event triggered when particles rendering is about to start
  91206. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  91207. */
  91208. onBeforeParticlesRenderingObservable: Observable<Scene>;
  91209. /**
  91210. * An event triggered when particles rendering is done
  91211. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  91212. */
  91213. onAfterParticlesRenderingObservable: Observable<Scene>;
  91214. /**
  91215. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  91216. */
  91217. onDataLoadedObservable: Observable<Scene>;
  91218. /**
  91219. * An event triggered when a camera is created
  91220. */
  91221. onNewCameraAddedObservable: Observable<Camera>;
  91222. /**
  91223. * An event triggered when a camera is removed
  91224. */
  91225. onCameraRemovedObservable: Observable<Camera>;
  91226. /**
  91227. * An event triggered when a light is created
  91228. */
  91229. onNewLightAddedObservable: Observable<Light>;
  91230. /**
  91231. * An event triggered when a light is removed
  91232. */
  91233. onLightRemovedObservable: Observable<Light>;
  91234. /**
  91235. * An event triggered when a geometry is created
  91236. */
  91237. onNewGeometryAddedObservable: Observable<Geometry>;
  91238. /**
  91239. * An event triggered when a geometry is removed
  91240. */
  91241. onGeometryRemovedObservable: Observable<Geometry>;
  91242. /**
  91243. * An event triggered when a transform node is created
  91244. */
  91245. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  91246. /**
  91247. * An event triggered when a transform node is removed
  91248. */
  91249. onTransformNodeRemovedObservable: Observable<TransformNode>;
  91250. /**
  91251. * An event triggered when a mesh is created
  91252. */
  91253. onNewMeshAddedObservable: Observable<AbstractMesh>;
  91254. /**
  91255. * An event triggered when a mesh is removed
  91256. */
  91257. onMeshRemovedObservable: Observable<AbstractMesh>;
  91258. /**
  91259. * An event triggered when a skeleton is created
  91260. */
  91261. onNewSkeletonAddedObservable: Observable<Skeleton>;
  91262. /**
  91263. * An event triggered when a skeleton is removed
  91264. */
  91265. onSkeletonRemovedObservable: Observable<Skeleton>;
  91266. /**
  91267. * An event triggered when a material is created
  91268. */
  91269. onNewMaterialAddedObservable: Observable<Material>;
  91270. /**
  91271. * An event triggered when a material is removed
  91272. */
  91273. onMaterialRemovedObservable: Observable<Material>;
  91274. /**
  91275. * An event triggered when a texture is created
  91276. */
  91277. onNewTextureAddedObservable: Observable<BaseTexture>;
  91278. /**
  91279. * An event triggered when a texture is removed
  91280. */
  91281. onTextureRemovedObservable: Observable<BaseTexture>;
  91282. /**
  91283. * An event triggered when render targets are about to be rendered
  91284. * Can happen multiple times per frame.
  91285. */
  91286. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  91287. /**
  91288. * An event triggered when render targets were rendered.
  91289. * Can happen multiple times per frame.
  91290. */
  91291. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  91292. /**
  91293. * An event triggered before calculating deterministic simulation step
  91294. */
  91295. onBeforeStepObservable: Observable<Scene>;
  91296. /**
  91297. * An event triggered after calculating deterministic simulation step
  91298. */
  91299. onAfterStepObservable: Observable<Scene>;
  91300. /**
  91301. * An event triggered when the activeCamera property is updated
  91302. */
  91303. onActiveCameraChanged: Observable<Scene>;
  91304. /**
  91305. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  91306. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  91307. * 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)
  91308. */
  91309. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  91310. /**
  91311. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  91312. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  91313. * 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)
  91314. */
  91315. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  91316. /**
  91317. * This Observable will when a mesh has been imported into the scene.
  91318. */
  91319. onMeshImportedObservable: Observable<AbstractMesh>;
  91320. /**
  91321. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  91322. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  91323. */
  91324. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  91325. /** @hidden */
  91326. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  91327. /**
  91328. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  91329. */
  91330. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  91331. /**
  91332. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  91333. */
  91334. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  91335. /**
  91336. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  91337. */
  91338. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  91339. private _onPointerMove;
  91340. private _onPointerDown;
  91341. private _onPointerUp;
  91342. /** Callback called when a pointer move is detected */
  91343. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  91344. /** Callback called when a pointer down is detected */
  91345. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  91346. /** Callback called when a pointer up is detected */
  91347. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  91348. /** Callback called when a pointer pick is detected */
  91349. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  91350. /**
  91351. * 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).
  91352. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  91353. */
  91354. onPrePointerObservable: Observable<PointerInfoPre>;
  91355. /**
  91356. * Observable event triggered each time an input event is received from the rendering canvas
  91357. */
  91358. onPointerObservable: Observable<PointerInfo>;
  91359. /**
  91360. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  91361. */
  91362. readonly unTranslatedPointer: Vector2;
  91363. /** The distance in pixel that you have to move to prevent some events */
  91364. static DragMovementThreshold: number;
  91365. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  91366. static LongPressDelay: number;
  91367. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  91368. static DoubleClickDelay: number;
  91369. /** If you need to check double click without raising a single click at first click, enable this flag */
  91370. static ExclusiveDoubleClickMode: boolean;
  91371. private _initClickEvent;
  91372. private _initActionManager;
  91373. private _delayedSimpleClick;
  91374. private _delayedSimpleClickTimeout;
  91375. private _previousDelayedSimpleClickTimeout;
  91376. private _meshPickProceed;
  91377. private _previousButtonPressed;
  91378. private _currentPickResult;
  91379. private _previousPickResult;
  91380. private _totalPointersPressed;
  91381. private _doubleClickOccured;
  91382. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  91383. cameraToUseForPointers: Nullable<Camera>;
  91384. private _pointerX;
  91385. private _pointerY;
  91386. private _unTranslatedPointerX;
  91387. private _unTranslatedPointerY;
  91388. private _startingPointerPosition;
  91389. private _previousStartingPointerPosition;
  91390. private _startingPointerTime;
  91391. private _previousStartingPointerTime;
  91392. private _pointerCaptures;
  91393. private _timeAccumulator;
  91394. private _currentStepId;
  91395. private _currentInternalStep;
  91396. /** @hidden */
  91397. _mirroredCameraPosition: Nullable<Vector3>;
  91398. /**
  91399. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  91400. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  91401. */
  91402. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  91403. /**
  91404. * Observable event triggered each time an keyboard event is received from the hosting window
  91405. */
  91406. onKeyboardObservable: Observable<KeyboardInfo>;
  91407. private _onKeyDown;
  91408. private _onKeyUp;
  91409. private _onCanvasFocusObserver;
  91410. private _onCanvasBlurObserver;
  91411. private _useRightHandedSystem;
  91412. /**
  91413. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  91414. */
  91415. useRightHandedSystem: boolean;
  91416. /**
  91417. * Sets the step Id used by deterministic lock step
  91418. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  91419. * @param newStepId defines the step Id
  91420. */
  91421. setStepId(newStepId: number): void;
  91422. /**
  91423. * Gets the step Id used by deterministic lock step
  91424. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  91425. * @returns the step Id
  91426. */
  91427. getStepId(): number;
  91428. /**
  91429. * Gets the internal step used by deterministic lock step
  91430. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  91431. * @returns the internal step
  91432. */
  91433. getInternalStep(): number;
  91434. private _fogEnabled;
  91435. /**
  91436. * Gets or sets a boolean indicating if fog is enabled on this scene
  91437. * @see http://doc.babylonjs.com/babylon101/environment#fog
  91438. * (Default is true)
  91439. */
  91440. fogEnabled: boolean;
  91441. private _fogMode;
  91442. /**
  91443. * Gets or sets the fog mode to use
  91444. * @see http://doc.babylonjs.com/babylon101/environment#fog
  91445. * | mode | value |
  91446. * | --- | --- |
  91447. * | FOGMODE_NONE | 0 |
  91448. * | FOGMODE_EXP | 1 |
  91449. * | FOGMODE_EXP2 | 2 |
  91450. * | FOGMODE_LINEAR | 3 |
  91451. */
  91452. fogMode: number;
  91453. /**
  91454. * Gets or sets the fog color to use
  91455. * @see http://doc.babylonjs.com/babylon101/environment#fog
  91456. * (Default is Color3(0.2, 0.2, 0.3))
  91457. */
  91458. fogColor: Color3;
  91459. /**
  91460. * Gets or sets the fog density to use
  91461. * @see http://doc.babylonjs.com/babylon101/environment#fog
  91462. * (Default is 0.1)
  91463. */
  91464. fogDensity: number;
  91465. /**
  91466. * Gets or sets the fog start distance to use
  91467. * @see http://doc.babylonjs.com/babylon101/environment#fog
  91468. * (Default is 0)
  91469. */
  91470. fogStart: number;
  91471. /**
  91472. * Gets or sets the fog end distance to use
  91473. * @see http://doc.babylonjs.com/babylon101/environment#fog
  91474. * (Default is 1000)
  91475. */
  91476. fogEnd: number;
  91477. private _shadowsEnabled;
  91478. /**
  91479. * Gets or sets a boolean indicating if shadows are enabled on this scene
  91480. */
  91481. shadowsEnabled: boolean;
  91482. private _lightsEnabled;
  91483. /**
  91484. * Gets or sets a boolean indicating if lights are enabled on this scene
  91485. */
  91486. lightsEnabled: boolean;
  91487. /** All of the active cameras added to this scene. */
  91488. activeCameras: Camera[];
  91489. /** @hidden */
  91490. _activeCamera: Nullable<Camera>;
  91491. /** Gets or sets the current active camera */
  91492. activeCamera: Nullable<Camera>;
  91493. private _defaultMaterial;
  91494. /** The default material used on meshes when no material is affected */
  91495. /** The default material used on meshes when no material is affected */
  91496. defaultMaterial: Material;
  91497. private _texturesEnabled;
  91498. /**
  91499. * Gets or sets a boolean indicating if textures are enabled on this scene
  91500. */
  91501. texturesEnabled: boolean;
  91502. /**
  91503. * Gets or sets a boolean indicating if particles are enabled on this scene
  91504. */
  91505. particlesEnabled: boolean;
  91506. /**
  91507. * Gets or sets a boolean indicating if sprites are enabled on this scene
  91508. */
  91509. spritesEnabled: boolean;
  91510. private _skeletonsEnabled;
  91511. /**
  91512. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  91513. */
  91514. skeletonsEnabled: boolean;
  91515. /**
  91516. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  91517. */
  91518. lensFlaresEnabled: boolean;
  91519. /**
  91520. * Gets or sets a boolean indicating if collisions are enabled on this scene
  91521. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  91522. */
  91523. collisionsEnabled: boolean;
  91524. private _collisionCoordinator;
  91525. /** @hidden */
  91526. readonly collisionCoordinator: ICollisionCoordinator;
  91527. /**
  91528. * Defines the gravity applied to this scene (used only for collisions)
  91529. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  91530. */
  91531. gravity: Vector3;
  91532. /**
  91533. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  91534. */
  91535. postProcessesEnabled: boolean;
  91536. /**
  91537. * The list of postprocesses added to the scene
  91538. */
  91539. postProcesses: PostProcess[];
  91540. /**
  91541. * Gets the current postprocess manager
  91542. */
  91543. postProcessManager: PostProcessManager;
  91544. /**
  91545. * Gets or sets a boolean indicating if render targets are enabled on this scene
  91546. */
  91547. renderTargetsEnabled: boolean;
  91548. /**
  91549. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  91550. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  91551. */
  91552. dumpNextRenderTargets: boolean;
  91553. /**
  91554. * The list of user defined render targets added to the scene
  91555. */
  91556. customRenderTargets: RenderTargetTexture[];
  91557. /**
  91558. * Defines if texture loading must be delayed
  91559. * If true, textures will only be loaded when they need to be rendered
  91560. */
  91561. useDelayedTextureLoading: boolean;
  91562. /**
  91563. * Gets the list of meshes imported to the scene through SceneLoader
  91564. */
  91565. importedMeshesFiles: String[];
  91566. /**
  91567. * Gets or sets a boolean indicating if probes are enabled on this scene
  91568. */
  91569. probesEnabled: boolean;
  91570. /**
  91571. * Gets or sets the current offline provider to use to store scene data
  91572. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  91573. */
  91574. offlineProvider: IOfflineProvider;
  91575. /**
  91576. * Gets or sets the action manager associated with the scene
  91577. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  91578. */
  91579. actionManager: AbstractActionManager;
  91580. private _meshesForIntersections;
  91581. /**
  91582. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  91583. */
  91584. proceduralTexturesEnabled: boolean;
  91585. private _engine;
  91586. private _totalVertices;
  91587. /** @hidden */
  91588. _activeIndices: PerfCounter;
  91589. /** @hidden */
  91590. _activeParticles: PerfCounter;
  91591. /** @hidden */
  91592. _activeBones: PerfCounter;
  91593. private _animationRatio;
  91594. /** @hidden */
  91595. _animationTimeLast: number;
  91596. /** @hidden */
  91597. _animationTime: number;
  91598. /**
  91599. * Gets or sets a general scale for animation speed
  91600. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  91601. */
  91602. animationTimeScale: number;
  91603. /** @hidden */
  91604. _cachedMaterial: Nullable<Material>;
  91605. /** @hidden */
  91606. _cachedEffect: Nullable<Effect>;
  91607. /** @hidden */
  91608. _cachedVisibility: Nullable<number>;
  91609. private _renderId;
  91610. private _frameId;
  91611. private _executeWhenReadyTimeoutId;
  91612. private _intermediateRendering;
  91613. private _viewUpdateFlag;
  91614. private _projectionUpdateFlag;
  91615. /** @hidden */
  91616. _toBeDisposed: Nullable<IDisposable>[];
  91617. private _activeRequests;
  91618. /** @hidden */
  91619. _pendingData: any[];
  91620. private _isDisposed;
  91621. /**
  91622. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  91623. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  91624. */
  91625. dispatchAllSubMeshesOfActiveMeshes: boolean;
  91626. private _activeMeshes;
  91627. private _processedMaterials;
  91628. private _renderTargets;
  91629. /** @hidden */
  91630. _activeParticleSystems: SmartArray<IParticleSystem>;
  91631. private _activeSkeletons;
  91632. private _softwareSkinnedMeshes;
  91633. private _renderingManager;
  91634. /** @hidden */
  91635. _activeAnimatables: Animatable[];
  91636. private _transformMatrix;
  91637. private _sceneUbo;
  91638. /** @hidden */
  91639. _viewMatrix: Matrix;
  91640. private _projectionMatrix;
  91641. private _wheelEventName;
  91642. /** @hidden */
  91643. _forcedViewPosition: Nullable<Vector3>;
  91644. /** @hidden */
  91645. _frustumPlanes: Plane[];
  91646. /**
  91647. * Gets the list of frustum planes (built from the active camera)
  91648. */
  91649. readonly frustumPlanes: Plane[];
  91650. /**
  91651. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  91652. * This is useful if there are more lights that the maximum simulteanous authorized
  91653. */
  91654. requireLightSorting: boolean;
  91655. /** @hidden */
  91656. readonly useMaterialMeshMap: boolean;
  91657. /** @hidden */
  91658. readonly useClonedMeshhMap: boolean;
  91659. private _pointerOverMesh;
  91660. private _pickedDownMesh;
  91661. private _pickedUpMesh;
  91662. private _externalData;
  91663. private _uid;
  91664. /**
  91665. * @hidden
  91666. * Backing store of defined scene components.
  91667. */
  91668. _components: ISceneComponent[];
  91669. /**
  91670. * @hidden
  91671. * Backing store of defined scene components.
  91672. */
  91673. _serializableComponents: ISceneSerializableComponent[];
  91674. /**
  91675. * List of components to register on the next registration step.
  91676. */
  91677. private _transientComponents;
  91678. /**
  91679. * Registers the transient components if needed.
  91680. */
  91681. private _registerTransientComponents;
  91682. /**
  91683. * @hidden
  91684. * Add a component to the scene.
  91685. * Note that the ccomponent could be registered on th next frame if this is called after
  91686. * the register component stage.
  91687. * @param component Defines the component to add to the scene
  91688. */
  91689. _addComponent(component: ISceneComponent): void;
  91690. /**
  91691. * @hidden
  91692. * Gets a component from the scene.
  91693. * @param name defines the name of the component to retrieve
  91694. * @returns the component or null if not present
  91695. */
  91696. _getComponent(name: string): Nullable<ISceneComponent>;
  91697. /**
  91698. * @hidden
  91699. * Defines the actions happening before camera updates.
  91700. */
  91701. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  91702. /**
  91703. * @hidden
  91704. * Defines the actions happening before clear the canvas.
  91705. */
  91706. _beforeClearStage: Stage<SimpleStageAction>;
  91707. /**
  91708. * @hidden
  91709. * Defines the actions when collecting render targets for the frame.
  91710. */
  91711. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  91712. /**
  91713. * @hidden
  91714. * Defines the actions happening for one camera in the frame.
  91715. */
  91716. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  91717. /**
  91718. * @hidden
  91719. * Defines the actions happening during the per mesh ready checks.
  91720. */
  91721. _isReadyForMeshStage: Stage<MeshStageAction>;
  91722. /**
  91723. * @hidden
  91724. * Defines the actions happening before evaluate active mesh checks.
  91725. */
  91726. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  91727. /**
  91728. * @hidden
  91729. * Defines the actions happening during the evaluate sub mesh checks.
  91730. */
  91731. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  91732. /**
  91733. * @hidden
  91734. * Defines the actions happening during the active mesh stage.
  91735. */
  91736. _activeMeshStage: Stage<ActiveMeshStageAction>;
  91737. /**
  91738. * @hidden
  91739. * Defines the actions happening during the per camera render target step.
  91740. */
  91741. _cameraDrawRenderTargetStage: Stage<CameraStageAction>;
  91742. /**
  91743. * @hidden
  91744. * Defines the actions happening just before the active camera is drawing.
  91745. */
  91746. _beforeCameraDrawStage: Stage<CameraStageAction>;
  91747. /**
  91748. * @hidden
  91749. * Defines the actions happening just before a render target is drawing.
  91750. */
  91751. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  91752. /**
  91753. * @hidden
  91754. * Defines the actions happening just before a rendering group is drawing.
  91755. */
  91756. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  91757. /**
  91758. * @hidden
  91759. * Defines the actions happening just before a mesh is drawing.
  91760. */
  91761. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  91762. /**
  91763. * @hidden
  91764. * Defines the actions happening just after a mesh has been drawn.
  91765. */
  91766. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  91767. /**
  91768. * @hidden
  91769. * Defines the actions happening just after a rendering group has been drawn.
  91770. */
  91771. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  91772. /**
  91773. * @hidden
  91774. * Defines the actions happening just after the active camera has been drawn.
  91775. */
  91776. _afterCameraDrawStage: Stage<CameraStageAction>;
  91777. /**
  91778. * @hidden
  91779. * Defines the actions happening just after a render target has been drawn.
  91780. */
  91781. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  91782. /**
  91783. * @hidden
  91784. * Defines the actions happening just after rendering all cameras and computing intersections.
  91785. */
  91786. _afterRenderStage: Stage<SimpleStageAction>;
  91787. /**
  91788. * @hidden
  91789. * Defines the actions happening when a pointer move event happens.
  91790. */
  91791. _pointerMoveStage: Stage<PointerMoveStageAction>;
  91792. /**
  91793. * @hidden
  91794. * Defines the actions happening when a pointer down event happens.
  91795. */
  91796. _pointerDownStage: Stage<PointerUpDownStageAction>;
  91797. /**
  91798. * @hidden
  91799. * Defines the actions happening when a pointer up event happens.
  91800. */
  91801. _pointerUpStage: Stage<PointerUpDownStageAction>;
  91802. /**
  91803. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  91804. */
  91805. private geometriesByUniqueId;
  91806. /**
  91807. * Creates a new Scene
  91808. * @param engine defines the engine to use to render this scene
  91809. * @param options defines the scene options
  91810. */
  91811. constructor(engine: Engine, options?: SceneOptions);
  91812. /**
  91813. * Gets a string idenfifying the name of the class
  91814. * @returns "Scene" string
  91815. */
  91816. getClassName(): string;
  91817. private _defaultMeshCandidates;
  91818. /**
  91819. * @hidden
  91820. */
  91821. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  91822. private _defaultSubMeshCandidates;
  91823. /**
  91824. * @hidden
  91825. */
  91826. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  91827. /**
  91828. * Sets the default candidate providers for the scene.
  91829. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  91830. * and getCollidingSubMeshCandidates to their default function
  91831. */
  91832. setDefaultCandidateProviders(): void;
  91833. /**
  91834. * Gets the mesh that is currently under the pointer
  91835. */
  91836. readonly meshUnderPointer: Nullable<AbstractMesh>;
  91837. /**
  91838. * Gets or sets the current on-screen X position of the pointer
  91839. */
  91840. pointerX: number;
  91841. /**
  91842. * Gets or sets the current on-screen Y position of the pointer
  91843. */
  91844. pointerY: number;
  91845. /**
  91846. * Gets the cached material (ie. the latest rendered one)
  91847. * @returns the cached material
  91848. */
  91849. getCachedMaterial(): Nullable<Material>;
  91850. /**
  91851. * Gets the cached effect (ie. the latest rendered one)
  91852. * @returns the cached effect
  91853. */
  91854. getCachedEffect(): Nullable<Effect>;
  91855. /**
  91856. * Gets the cached visibility state (ie. the latest rendered one)
  91857. * @returns the cached visibility state
  91858. */
  91859. getCachedVisibility(): Nullable<number>;
  91860. /**
  91861. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  91862. * @param material defines the current material
  91863. * @param effect defines the current effect
  91864. * @param visibility defines the current visibility state
  91865. * @returns true if one parameter is not cached
  91866. */
  91867. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  91868. /**
  91869. * Gets the engine associated with the scene
  91870. * @returns an Engine
  91871. */
  91872. getEngine(): Engine;
  91873. /**
  91874. * Gets the total number of vertices rendered per frame
  91875. * @returns the total number of vertices rendered per frame
  91876. */
  91877. getTotalVertices(): number;
  91878. /**
  91879. * Gets the performance counter for total vertices
  91880. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  91881. */
  91882. readonly totalVerticesPerfCounter: PerfCounter;
  91883. /**
  91884. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  91885. * @returns the total number of active indices rendered per frame
  91886. */
  91887. getActiveIndices(): number;
  91888. /**
  91889. * Gets the performance counter for active indices
  91890. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  91891. */
  91892. readonly totalActiveIndicesPerfCounter: PerfCounter;
  91893. /**
  91894. * Gets the total number of active particles rendered per frame
  91895. * @returns the total number of active particles rendered per frame
  91896. */
  91897. getActiveParticles(): number;
  91898. /**
  91899. * Gets the performance counter for active particles
  91900. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  91901. */
  91902. readonly activeParticlesPerfCounter: PerfCounter;
  91903. /**
  91904. * Gets the total number of active bones rendered per frame
  91905. * @returns the total number of active bones rendered per frame
  91906. */
  91907. getActiveBones(): number;
  91908. /**
  91909. * Gets the performance counter for active bones
  91910. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  91911. */
  91912. readonly activeBonesPerfCounter: PerfCounter;
  91913. /**
  91914. * Gets the array of active meshes
  91915. * @returns an array of AbstractMesh
  91916. */
  91917. getActiveMeshes(): SmartArray<AbstractMesh>;
  91918. /**
  91919. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  91920. * @returns a number
  91921. */
  91922. getAnimationRatio(): number;
  91923. /**
  91924. * Gets an unique Id for the current render phase
  91925. * @returns a number
  91926. */
  91927. getRenderId(): number;
  91928. /**
  91929. * Gets an unique Id for the current frame
  91930. * @returns a number
  91931. */
  91932. getFrameId(): number;
  91933. /** Call this function if you want to manually increment the render Id*/
  91934. incrementRenderId(): void;
  91935. private _updatePointerPosition;
  91936. private _createUbo;
  91937. private _setRayOnPointerInfo;
  91938. /**
  91939. * Use this method to simulate a pointer move on a mesh
  91940. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  91941. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  91942. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  91943. * @returns the current scene
  91944. */
  91945. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  91946. private _processPointerMove;
  91947. private _checkPrePointerObservable;
  91948. /**
  91949. * Use this method to simulate a pointer down on a mesh
  91950. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  91951. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  91952. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  91953. * @returns the current scene
  91954. */
  91955. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  91956. private _processPointerDown;
  91957. /**
  91958. * Use this method to simulate a pointer up on a mesh
  91959. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  91960. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  91961. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  91962. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  91963. * @returns the current scene
  91964. */
  91965. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  91966. private _processPointerUp;
  91967. /**
  91968. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  91969. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  91970. * @returns true if the pointer was captured
  91971. */
  91972. isPointerCaptured(pointerId?: number): boolean;
  91973. /** @hidden */
  91974. _isPointerSwiping(): boolean;
  91975. /**
  91976. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  91977. * @param attachUp defines if you want to attach events to pointerup
  91978. * @param attachDown defines if you want to attach events to pointerdown
  91979. * @param attachMove defines if you want to attach events to pointermove
  91980. */
  91981. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  91982. /** Detaches all event handlers*/
  91983. detachControl(): void;
  91984. /**
  91985. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  91986. * Delay loaded resources are not taking in account
  91987. * @return true if all required resources are ready
  91988. */
  91989. isReady(): boolean;
  91990. /** Resets all cached information relative to material (including effect and visibility) */
  91991. resetCachedMaterial(): void;
  91992. /**
  91993. * Registers a function to be called before every frame render
  91994. * @param func defines the function to register
  91995. */
  91996. registerBeforeRender(func: () => void): void;
  91997. /**
  91998. * Unregisters a function called before every frame render
  91999. * @param func defines the function to unregister
  92000. */
  92001. unregisterBeforeRender(func: () => void): void;
  92002. /**
  92003. * Registers a function to be called after every frame render
  92004. * @param func defines the function to register
  92005. */
  92006. registerAfterRender(func: () => void): void;
  92007. /**
  92008. * Unregisters a function called after every frame render
  92009. * @param func defines the function to unregister
  92010. */
  92011. unregisterAfterRender(func: () => void): void;
  92012. private _executeOnceBeforeRender;
  92013. /**
  92014. * The provided function will run before render once and will be disposed afterwards.
  92015. * A timeout delay can be provided so that the function will be executed in N ms.
  92016. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  92017. * @param func The function to be executed.
  92018. * @param timeout optional delay in ms
  92019. */
  92020. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  92021. /** @hidden */
  92022. _addPendingData(data: any): void;
  92023. /** @hidden */
  92024. _removePendingData(data: any): void;
  92025. /**
  92026. * Returns the number of items waiting to be loaded
  92027. * @returns the number of items waiting to be loaded
  92028. */
  92029. getWaitingItemsCount(): number;
  92030. /**
  92031. * Returns a boolean indicating if the scene is still loading data
  92032. */
  92033. readonly isLoading: boolean;
  92034. /**
  92035. * Registers a function to be executed when the scene is ready
  92036. * @param {Function} func - the function to be executed
  92037. */
  92038. executeWhenReady(func: () => void): void;
  92039. /**
  92040. * Returns a promise that resolves when the scene is ready
  92041. * @returns A promise that resolves when the scene is ready
  92042. */
  92043. whenReadyAsync(): Promise<void>;
  92044. /** @hidden */
  92045. _checkIsReady(): void;
  92046. /**
  92047. * Gets all animatable attached to the scene
  92048. */
  92049. readonly animatables: Animatable[];
  92050. /**
  92051. * Resets the last animation time frame.
  92052. * Useful to override when animations start running when loading a scene for the first time.
  92053. */
  92054. resetLastAnimationTimeFrame(): void;
  92055. /**
  92056. * Gets the current view matrix
  92057. * @returns a Matrix
  92058. */
  92059. getViewMatrix(): Matrix;
  92060. /**
  92061. * Gets the current projection matrix
  92062. * @returns a Matrix
  92063. */
  92064. getProjectionMatrix(): Matrix;
  92065. /**
  92066. * Gets the current transform matrix
  92067. * @returns a Matrix made of View * Projection
  92068. */
  92069. getTransformMatrix(): Matrix;
  92070. /**
  92071. * Sets the current transform matrix
  92072. * @param viewL defines the View matrix to use
  92073. * @param projectionL defines the Projection matrix to use
  92074. * @param viewR defines the right View matrix to use (if provided)
  92075. * @param projectionR defines the right Projection matrix to use (if provided)
  92076. */
  92077. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  92078. /**
  92079. * Gets the uniform buffer used to store scene data
  92080. * @returns a UniformBuffer
  92081. */
  92082. getSceneUniformBuffer(): UniformBuffer;
  92083. /**
  92084. * Gets an unique (relatively to the current scene) Id
  92085. * @returns an unique number for the scene
  92086. */
  92087. getUniqueId(): number;
  92088. /**
  92089. * Add a mesh to the list of scene's meshes
  92090. * @param newMesh defines the mesh to add
  92091. * @param recursive if all child meshes should also be added to the scene
  92092. */
  92093. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  92094. /**
  92095. * Remove a mesh for the list of scene's meshes
  92096. * @param toRemove defines the mesh to remove
  92097. * @param recursive if all child meshes should also be removed from the scene
  92098. * @returns the index where the mesh was in the mesh list
  92099. */
  92100. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  92101. /**
  92102. * Add a transform node to the list of scene's transform nodes
  92103. * @param newTransformNode defines the transform node to add
  92104. */
  92105. addTransformNode(newTransformNode: TransformNode): void;
  92106. /**
  92107. * Remove a transform node for the list of scene's transform nodes
  92108. * @param toRemove defines the transform node to remove
  92109. * @returns the index where the transform node was in the transform node list
  92110. */
  92111. removeTransformNode(toRemove: TransformNode): number;
  92112. /**
  92113. * Remove a skeleton for the list of scene's skeletons
  92114. * @param toRemove defines the skeleton to remove
  92115. * @returns the index where the skeleton was in the skeleton list
  92116. */
  92117. removeSkeleton(toRemove: Skeleton): number;
  92118. /**
  92119. * Remove a morph target for the list of scene's morph targets
  92120. * @param toRemove defines the morph target to remove
  92121. * @returns the index where the morph target was in the morph target list
  92122. */
  92123. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  92124. /**
  92125. * Remove a light for the list of scene's lights
  92126. * @param toRemove defines the light to remove
  92127. * @returns the index where the light was in the light list
  92128. */
  92129. removeLight(toRemove: Light): number;
  92130. /**
  92131. * Remove a camera for the list of scene's cameras
  92132. * @param toRemove defines the camera to remove
  92133. * @returns the index where the camera was in the camera list
  92134. */
  92135. removeCamera(toRemove: Camera): number;
  92136. /**
  92137. * Remove a particle system for the list of scene's particle systems
  92138. * @param toRemove defines the particle system to remove
  92139. * @returns the index where the particle system was in the particle system list
  92140. */
  92141. removeParticleSystem(toRemove: IParticleSystem): number;
  92142. /**
  92143. * Remove a animation for the list of scene's animations
  92144. * @param toRemove defines the animation to remove
  92145. * @returns the index where the animation was in the animation list
  92146. */
  92147. removeAnimation(toRemove: Animation): number;
  92148. /**
  92149. * Removes the given animation group from this scene.
  92150. * @param toRemove The animation group to remove
  92151. * @returns The index of the removed animation group
  92152. */
  92153. removeAnimationGroup(toRemove: AnimationGroup): number;
  92154. /**
  92155. * Removes the given multi-material from this scene.
  92156. * @param toRemove The multi-material to remove
  92157. * @returns The index of the removed multi-material
  92158. */
  92159. removeMultiMaterial(toRemove: MultiMaterial): number;
  92160. /**
  92161. * Removes the given material from this scene.
  92162. * @param toRemove The material to remove
  92163. * @returns The index of the removed material
  92164. */
  92165. removeMaterial(toRemove: Material): number;
  92166. /**
  92167. * Removes the given action manager from this scene.
  92168. * @param toRemove The action manager to remove
  92169. * @returns The index of the removed action manager
  92170. */
  92171. removeActionManager(toRemove: AbstractActionManager): number;
  92172. /**
  92173. * Removes the given texture from this scene.
  92174. * @param toRemove The texture to remove
  92175. * @returns The index of the removed texture
  92176. */
  92177. removeTexture(toRemove: BaseTexture): number;
  92178. /**
  92179. * Adds the given light to this scene
  92180. * @param newLight The light to add
  92181. */
  92182. addLight(newLight: Light): void;
  92183. /**
  92184. * Sorts the list list based on light priorities
  92185. */
  92186. sortLightsByPriority(): void;
  92187. /**
  92188. * Adds the given camera to this scene
  92189. * @param newCamera The camera to add
  92190. */
  92191. addCamera(newCamera: Camera): void;
  92192. /**
  92193. * Adds the given skeleton to this scene
  92194. * @param newSkeleton The skeleton to add
  92195. */
  92196. addSkeleton(newSkeleton: Skeleton): void;
  92197. /**
  92198. * Adds the given particle system to this scene
  92199. * @param newParticleSystem The particle system to add
  92200. */
  92201. addParticleSystem(newParticleSystem: IParticleSystem): void;
  92202. /**
  92203. * Adds the given animation to this scene
  92204. * @param newAnimation The animation to add
  92205. */
  92206. addAnimation(newAnimation: Animation): void;
  92207. /**
  92208. * Adds the given animation group to this scene.
  92209. * @param newAnimationGroup The animation group to add
  92210. */
  92211. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  92212. /**
  92213. * Adds the given multi-material to this scene
  92214. * @param newMultiMaterial The multi-material to add
  92215. */
  92216. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  92217. /**
  92218. * Adds the given material to this scene
  92219. * @param newMaterial The material to add
  92220. */
  92221. addMaterial(newMaterial: Material): void;
  92222. /**
  92223. * Adds the given morph target to this scene
  92224. * @param newMorphTargetManager The morph target to add
  92225. */
  92226. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  92227. /**
  92228. * Adds the given geometry to this scene
  92229. * @param newGeometry The geometry to add
  92230. */
  92231. addGeometry(newGeometry: Geometry): void;
  92232. /**
  92233. * Adds the given action manager to this scene
  92234. * @param newActionManager The action manager to add
  92235. */
  92236. addActionManager(newActionManager: AbstractActionManager): void;
  92237. /**
  92238. * Adds the given texture to this scene.
  92239. * @param newTexture The texture to add
  92240. */
  92241. addTexture(newTexture: BaseTexture): void;
  92242. /**
  92243. * Switch active camera
  92244. * @param newCamera defines the new active camera
  92245. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  92246. */
  92247. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  92248. /**
  92249. * sets the active camera of the scene using its ID
  92250. * @param id defines the camera's ID
  92251. * @return the new active camera or null if none found.
  92252. */
  92253. setActiveCameraByID(id: string): Nullable<Camera>;
  92254. /**
  92255. * sets the active camera of the scene using its name
  92256. * @param name defines the camera's name
  92257. * @returns the new active camera or null if none found.
  92258. */
  92259. setActiveCameraByName(name: string): Nullable<Camera>;
  92260. /**
  92261. * get an animation group using its name
  92262. * @param name defines the material's name
  92263. * @return the animation group or null if none found.
  92264. */
  92265. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  92266. /**
  92267. * Get a material using its unique id
  92268. * @param uniqueId defines the material's unique id
  92269. * @return the material or null if none found.
  92270. */
  92271. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  92272. /**
  92273. * get a material using its id
  92274. * @param id defines the material's ID
  92275. * @return the material or null if none found.
  92276. */
  92277. getMaterialByID(id: string): Nullable<Material>;
  92278. /**
  92279. * Gets a material using its name
  92280. * @param name defines the material's name
  92281. * @return the material or null if none found.
  92282. */
  92283. getMaterialByName(name: string): Nullable<Material>;
  92284. /**
  92285. * Gets a camera using its id
  92286. * @param id defines the id to look for
  92287. * @returns the camera or null if not found
  92288. */
  92289. getCameraByID(id: string): Nullable<Camera>;
  92290. /**
  92291. * Gets a camera using its unique id
  92292. * @param uniqueId defines the unique id to look for
  92293. * @returns the camera or null if not found
  92294. */
  92295. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  92296. /**
  92297. * Gets a camera using its name
  92298. * @param name defines the camera's name
  92299. * @return the camera or null if none found.
  92300. */
  92301. getCameraByName(name: string): Nullable<Camera>;
  92302. /**
  92303. * Gets a bone using its id
  92304. * @param id defines the bone's id
  92305. * @return the bone or null if not found
  92306. */
  92307. getBoneByID(id: string): Nullable<Bone>;
  92308. /**
  92309. * Gets a bone using its id
  92310. * @param name defines the bone's name
  92311. * @return the bone or null if not found
  92312. */
  92313. getBoneByName(name: string): Nullable<Bone>;
  92314. /**
  92315. * Gets a light node using its name
  92316. * @param name defines the the light's name
  92317. * @return the light or null if none found.
  92318. */
  92319. getLightByName(name: string): Nullable<Light>;
  92320. /**
  92321. * Gets a light node using its id
  92322. * @param id defines the light's id
  92323. * @return the light or null if none found.
  92324. */
  92325. getLightByID(id: string): Nullable<Light>;
  92326. /**
  92327. * Gets a light node using its scene-generated unique ID
  92328. * @param uniqueId defines the light's unique id
  92329. * @return the light or null if none found.
  92330. */
  92331. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  92332. /**
  92333. * Gets a particle system by id
  92334. * @param id defines the particle system id
  92335. * @return the corresponding system or null if none found
  92336. */
  92337. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  92338. /**
  92339. * Gets a geometry using its ID
  92340. * @param id defines the geometry's id
  92341. * @return the geometry or null if none found.
  92342. */
  92343. getGeometryByID(id: string): Nullable<Geometry>;
  92344. private _getGeometryByUniqueID;
  92345. /**
  92346. * Add a new geometry to this scene
  92347. * @param geometry defines the geometry to be added to the scene.
  92348. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  92349. * @return a boolean defining if the geometry was added or not
  92350. */
  92351. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  92352. /**
  92353. * Removes an existing geometry
  92354. * @param geometry defines the geometry to be removed from the scene
  92355. * @return a boolean defining if the geometry was removed or not
  92356. */
  92357. removeGeometry(geometry: Geometry): boolean;
  92358. /**
  92359. * Gets the list of geometries attached to the scene
  92360. * @returns an array of Geometry
  92361. */
  92362. getGeometries(): Geometry[];
  92363. /**
  92364. * Gets the first added mesh found of a given ID
  92365. * @param id defines the id to search for
  92366. * @return the mesh found or null if not found at all
  92367. */
  92368. getMeshByID(id: string): Nullable<AbstractMesh>;
  92369. /**
  92370. * Gets a list of meshes using their id
  92371. * @param id defines the id to search for
  92372. * @returns a list of meshes
  92373. */
  92374. getMeshesByID(id: string): Array<AbstractMesh>;
  92375. /**
  92376. * Gets the first added transform node found of a given ID
  92377. * @param id defines the id to search for
  92378. * @return the found transform node or null if not found at all.
  92379. */
  92380. getTransformNodeByID(id: string): Nullable<TransformNode>;
  92381. /**
  92382. * Gets a transform node with its auto-generated unique id
  92383. * @param uniqueId efines the unique id to search for
  92384. * @return the found transform node or null if not found at all.
  92385. */
  92386. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  92387. /**
  92388. * Gets a list of transform nodes using their id
  92389. * @param id defines the id to search for
  92390. * @returns a list of transform nodes
  92391. */
  92392. getTransformNodesByID(id: string): Array<TransformNode>;
  92393. /**
  92394. * Gets a mesh with its auto-generated unique id
  92395. * @param uniqueId defines the unique id to search for
  92396. * @return the found mesh or null if not found at all.
  92397. */
  92398. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  92399. /**
  92400. * Gets a the last added mesh using a given id
  92401. * @param id defines the id to search for
  92402. * @return the found mesh or null if not found at all.
  92403. */
  92404. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  92405. /**
  92406. * Gets a the last added node (Mesh, Camera, Light) using a given id
  92407. * @param id defines the id to search for
  92408. * @return the found node or null if not found at all
  92409. */
  92410. getLastEntryByID(id: string): Nullable<Node>;
  92411. /**
  92412. * Gets a node (Mesh, Camera, Light) using a given id
  92413. * @param id defines the id to search for
  92414. * @return the found node or null if not found at all
  92415. */
  92416. getNodeByID(id: string): Nullable<Node>;
  92417. /**
  92418. * Gets a node (Mesh, Camera, Light) using a given name
  92419. * @param name defines the name to search for
  92420. * @return the found node or null if not found at all.
  92421. */
  92422. getNodeByName(name: string): Nullable<Node>;
  92423. /**
  92424. * Gets a mesh using a given name
  92425. * @param name defines the name to search for
  92426. * @return the found mesh or null if not found at all.
  92427. */
  92428. getMeshByName(name: string): Nullable<AbstractMesh>;
  92429. /**
  92430. * Gets a transform node using a given name
  92431. * @param name defines the name to search for
  92432. * @return the found transform node or null if not found at all.
  92433. */
  92434. getTransformNodeByName(name: string): Nullable<TransformNode>;
  92435. /**
  92436. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  92437. * @param id defines the id to search for
  92438. * @return the found skeleton or null if not found at all.
  92439. */
  92440. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  92441. /**
  92442. * Gets a skeleton using a given auto generated unique id
  92443. * @param uniqueId defines the unique id to search for
  92444. * @return the found skeleton or null if not found at all.
  92445. */
  92446. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  92447. /**
  92448. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  92449. * @param id defines the id to search for
  92450. * @return the found skeleton or null if not found at all.
  92451. */
  92452. getSkeletonById(id: string): Nullable<Skeleton>;
  92453. /**
  92454. * Gets a skeleton using a given name
  92455. * @param name defines the name to search for
  92456. * @return the found skeleton or null if not found at all.
  92457. */
  92458. getSkeletonByName(name: string): Nullable<Skeleton>;
  92459. /**
  92460. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  92461. * @param id defines the id to search for
  92462. * @return the found morph target manager or null if not found at all.
  92463. */
  92464. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  92465. /**
  92466. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  92467. * @param id defines the id to search for
  92468. * @return the found morph target or null if not found at all.
  92469. */
  92470. getMorphTargetById(id: string): Nullable<MorphTarget>;
  92471. /**
  92472. * Gets a boolean indicating if the given mesh is active
  92473. * @param mesh defines the mesh to look for
  92474. * @returns true if the mesh is in the active list
  92475. */
  92476. isActiveMesh(mesh: AbstractMesh): boolean;
  92477. /**
  92478. * Return a unique id as a string which can serve as an identifier for the scene
  92479. */
  92480. readonly uid: string;
  92481. /**
  92482. * Add an externaly attached data from its key.
  92483. * This method call will fail and return false, if such key already exists.
  92484. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  92485. * @param key the unique key that identifies the data
  92486. * @param data the data object to associate to the key for this Engine instance
  92487. * @return true if no such key were already present and the data was added successfully, false otherwise
  92488. */
  92489. addExternalData<T>(key: string, data: T): boolean;
  92490. /**
  92491. * Get an externaly attached data from its key
  92492. * @param key the unique key that identifies the data
  92493. * @return the associated data, if present (can be null), or undefined if not present
  92494. */
  92495. getExternalData<T>(key: string): Nullable<T>;
  92496. /**
  92497. * Get an externaly attached data from its key, create it using a factory if it's not already present
  92498. * @param key the unique key that identifies the data
  92499. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  92500. * @return the associated data, can be null if the factory returned null.
  92501. */
  92502. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  92503. /**
  92504. * Remove an externaly attached data from the Engine instance
  92505. * @param key the unique key that identifies the data
  92506. * @return true if the data was successfully removed, false if it doesn't exist
  92507. */
  92508. removeExternalData(key: string): boolean;
  92509. private _evaluateSubMesh;
  92510. /**
  92511. * Clear the processed materials smart array preventing retention point in material dispose.
  92512. */
  92513. freeProcessedMaterials(): void;
  92514. private _preventFreeActiveMeshesAndRenderingGroups;
  92515. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  92516. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  92517. * when disposing several meshes in a row or a hierarchy of meshes.
  92518. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  92519. */
  92520. blockfreeActiveMeshesAndRenderingGroups: boolean;
  92521. /**
  92522. * Clear the active meshes smart array preventing retention point in mesh dispose.
  92523. */
  92524. freeActiveMeshes(): void;
  92525. /**
  92526. * Clear the info related to rendering groups preventing retention points during dispose.
  92527. */
  92528. freeRenderingGroups(): void;
  92529. /** @hidden */
  92530. _isInIntermediateRendering(): boolean;
  92531. /**
  92532. * Lambda returning the list of potentially active meshes.
  92533. */
  92534. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  92535. /**
  92536. * Lambda returning the list of potentially active sub meshes.
  92537. */
  92538. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  92539. /**
  92540. * Lambda returning the list of potentially intersecting sub meshes.
  92541. */
  92542. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  92543. /**
  92544. * Lambda returning the list of potentially colliding sub meshes.
  92545. */
  92546. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  92547. private _activeMeshesFrozen;
  92548. /**
  92549. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  92550. * @returns the current scene
  92551. */
  92552. freezeActiveMeshes(): Scene;
  92553. /**
  92554. * Use this function to restart evaluating active meshes on every frame
  92555. * @returns the current scene
  92556. */
  92557. unfreezeActiveMeshes(): Scene;
  92558. private _evaluateActiveMeshes;
  92559. private _activeMesh;
  92560. /**
  92561. * Update the transform matrix to update from the current active camera
  92562. * @param force defines a boolean used to force the update even if cache is up to date
  92563. */
  92564. updateTransformMatrix(force?: boolean): void;
  92565. private _bindFrameBuffer;
  92566. /** @hidden */
  92567. _allowPostProcessClearColor: boolean;
  92568. /** @hidden */
  92569. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  92570. private _processSubCameras;
  92571. private _checkIntersections;
  92572. /** @hidden */
  92573. _advancePhysicsEngineStep(step: number): void;
  92574. /**
  92575. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  92576. */
  92577. getDeterministicFrameTime: () => number;
  92578. /** @hidden */
  92579. _animate(): void;
  92580. /**
  92581. * Render the scene
  92582. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  92583. */
  92584. render(updateCameras?: boolean): void;
  92585. /**
  92586. * Freeze all materials
  92587. * A frozen material will not be updatable but should be faster to render
  92588. */
  92589. freezeMaterials(): void;
  92590. /**
  92591. * Unfreeze all materials
  92592. * A frozen material will not be updatable but should be faster to render
  92593. */
  92594. unfreezeMaterials(): void;
  92595. /**
  92596. * Releases all held ressources
  92597. */
  92598. dispose(): void;
  92599. /**
  92600. * Gets if the scene is already disposed
  92601. */
  92602. readonly isDisposed: boolean;
  92603. /**
  92604. * Call this function to reduce memory footprint of the scene.
  92605. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  92606. */
  92607. clearCachedVertexData(): void;
  92608. /**
  92609. * This function will remove the local cached buffer data from texture.
  92610. * It will save memory but will prevent the texture from being rebuilt
  92611. */
  92612. cleanCachedTextureBuffer(): void;
  92613. /**
  92614. * Get the world extend vectors with an optional filter
  92615. *
  92616. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  92617. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  92618. */
  92619. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  92620. min: Vector3;
  92621. max: Vector3;
  92622. };
  92623. /**
  92624. * Creates a ray that can be used to pick in the scene
  92625. * @param x defines the x coordinate of the origin (on-screen)
  92626. * @param y defines the y coordinate of the origin (on-screen)
  92627. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  92628. * @param camera defines the camera to use for the picking
  92629. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  92630. * @returns a Ray
  92631. */
  92632. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  92633. /**
  92634. * Creates a ray that can be used to pick in the scene
  92635. * @param x defines the x coordinate of the origin (on-screen)
  92636. * @param y defines the y coordinate of the origin (on-screen)
  92637. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  92638. * @param result defines the ray where to store the picking ray
  92639. * @param camera defines the camera to use for the picking
  92640. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  92641. * @returns the current scene
  92642. */
  92643. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  92644. /**
  92645. * Creates a ray that can be used to pick in the scene
  92646. * @param x defines the x coordinate of the origin (on-screen)
  92647. * @param y defines the y coordinate of the origin (on-screen)
  92648. * @param camera defines the camera to use for the picking
  92649. * @returns a Ray
  92650. */
  92651. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  92652. /**
  92653. * Creates a ray that can be used to pick in the scene
  92654. * @param x defines the x coordinate of the origin (on-screen)
  92655. * @param y defines the y coordinate of the origin (on-screen)
  92656. * @param result defines the ray where to store the picking ray
  92657. * @param camera defines the camera to use for the picking
  92658. * @returns the current scene
  92659. */
  92660. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  92661. /** Launch a ray to try to pick a mesh in the scene
  92662. * @param x position on screen
  92663. * @param y position on screen
  92664. * @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
  92665. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  92666. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  92667. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  92668. * @returns a PickingInfo
  92669. */
  92670. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: (p0: Vector3, p1: Vector3, p2: Vector3) => boolean): Nullable<PickingInfo>;
  92671. /** Use the given ray to pick a mesh in the scene
  92672. * @param ray The ray to use to pick meshes
  92673. * @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
  92674. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  92675. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  92676. * @returns a PickingInfo
  92677. */
  92678. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  92679. /**
  92680. * Launch a ray to try to pick a mesh in the scene
  92681. * @param x X position on screen
  92682. * @param y Y position on screen
  92683. * @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
  92684. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  92685. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  92686. * @returns an array of PickingInfo
  92687. */
  92688. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  92689. /**
  92690. * Launch a ray to try to pick a mesh in the scene
  92691. * @param ray Ray to use
  92692. * @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
  92693. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  92694. * @returns an array of PickingInfo
  92695. */
  92696. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  92697. /**
  92698. * Force the value of meshUnderPointer
  92699. * @param mesh defines the mesh to use
  92700. */
  92701. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  92702. /**
  92703. * Gets the mesh under the pointer
  92704. * @returns a Mesh or null if no mesh is under the pointer
  92705. */
  92706. getPointerOverMesh(): Nullable<AbstractMesh>;
  92707. /** @hidden */
  92708. _rebuildGeometries(): void;
  92709. /** @hidden */
  92710. _rebuildTextures(): void;
  92711. private _getByTags;
  92712. /**
  92713. * Get a list of meshes by tags
  92714. * @param tagsQuery defines the tags query to use
  92715. * @param forEach defines a predicate used to filter results
  92716. * @returns an array of Mesh
  92717. */
  92718. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  92719. /**
  92720. * Get a list of cameras by tags
  92721. * @param tagsQuery defines the tags query to use
  92722. * @param forEach defines a predicate used to filter results
  92723. * @returns an array of Camera
  92724. */
  92725. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  92726. /**
  92727. * Get a list of lights by tags
  92728. * @param tagsQuery defines the tags query to use
  92729. * @param forEach defines a predicate used to filter results
  92730. * @returns an array of Light
  92731. */
  92732. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  92733. /**
  92734. * Get a list of materials by tags
  92735. * @param tagsQuery defines the tags query to use
  92736. * @param forEach defines a predicate used to filter results
  92737. * @returns an array of Material
  92738. */
  92739. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  92740. /**
  92741. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  92742. * This allowed control for front to back rendering or reversly depending of the special needs.
  92743. *
  92744. * @param renderingGroupId The rendering group id corresponding to its index
  92745. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  92746. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  92747. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  92748. */
  92749. 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;
  92750. /**
  92751. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  92752. *
  92753. * @param renderingGroupId The rendering group id corresponding to its index
  92754. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  92755. * @param depth Automatically clears depth between groups if true and autoClear is true.
  92756. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  92757. */
  92758. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  92759. /**
  92760. * Gets the current auto clear configuration for one rendering group of the rendering
  92761. * manager.
  92762. * @param index the rendering group index to get the information for
  92763. * @returns The auto clear setup for the requested rendering group
  92764. */
  92765. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  92766. private _blockMaterialDirtyMechanism;
  92767. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  92768. blockMaterialDirtyMechanism: boolean;
  92769. /**
  92770. * Will flag all materials as dirty to trigger new shader compilation
  92771. * @param flag defines the flag used to specify which material part must be marked as dirty
  92772. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  92773. */
  92774. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  92775. /** @hidden */
  92776. _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;
  92777. /** @hidden */
  92778. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  92779. }
  92780. }
  92781. declare module BABYLON {
  92782. /**
  92783. * Set of assets to keep when moving a scene into an asset container.
  92784. */
  92785. export class KeepAssets extends AbstractScene {
  92786. }
  92787. /**
  92788. * Container with a set of assets that can be added or removed from a scene.
  92789. */
  92790. export class AssetContainer extends AbstractScene {
  92791. /**
  92792. * The scene the AssetContainer belongs to.
  92793. */
  92794. scene: Scene;
  92795. /**
  92796. * Instantiates an AssetContainer.
  92797. * @param scene The scene the AssetContainer belongs to.
  92798. */
  92799. constructor(scene: Scene);
  92800. /**
  92801. * Adds all the assets from the container to the scene.
  92802. */
  92803. addAllToScene(): void;
  92804. /**
  92805. * Removes all the assets in the container from the scene
  92806. */
  92807. removeAllFromScene(): void;
  92808. /**
  92809. * Disposes all the assets in the container
  92810. */
  92811. dispose(): void;
  92812. private _moveAssets;
  92813. /**
  92814. * Removes all the assets contained in the scene and adds them to the container.
  92815. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  92816. */
  92817. moveAllFromScene(keepAssets?: KeepAssets): void;
  92818. /**
  92819. * 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.
  92820. * @returns the root mesh
  92821. */
  92822. createRootMesh(): Mesh;
  92823. }
  92824. }
  92825. declare module BABYLON {
  92826. /**
  92827. * Defines how the parser contract is defined.
  92828. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  92829. */
  92830. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  92831. /**
  92832. * Defines how the individual parser contract is defined.
  92833. * These parser can parse an individual asset
  92834. */
  92835. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  92836. /**
  92837. * Base class of the scene acting as a container for the different elements composing a scene.
  92838. * This class is dynamically extended by the different components of the scene increasing
  92839. * flexibility and reducing coupling
  92840. */
  92841. export abstract class AbstractScene {
  92842. /**
  92843. * Stores the list of available parsers in the application.
  92844. */
  92845. private static _BabylonFileParsers;
  92846. /**
  92847. * Stores the list of available individual parsers in the application.
  92848. */
  92849. private static _IndividualBabylonFileParsers;
  92850. /**
  92851. * Adds a parser in the list of available ones
  92852. * @param name Defines the name of the parser
  92853. * @param parser Defines the parser to add
  92854. */
  92855. static AddParser(name: string, parser: BabylonFileParser): void;
  92856. /**
  92857. * Gets a general parser from the list of avaialble ones
  92858. * @param name Defines the name of the parser
  92859. * @returns the requested parser or null
  92860. */
  92861. static GetParser(name: string): Nullable<BabylonFileParser>;
  92862. /**
  92863. * Adds n individual parser in the list of available ones
  92864. * @param name Defines the name of the parser
  92865. * @param parser Defines the parser to add
  92866. */
  92867. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  92868. /**
  92869. * Gets an individual parser from the list of avaialble ones
  92870. * @param name Defines the name of the parser
  92871. * @returns the requested parser or null
  92872. */
  92873. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  92874. /**
  92875. * Parser json data and populate both a scene and its associated container object
  92876. * @param jsonData Defines the data to parse
  92877. * @param scene Defines the scene to parse the data for
  92878. * @param container Defines the container attached to the parsing sequence
  92879. * @param rootUrl Defines the root url of the data
  92880. */
  92881. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  92882. /**
  92883. * Gets the list of root nodes (ie. nodes with no parent)
  92884. */
  92885. rootNodes: Node[];
  92886. /** All of the cameras added to this scene
  92887. * @see http://doc.babylonjs.com/babylon101/cameras
  92888. */
  92889. cameras: Camera[];
  92890. /**
  92891. * All of the lights added to this scene
  92892. * @see http://doc.babylonjs.com/babylon101/lights
  92893. */
  92894. lights: Light[];
  92895. /**
  92896. * All of the (abstract) meshes added to this scene
  92897. */
  92898. meshes: AbstractMesh[];
  92899. /**
  92900. * The list of skeletons added to the scene
  92901. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  92902. */
  92903. skeletons: Skeleton[];
  92904. /**
  92905. * All of the particle systems added to this scene
  92906. * @see http://doc.babylonjs.com/babylon101/particles
  92907. */
  92908. particleSystems: IParticleSystem[];
  92909. /**
  92910. * Gets a list of Animations associated with the scene
  92911. */
  92912. animations: Animation[];
  92913. /**
  92914. * All of the animation groups added to this scene
  92915. * @see http://doc.babylonjs.com/how_to/group
  92916. */
  92917. animationGroups: AnimationGroup[];
  92918. /**
  92919. * All of the multi-materials added to this scene
  92920. * @see http://doc.babylonjs.com/how_to/multi_materials
  92921. */
  92922. multiMaterials: MultiMaterial[];
  92923. /**
  92924. * All of the materials added to this scene
  92925. * In the context of a Scene, it is not supposed to be modified manually.
  92926. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  92927. * Note also that the order of the Material wihin the array is not significant and might change.
  92928. * @see http://doc.babylonjs.com/babylon101/materials
  92929. */
  92930. materials: Material[];
  92931. /**
  92932. * The list of morph target managers added to the scene
  92933. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  92934. */
  92935. morphTargetManagers: MorphTargetManager[];
  92936. /**
  92937. * The list of geometries used in the scene.
  92938. */
  92939. geometries: Geometry[];
  92940. /**
  92941. * All of the tranform nodes added to this scene
  92942. * In the context of a Scene, it is not supposed to be modified manually.
  92943. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  92944. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  92945. * @see http://doc.babylonjs.com/how_to/transformnode
  92946. */
  92947. transformNodes: TransformNode[];
  92948. /**
  92949. * ActionManagers available on the scene.
  92950. */
  92951. actionManagers: AbstractActionManager[];
  92952. /**
  92953. * Textures to keep.
  92954. */
  92955. textures: BaseTexture[];
  92956. /**
  92957. * Environment texture for the scene
  92958. */
  92959. environmentTexture: Nullable<BaseTexture>;
  92960. }
  92961. }
  92962. declare module BABYLON {
  92963. /**
  92964. * Defines a sound that can be played in the application.
  92965. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  92966. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  92967. */
  92968. export class Sound {
  92969. /**
  92970. * The name of the sound in the scene.
  92971. */
  92972. name: string;
  92973. /**
  92974. * Does the sound autoplay once loaded.
  92975. */
  92976. autoplay: boolean;
  92977. /**
  92978. * Does the sound loop after it finishes playing once.
  92979. */
  92980. loop: boolean;
  92981. /**
  92982. * Does the sound use a custom attenuation curve to simulate the falloff
  92983. * happening when the source gets further away from the camera.
  92984. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  92985. */
  92986. useCustomAttenuation: boolean;
  92987. /**
  92988. * The sound track id this sound belongs to.
  92989. */
  92990. soundTrackId: number;
  92991. /**
  92992. * Is this sound currently played.
  92993. */
  92994. isPlaying: boolean;
  92995. /**
  92996. * Is this sound currently paused.
  92997. */
  92998. isPaused: boolean;
  92999. /**
  93000. * Does this sound enables spatial sound.
  93001. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  93002. */
  93003. spatialSound: boolean;
  93004. /**
  93005. * Define the reference distance the sound should be heard perfectly.
  93006. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  93007. */
  93008. refDistance: number;
  93009. /**
  93010. * Define the roll off factor of spatial sounds.
  93011. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  93012. */
  93013. rolloffFactor: number;
  93014. /**
  93015. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  93016. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  93017. */
  93018. maxDistance: number;
  93019. /**
  93020. * Define the distance attenuation model the sound will follow.
  93021. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  93022. */
  93023. distanceModel: string;
  93024. /**
  93025. * @hidden
  93026. * Back Compat
  93027. **/
  93028. onended: () => any;
  93029. /**
  93030. * Observable event when the current playing sound finishes.
  93031. */
  93032. onEndedObservable: Observable<Sound>;
  93033. private _panningModel;
  93034. private _playbackRate;
  93035. private _streaming;
  93036. private _startTime;
  93037. private _startOffset;
  93038. private _position;
  93039. /** @hidden */
  93040. _positionInEmitterSpace: boolean;
  93041. private _localDirection;
  93042. private _volume;
  93043. private _isReadyToPlay;
  93044. private _isDirectional;
  93045. private _readyToPlayCallback;
  93046. private _audioBuffer;
  93047. private _soundSource;
  93048. private _streamingSource;
  93049. private _soundPanner;
  93050. private _soundGain;
  93051. private _inputAudioNode;
  93052. private _outputAudioNode;
  93053. private _coneInnerAngle;
  93054. private _coneOuterAngle;
  93055. private _coneOuterGain;
  93056. private _scene;
  93057. private _connectedTransformNode;
  93058. private _customAttenuationFunction;
  93059. private _registerFunc;
  93060. private _isOutputConnected;
  93061. private _htmlAudioElement;
  93062. private _urlType;
  93063. /** @hidden */
  93064. static _SceneComponentInitialization: (scene: Scene) => void;
  93065. /**
  93066. * Create a sound and attach it to a scene
  93067. * @param name Name of your sound
  93068. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  93069. * @param scene defines the scene the sound belongs to
  93070. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  93071. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  93072. */
  93073. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  93074. /**
  93075. * Release the sound and its associated resources
  93076. */
  93077. dispose(): void;
  93078. /**
  93079. * Gets if the sounds is ready to be played or not.
  93080. * @returns true if ready, otherwise false
  93081. */
  93082. isReady(): boolean;
  93083. private _soundLoaded;
  93084. /**
  93085. * Sets the data of the sound from an audiobuffer
  93086. * @param audioBuffer The audioBuffer containing the data
  93087. */
  93088. setAudioBuffer(audioBuffer: AudioBuffer): void;
  93089. /**
  93090. * Updates the current sounds options such as maxdistance, loop...
  93091. * @param options A JSON object containing values named as the object properties
  93092. */
  93093. updateOptions(options: any): void;
  93094. private _createSpatialParameters;
  93095. private _updateSpatialParameters;
  93096. /**
  93097. * Switch the panning model to HRTF:
  93098. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  93099. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  93100. */
  93101. switchPanningModelToHRTF(): void;
  93102. /**
  93103. * Switch the panning model to Equal Power:
  93104. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  93105. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  93106. */
  93107. switchPanningModelToEqualPower(): void;
  93108. private _switchPanningModel;
  93109. /**
  93110. * Connect this sound to a sound track audio node like gain...
  93111. * @param soundTrackAudioNode the sound track audio node to connect to
  93112. */
  93113. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  93114. /**
  93115. * Transform this sound into a directional source
  93116. * @param coneInnerAngle Size of the inner cone in degree
  93117. * @param coneOuterAngle Size of the outer cone in degree
  93118. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  93119. */
  93120. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  93121. /**
  93122. * Gets or sets the inner angle for the directional cone.
  93123. */
  93124. /**
  93125. * Gets or sets the inner angle for the directional cone.
  93126. */
  93127. directionalConeInnerAngle: number;
  93128. /**
  93129. * Gets or sets the outer angle for the directional cone.
  93130. */
  93131. /**
  93132. * Gets or sets the outer angle for the directional cone.
  93133. */
  93134. directionalConeOuterAngle: number;
  93135. /**
  93136. * Sets the position of the emitter if spatial sound is enabled
  93137. * @param newPosition Defines the new posisiton
  93138. */
  93139. setPosition(newPosition: Vector3): void;
  93140. /**
  93141. * Sets the local direction of the emitter if spatial sound is enabled
  93142. * @param newLocalDirection Defines the new local direction
  93143. */
  93144. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  93145. private _updateDirection;
  93146. /** @hidden */
  93147. updateDistanceFromListener(): void;
  93148. /**
  93149. * Sets a new custom attenuation function for the sound.
  93150. * @param callback Defines the function used for the attenuation
  93151. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  93152. */
  93153. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  93154. /**
  93155. * Play the sound
  93156. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  93157. * @param offset (optional) Start the sound setting it at a specific time
  93158. */
  93159. play(time?: number, offset?: number): void;
  93160. private _onended;
  93161. /**
  93162. * Stop the sound
  93163. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  93164. */
  93165. stop(time?: number): void;
  93166. /**
  93167. * Put the sound in pause
  93168. */
  93169. pause(): void;
  93170. /**
  93171. * Sets a dedicated volume for this sounds
  93172. * @param newVolume Define the new volume of the sound
  93173. * @param time Define in how long the sound should be at this value
  93174. */
  93175. setVolume(newVolume: number, time?: number): void;
  93176. /**
  93177. * Set the sound play back rate
  93178. * @param newPlaybackRate Define the playback rate the sound should be played at
  93179. */
  93180. setPlaybackRate(newPlaybackRate: number): void;
  93181. /**
  93182. * Gets the volume of the sound.
  93183. * @returns the volume of the sound
  93184. */
  93185. getVolume(): number;
  93186. /**
  93187. * Attach the sound to a dedicated mesh
  93188. * @param transformNode The transform node to connect the sound with
  93189. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  93190. */
  93191. attachToMesh(transformNode: TransformNode): void;
  93192. /**
  93193. * Detach the sound from the previously attached mesh
  93194. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  93195. */
  93196. detachFromMesh(): void;
  93197. private _onRegisterAfterWorldMatrixUpdate;
  93198. /**
  93199. * Clone the current sound in the scene.
  93200. * @returns the new sound clone
  93201. */
  93202. clone(): Nullable<Sound>;
  93203. /**
  93204. * Gets the current underlying audio buffer containing the data
  93205. * @returns the audio buffer
  93206. */
  93207. getAudioBuffer(): Nullable<AudioBuffer>;
  93208. /**
  93209. * Serializes the Sound in a JSON representation
  93210. * @returns the JSON representation of the sound
  93211. */
  93212. serialize(): any;
  93213. /**
  93214. * Parse a JSON representation of a sound to innstantiate in a given scene
  93215. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  93216. * @param scene Define the scene the new parsed sound should be created in
  93217. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  93218. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  93219. * @returns the newly parsed sound
  93220. */
  93221. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  93222. }
  93223. }
  93224. declare module BABYLON {
  93225. /**
  93226. * This defines an action helpful to play a defined sound on a triggered action.
  93227. */
  93228. export class PlaySoundAction extends Action {
  93229. private _sound;
  93230. /**
  93231. * Instantiate the action
  93232. * @param triggerOptions defines the trigger options
  93233. * @param sound defines the sound to play
  93234. * @param condition defines the trigger related conditions
  93235. */
  93236. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  93237. /** @hidden */
  93238. _prepare(): void;
  93239. /**
  93240. * Execute the action and play the sound.
  93241. */
  93242. execute(): void;
  93243. /**
  93244. * Serializes the actions and its related information.
  93245. * @param parent defines the object to serialize in
  93246. * @returns the serialized object
  93247. */
  93248. serialize(parent: any): any;
  93249. }
  93250. /**
  93251. * This defines an action helpful to stop a defined sound on a triggered action.
  93252. */
  93253. export class StopSoundAction extends Action {
  93254. private _sound;
  93255. /**
  93256. * Instantiate the action
  93257. * @param triggerOptions defines the trigger options
  93258. * @param sound defines the sound to stop
  93259. * @param condition defines the trigger related conditions
  93260. */
  93261. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  93262. /** @hidden */
  93263. _prepare(): void;
  93264. /**
  93265. * Execute the action and stop the sound.
  93266. */
  93267. execute(): void;
  93268. /**
  93269. * Serializes the actions and its related information.
  93270. * @param parent defines the object to serialize in
  93271. * @returns the serialized object
  93272. */
  93273. serialize(parent: any): any;
  93274. }
  93275. }
  93276. declare module BABYLON {
  93277. /**
  93278. * This defines an action responsible to change the value of a property
  93279. * by interpolating between its current value and the newly set one once triggered.
  93280. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  93281. */
  93282. export class InterpolateValueAction extends Action {
  93283. /**
  93284. * Defines the path of the property where the value should be interpolated
  93285. */
  93286. propertyPath: string;
  93287. /**
  93288. * Defines the target value at the end of the interpolation.
  93289. */
  93290. value: any;
  93291. /**
  93292. * Defines the time it will take for the property to interpolate to the value.
  93293. */
  93294. duration: number;
  93295. /**
  93296. * Defines if the other scene animations should be stopped when the action has been triggered
  93297. */
  93298. stopOtherAnimations?: boolean;
  93299. /**
  93300. * Defines a callback raised once the interpolation animation has been done.
  93301. */
  93302. onInterpolationDone?: () => void;
  93303. /**
  93304. * Observable triggered once the interpolation animation has been done.
  93305. */
  93306. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  93307. private _target;
  93308. private _effectiveTarget;
  93309. private _property;
  93310. /**
  93311. * Instantiate the action
  93312. * @param triggerOptions defines the trigger options
  93313. * @param target defines the object containing the value to interpolate
  93314. * @param propertyPath defines the path to the property in the target object
  93315. * @param value defines the target value at the end of the interpolation
  93316. * @param duration deines the time it will take for the property to interpolate to the value.
  93317. * @param condition defines the trigger related conditions
  93318. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  93319. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  93320. */
  93321. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  93322. /** @hidden */
  93323. _prepare(): void;
  93324. /**
  93325. * Execute the action starts the value interpolation.
  93326. */
  93327. execute(): void;
  93328. /**
  93329. * Serializes the actions and its related information.
  93330. * @param parent defines the object to serialize in
  93331. * @returns the serialized object
  93332. */
  93333. serialize(parent: any): any;
  93334. }
  93335. }
  93336. declare module BABYLON {
  93337. /**
  93338. * Options allowed during the creation of a sound track.
  93339. */
  93340. export interface ISoundTrackOptions {
  93341. /**
  93342. * The volume the sound track should take during creation
  93343. */
  93344. volume?: number;
  93345. /**
  93346. * Define if the sound track is the main sound track of the scene
  93347. */
  93348. mainTrack?: boolean;
  93349. }
  93350. /**
  93351. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  93352. * It will be also used in a future release to apply effects on a specific track.
  93353. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  93354. */
  93355. export class SoundTrack {
  93356. /**
  93357. * The unique identifier of the sound track in the scene.
  93358. */
  93359. id: number;
  93360. /**
  93361. * The list of sounds included in the sound track.
  93362. */
  93363. soundCollection: Array<Sound>;
  93364. private _outputAudioNode;
  93365. private _scene;
  93366. private _isMainTrack;
  93367. private _connectedAnalyser;
  93368. private _options;
  93369. private _isInitialized;
  93370. /**
  93371. * Creates a new sound track.
  93372. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  93373. * @param scene Define the scene the sound track belongs to
  93374. * @param options
  93375. */
  93376. constructor(scene: Scene, options?: ISoundTrackOptions);
  93377. private _initializeSoundTrackAudioGraph;
  93378. /**
  93379. * Release the sound track and its associated resources
  93380. */
  93381. dispose(): void;
  93382. /**
  93383. * Adds a sound to this sound track
  93384. * @param sound define the cound to add
  93385. * @ignoreNaming
  93386. */
  93387. AddSound(sound: Sound): void;
  93388. /**
  93389. * Removes a sound to this sound track
  93390. * @param sound define the cound to remove
  93391. * @ignoreNaming
  93392. */
  93393. RemoveSound(sound: Sound): void;
  93394. /**
  93395. * Set a global volume for the full sound track.
  93396. * @param newVolume Define the new volume of the sound track
  93397. */
  93398. setVolume(newVolume: number): void;
  93399. /**
  93400. * Switch the panning model to HRTF:
  93401. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  93402. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  93403. */
  93404. switchPanningModelToHRTF(): void;
  93405. /**
  93406. * Switch the panning model to Equal Power:
  93407. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  93408. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  93409. */
  93410. switchPanningModelToEqualPower(): void;
  93411. /**
  93412. * Connect the sound track to an audio analyser allowing some amazing
  93413. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  93414. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  93415. * @param analyser The analyser to connect to the engine
  93416. */
  93417. connectToAnalyser(analyser: Analyser): void;
  93418. }
  93419. }
  93420. declare module BABYLON {
  93421. interface AbstractScene {
  93422. /**
  93423. * The list of sounds used in the scene.
  93424. */
  93425. sounds: Nullable<Array<Sound>>;
  93426. }
  93427. interface Scene {
  93428. /**
  93429. * @hidden
  93430. * Backing field
  93431. */
  93432. _mainSoundTrack: SoundTrack;
  93433. /**
  93434. * The main sound track played by the scene.
  93435. * It cotains your primary collection of sounds.
  93436. */
  93437. mainSoundTrack: SoundTrack;
  93438. /**
  93439. * The list of sound tracks added to the scene
  93440. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  93441. */
  93442. soundTracks: Nullable<Array<SoundTrack>>;
  93443. /**
  93444. * Gets a sound using a given name
  93445. * @param name defines the name to search for
  93446. * @return the found sound or null if not found at all.
  93447. */
  93448. getSoundByName(name: string): Nullable<Sound>;
  93449. /**
  93450. * Gets or sets if audio support is enabled
  93451. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  93452. */
  93453. audioEnabled: boolean;
  93454. /**
  93455. * Gets or sets if audio will be output to headphones
  93456. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  93457. */
  93458. headphone: boolean;
  93459. }
  93460. /**
  93461. * Defines the sound scene component responsible to manage any sounds
  93462. * in a given scene.
  93463. */
  93464. export class AudioSceneComponent implements ISceneSerializableComponent {
  93465. /**
  93466. * The component name helpfull to identify the component in the list of scene components.
  93467. */
  93468. readonly name: string;
  93469. /**
  93470. * The scene the component belongs to.
  93471. */
  93472. scene: Scene;
  93473. private _audioEnabled;
  93474. /**
  93475. * Gets whether audio is enabled or not.
  93476. * Please use related enable/disable method to switch state.
  93477. */
  93478. readonly audioEnabled: boolean;
  93479. private _headphone;
  93480. /**
  93481. * Gets whether audio is outputing to headphone or not.
  93482. * Please use the according Switch methods to change output.
  93483. */
  93484. readonly headphone: boolean;
  93485. /**
  93486. * Creates a new instance of the component for the given scene
  93487. * @param scene Defines the scene to register the component in
  93488. */
  93489. constructor(scene: Scene);
  93490. /**
  93491. * Registers the component in a given scene
  93492. */
  93493. register(): void;
  93494. /**
  93495. * Rebuilds the elements related to this component in case of
  93496. * context lost for instance.
  93497. */
  93498. rebuild(): void;
  93499. /**
  93500. * Serializes the component data to the specified json object
  93501. * @param serializationObject The object to serialize to
  93502. */
  93503. serialize(serializationObject: any): void;
  93504. /**
  93505. * Adds all the element from the container to the scene
  93506. * @param container the container holding the elements
  93507. */
  93508. addFromContainer(container: AbstractScene): void;
  93509. /**
  93510. * Removes all the elements in the container from the scene
  93511. * @param container contains the elements to remove
  93512. * @param dispose if the removed element should be disposed (default: false)
  93513. */
  93514. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  93515. /**
  93516. * Disposes the component and the associated ressources.
  93517. */
  93518. dispose(): void;
  93519. /**
  93520. * Disables audio in the associated scene.
  93521. */
  93522. disableAudio(): void;
  93523. /**
  93524. * Enables audio in the associated scene.
  93525. */
  93526. enableAudio(): void;
  93527. /**
  93528. * Switch audio to headphone output.
  93529. */
  93530. switchAudioModeForHeadphones(): void;
  93531. /**
  93532. * Switch audio to normal speakers.
  93533. */
  93534. switchAudioModeForNormalSpeakers(): void;
  93535. private _afterRender;
  93536. }
  93537. }
  93538. declare module BABYLON {
  93539. /**
  93540. * Wraps one or more Sound objects and selects one with random weight for playback.
  93541. */
  93542. export class WeightedSound {
  93543. /** When true a Sound will be selected and played when the current playing Sound completes. */
  93544. loop: boolean;
  93545. private _coneInnerAngle;
  93546. private _coneOuterAngle;
  93547. private _volume;
  93548. /** A Sound is currently playing. */
  93549. isPlaying: boolean;
  93550. /** A Sound is currently paused. */
  93551. isPaused: boolean;
  93552. private _sounds;
  93553. private _weights;
  93554. private _currentIndex?;
  93555. /**
  93556. * Creates a new WeightedSound from the list of sounds given.
  93557. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  93558. * @param sounds Array of Sounds that will be selected from.
  93559. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  93560. */
  93561. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  93562. /**
  93563. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  93564. */
  93565. /**
  93566. * The size of cone in degress for a directional sound in which there will be no attenuation.
  93567. */
  93568. directionalConeInnerAngle: number;
  93569. /**
  93570. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  93571. * Listener angles between innerAngle and outerAngle will falloff linearly.
  93572. */
  93573. /**
  93574. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  93575. * Listener angles between innerAngle and outerAngle will falloff linearly.
  93576. */
  93577. directionalConeOuterAngle: number;
  93578. /**
  93579. * Playback volume.
  93580. */
  93581. /**
  93582. * Playback volume.
  93583. */
  93584. volume: number;
  93585. private _onended;
  93586. /**
  93587. * Suspend playback
  93588. */
  93589. pause(): void;
  93590. /**
  93591. * Stop playback
  93592. */
  93593. stop(): void;
  93594. /**
  93595. * Start playback.
  93596. * @param startOffset Position the clip head at a specific time in seconds.
  93597. */
  93598. play(startOffset?: number): void;
  93599. }
  93600. }
  93601. declare module BABYLON {
  93602. /**
  93603. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  93604. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  93605. */
  93606. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  93607. /**
  93608. * Gets the name of the behavior.
  93609. */
  93610. readonly name: string;
  93611. /**
  93612. * The easing function used by animations
  93613. */
  93614. static EasingFunction: BackEase;
  93615. /**
  93616. * The easing mode used by animations
  93617. */
  93618. static EasingMode: number;
  93619. /**
  93620. * The duration of the animation, in milliseconds
  93621. */
  93622. transitionDuration: number;
  93623. /**
  93624. * Length of the distance animated by the transition when lower radius is reached
  93625. */
  93626. lowerRadiusTransitionRange: number;
  93627. /**
  93628. * Length of the distance animated by the transition when upper radius is reached
  93629. */
  93630. upperRadiusTransitionRange: number;
  93631. private _autoTransitionRange;
  93632. /**
  93633. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  93634. */
  93635. /**
  93636. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  93637. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  93638. */
  93639. autoTransitionRange: boolean;
  93640. private _attachedCamera;
  93641. private _onAfterCheckInputsObserver;
  93642. private _onMeshTargetChangedObserver;
  93643. /**
  93644. * Initializes the behavior.
  93645. */
  93646. init(): void;
  93647. /**
  93648. * Attaches the behavior to its arc rotate camera.
  93649. * @param camera Defines the camera to attach the behavior to
  93650. */
  93651. attach(camera: ArcRotateCamera): void;
  93652. /**
  93653. * Detaches the behavior from its current arc rotate camera.
  93654. */
  93655. detach(): void;
  93656. private _radiusIsAnimating;
  93657. private _radiusBounceTransition;
  93658. private _animatables;
  93659. private _cachedWheelPrecision;
  93660. /**
  93661. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  93662. * @param radiusLimit The limit to check against.
  93663. * @return Bool to indicate if at limit.
  93664. */
  93665. private _isRadiusAtLimit;
  93666. /**
  93667. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  93668. * @param radiusDelta The delta by which to animate to. Can be negative.
  93669. */
  93670. private _applyBoundRadiusAnimation;
  93671. /**
  93672. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  93673. */
  93674. protected _clearAnimationLocks(): void;
  93675. /**
  93676. * Stops and removes all animations that have been applied to the camera
  93677. */
  93678. stopAllAnimations(): void;
  93679. }
  93680. }
  93681. declare module BABYLON {
  93682. /**
  93683. * 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.
  93684. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  93685. */
  93686. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  93687. /**
  93688. * Gets the name of the behavior.
  93689. */
  93690. readonly name: string;
  93691. private _mode;
  93692. private _radiusScale;
  93693. private _positionScale;
  93694. private _defaultElevation;
  93695. private _elevationReturnTime;
  93696. private _elevationReturnWaitTime;
  93697. private _zoomStopsAnimation;
  93698. private _framingTime;
  93699. /**
  93700. * The easing function used by animations
  93701. */
  93702. static EasingFunction: ExponentialEase;
  93703. /**
  93704. * The easing mode used by animations
  93705. */
  93706. static EasingMode: number;
  93707. /**
  93708. * Sets the current mode used by the behavior
  93709. */
  93710. /**
  93711. * Gets current mode used by the behavior.
  93712. */
  93713. mode: number;
  93714. /**
  93715. * Sets the scale applied to the radius (1 by default)
  93716. */
  93717. /**
  93718. * Gets the scale applied to the radius
  93719. */
  93720. radiusScale: number;
  93721. /**
  93722. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  93723. */
  93724. /**
  93725. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  93726. */
  93727. positionScale: number;
  93728. /**
  93729. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  93730. * behaviour is triggered, in radians.
  93731. */
  93732. /**
  93733. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  93734. * behaviour is triggered, in radians.
  93735. */
  93736. defaultElevation: number;
  93737. /**
  93738. * Sets the time (in milliseconds) taken to return to the default beta position.
  93739. * Negative value indicates camera should not return to default.
  93740. */
  93741. /**
  93742. * Gets the time (in milliseconds) taken to return to the default beta position.
  93743. * Negative value indicates camera should not return to default.
  93744. */
  93745. elevationReturnTime: number;
  93746. /**
  93747. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  93748. */
  93749. /**
  93750. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  93751. */
  93752. elevationReturnWaitTime: number;
  93753. /**
  93754. * Sets the flag that indicates if user zooming should stop animation.
  93755. */
  93756. /**
  93757. * Gets the flag that indicates if user zooming should stop animation.
  93758. */
  93759. zoomStopsAnimation: boolean;
  93760. /**
  93761. * Sets the transition time when framing the mesh, in milliseconds
  93762. */
  93763. /**
  93764. * Gets the transition time when framing the mesh, in milliseconds
  93765. */
  93766. framingTime: number;
  93767. /**
  93768. * Define if the behavior should automatically change the configured
  93769. * camera limits and sensibilities.
  93770. */
  93771. autoCorrectCameraLimitsAndSensibility: boolean;
  93772. private _onPrePointerObservableObserver;
  93773. private _onAfterCheckInputsObserver;
  93774. private _onMeshTargetChangedObserver;
  93775. private _attachedCamera;
  93776. private _isPointerDown;
  93777. private _lastInteractionTime;
  93778. /**
  93779. * Initializes the behavior.
  93780. */
  93781. init(): void;
  93782. /**
  93783. * Attaches the behavior to its arc rotate camera.
  93784. * @param camera Defines the camera to attach the behavior to
  93785. */
  93786. attach(camera: ArcRotateCamera): void;
  93787. /**
  93788. * Detaches the behavior from its current arc rotate camera.
  93789. */
  93790. detach(): void;
  93791. private _animatables;
  93792. private _betaIsAnimating;
  93793. private _betaTransition;
  93794. private _radiusTransition;
  93795. private _vectorTransition;
  93796. /**
  93797. * Targets the given mesh and updates zoom level accordingly.
  93798. * @param mesh The mesh to target.
  93799. * @param radius Optional. If a cached radius position already exists, overrides default.
  93800. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  93801. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  93802. * @param onAnimationEnd Callback triggered at the end of the framing animation
  93803. */
  93804. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  93805. /**
  93806. * Targets the given mesh with its children and updates zoom level accordingly.
  93807. * @param mesh The mesh to target.
  93808. * @param radius Optional. If a cached radius position already exists, overrides default.
  93809. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  93810. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  93811. * @param onAnimationEnd Callback triggered at the end of the framing animation
  93812. */
  93813. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  93814. /**
  93815. * Targets the given meshes with their children and updates zoom level accordingly.
  93816. * @param meshes The mesh to target.
  93817. * @param radius Optional. If a cached radius position already exists, overrides default.
  93818. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  93819. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  93820. * @param onAnimationEnd Callback triggered at the end of the framing animation
  93821. */
  93822. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  93823. /**
  93824. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  93825. * @param minimumWorld Determines the smaller position of the bounding box extend
  93826. * @param maximumWorld Determines the bigger position of the bounding box extend
  93827. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  93828. * @param onAnimationEnd Callback triggered at the end of the framing animation
  93829. */
  93830. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  93831. /**
  93832. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  93833. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  93834. * frustum width.
  93835. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  93836. * to fully enclose the mesh in the viewing frustum.
  93837. */
  93838. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  93839. /**
  93840. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  93841. * is automatically returned to its default position (expected to be above ground plane).
  93842. */
  93843. private _maintainCameraAboveGround;
  93844. /**
  93845. * Returns the frustum slope based on the canvas ratio and camera FOV
  93846. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  93847. */
  93848. private _getFrustumSlope;
  93849. /**
  93850. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  93851. */
  93852. private _clearAnimationLocks;
  93853. /**
  93854. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  93855. */
  93856. private _applyUserInteraction;
  93857. /**
  93858. * Stops and removes all animations that have been applied to the camera
  93859. */
  93860. stopAllAnimations(): void;
  93861. /**
  93862. * Gets a value indicating if the user is moving the camera
  93863. */
  93864. readonly isUserIsMoving: boolean;
  93865. /**
  93866. * The camera can move all the way towards the mesh.
  93867. */
  93868. static IgnoreBoundsSizeMode: number;
  93869. /**
  93870. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  93871. */
  93872. static FitFrustumSidesMode: number;
  93873. }
  93874. }
  93875. declare module BABYLON {
  93876. /**
  93877. * Base class for Camera Pointer Inputs.
  93878. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  93879. * for example usage.
  93880. */
  93881. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  93882. /**
  93883. * Defines the camera the input is attached to.
  93884. */
  93885. abstract camera: Camera;
  93886. /**
  93887. * Whether keyboard modifier keys are pressed at time of last mouse event.
  93888. */
  93889. protected _altKey: boolean;
  93890. protected _ctrlKey: boolean;
  93891. protected _metaKey: boolean;
  93892. protected _shiftKey: boolean;
  93893. /**
  93894. * Which mouse buttons were pressed at time of last mouse event.
  93895. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  93896. */
  93897. protected _buttonsPressed: number;
  93898. /**
  93899. * Defines the buttons associated with the input to handle camera move.
  93900. */
  93901. buttons: number[];
  93902. /**
  93903. * Attach the input controls to a specific dom element to get the input from.
  93904. * @param element Defines the element the controls should be listened from
  93905. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  93906. */
  93907. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  93908. /**
  93909. * Detach the current controls from the specified dom element.
  93910. * @param element Defines the element to stop listening the inputs from
  93911. */
  93912. detachControl(element: Nullable<HTMLElement>): void;
  93913. /**
  93914. * Gets the class name of the current input.
  93915. * @returns the class name
  93916. */
  93917. getClassName(): string;
  93918. /**
  93919. * Get the friendly name associated with the input class.
  93920. * @returns the input friendly name
  93921. */
  93922. getSimpleName(): string;
  93923. /**
  93924. * Called on pointer POINTERDOUBLETAP event.
  93925. * Override this method to provide functionality on POINTERDOUBLETAP event.
  93926. */
  93927. protected onDoubleTap(type: string): void;
  93928. /**
  93929. * Called on pointer POINTERMOVE event if only a single touch is active.
  93930. * Override this method to provide functionality.
  93931. */
  93932. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  93933. /**
  93934. * Called on pointer POINTERMOVE event if multiple touches are active.
  93935. * Override this method to provide functionality.
  93936. */
  93937. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  93938. /**
  93939. * Called on JS contextmenu event.
  93940. * Override this method to provide functionality.
  93941. */
  93942. protected onContextMenu(evt: PointerEvent): void;
  93943. /**
  93944. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  93945. * press.
  93946. * Override this method to provide functionality.
  93947. */
  93948. protected onButtonDown(evt: PointerEvent): void;
  93949. /**
  93950. * Called each time a new POINTERUP event occurs. Ie, for each button
  93951. * release.
  93952. * Override this method to provide functionality.
  93953. */
  93954. protected onButtonUp(evt: PointerEvent): void;
  93955. /**
  93956. * Called when window becomes inactive.
  93957. * Override this method to provide functionality.
  93958. */
  93959. protected onLostFocus(): void;
  93960. private _pointerInput;
  93961. private _observer;
  93962. private _onLostFocus;
  93963. private pointA;
  93964. private pointB;
  93965. }
  93966. }
  93967. declare module BABYLON {
  93968. /**
  93969. * Manage the pointers inputs to control an arc rotate camera.
  93970. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  93971. */
  93972. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  93973. /**
  93974. * Defines the camera the input is attached to.
  93975. */
  93976. camera: ArcRotateCamera;
  93977. /**
  93978. * Gets the class name of the current input.
  93979. * @returns the class name
  93980. */
  93981. getClassName(): string;
  93982. /**
  93983. * Defines the buttons associated with the input to handle camera move.
  93984. */
  93985. buttons: number[];
  93986. /**
  93987. * Defines the pointer angular sensibility along the X axis or how fast is
  93988. * the camera rotating.
  93989. */
  93990. angularSensibilityX: number;
  93991. /**
  93992. * Defines the pointer angular sensibility along the Y axis or how fast is
  93993. * the camera rotating.
  93994. */
  93995. angularSensibilityY: number;
  93996. /**
  93997. * Defines the pointer pinch precision or how fast is the camera zooming.
  93998. */
  93999. pinchPrecision: number;
  94000. /**
  94001. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  94002. * from 0.
  94003. * It defines the percentage of current camera.radius to use as delta when
  94004. * pinch zoom is used.
  94005. */
  94006. pinchDeltaPercentage: number;
  94007. /**
  94008. * Defines the pointer panning sensibility or how fast is the camera moving.
  94009. */
  94010. panningSensibility: number;
  94011. /**
  94012. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  94013. */
  94014. multiTouchPanning: boolean;
  94015. /**
  94016. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  94017. * zoom (pinch) through multitouch.
  94018. */
  94019. multiTouchPanAndZoom: boolean;
  94020. /**
  94021. * Revers pinch action direction.
  94022. */
  94023. pinchInwards: boolean;
  94024. private _isPanClick;
  94025. private _twoFingerActivityCount;
  94026. private _isPinching;
  94027. /**
  94028. * Called on pointer POINTERMOVE event if only a single touch is active.
  94029. */
  94030. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  94031. /**
  94032. * Called on pointer POINTERDOUBLETAP event.
  94033. */
  94034. protected onDoubleTap(type: string): void;
  94035. /**
  94036. * Called on pointer POINTERMOVE event if multiple touches are active.
  94037. */
  94038. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  94039. /**
  94040. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  94041. * press.
  94042. */
  94043. protected onButtonDown(evt: PointerEvent): void;
  94044. /**
  94045. * Called each time a new POINTERUP event occurs. Ie, for each button
  94046. * release.
  94047. */
  94048. protected onButtonUp(evt: PointerEvent): void;
  94049. /**
  94050. * Called when window becomes inactive.
  94051. */
  94052. protected onLostFocus(): void;
  94053. }
  94054. }
  94055. declare module BABYLON {
  94056. /**
  94057. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  94058. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  94059. */
  94060. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  94061. /**
  94062. * Defines the camera the input is attached to.
  94063. */
  94064. camera: ArcRotateCamera;
  94065. /**
  94066. * Defines the list of key codes associated with the up action (increase alpha)
  94067. */
  94068. keysUp: number[];
  94069. /**
  94070. * Defines the list of key codes associated with the down action (decrease alpha)
  94071. */
  94072. keysDown: number[];
  94073. /**
  94074. * Defines the list of key codes associated with the left action (increase beta)
  94075. */
  94076. keysLeft: number[];
  94077. /**
  94078. * Defines the list of key codes associated with the right action (decrease beta)
  94079. */
  94080. keysRight: number[];
  94081. /**
  94082. * Defines the list of key codes associated with the reset action.
  94083. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  94084. */
  94085. keysReset: number[];
  94086. /**
  94087. * Defines the panning sensibility of the inputs.
  94088. * (How fast is the camera paning)
  94089. */
  94090. panningSensibility: number;
  94091. /**
  94092. * Defines the zooming sensibility of the inputs.
  94093. * (How fast is the camera zooming)
  94094. */
  94095. zoomingSensibility: number;
  94096. /**
  94097. * Defines wether maintaining the alt key down switch the movement mode from
  94098. * orientation to zoom.
  94099. */
  94100. useAltToZoom: boolean;
  94101. /**
  94102. * Rotation speed of the camera
  94103. */
  94104. angularSpeed: number;
  94105. private _keys;
  94106. private _ctrlPressed;
  94107. private _altPressed;
  94108. private _onCanvasBlurObserver;
  94109. private _onKeyboardObserver;
  94110. private _engine;
  94111. private _scene;
  94112. /**
  94113. * Attach the input controls to a specific dom element to get the input from.
  94114. * @param element Defines the element the controls should be listened from
  94115. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  94116. */
  94117. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  94118. /**
  94119. * Detach the current controls from the specified dom element.
  94120. * @param element Defines the element to stop listening the inputs from
  94121. */
  94122. detachControl(element: Nullable<HTMLElement>): void;
  94123. /**
  94124. * Update the current camera state depending on the inputs that have been used this frame.
  94125. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  94126. */
  94127. checkInputs(): void;
  94128. /**
  94129. * Gets the class name of the current intput.
  94130. * @returns the class name
  94131. */
  94132. getClassName(): string;
  94133. /**
  94134. * Get the friendly name associated with the input class.
  94135. * @returns the input friendly name
  94136. */
  94137. getSimpleName(): string;
  94138. }
  94139. }
  94140. declare module BABYLON {
  94141. /**
  94142. * Manage the mouse wheel inputs to control an arc rotate camera.
  94143. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  94144. */
  94145. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  94146. /**
  94147. * Defines the camera the input is attached to.
  94148. */
  94149. camera: ArcRotateCamera;
  94150. /**
  94151. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  94152. */
  94153. wheelPrecision: number;
  94154. /**
  94155. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  94156. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  94157. */
  94158. wheelDeltaPercentage: number;
  94159. private _wheel;
  94160. private _observer;
  94161. /**
  94162. * Attach the input controls to a specific dom element to get the input from.
  94163. * @param element Defines the element the controls should be listened from
  94164. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  94165. */
  94166. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  94167. /**
  94168. * Detach the current controls from the specified dom element.
  94169. * @param element Defines the element to stop listening the inputs from
  94170. */
  94171. detachControl(element: Nullable<HTMLElement>): void;
  94172. /**
  94173. * Gets the class name of the current intput.
  94174. * @returns the class name
  94175. */
  94176. getClassName(): string;
  94177. /**
  94178. * Get the friendly name associated with the input class.
  94179. * @returns the input friendly name
  94180. */
  94181. getSimpleName(): string;
  94182. }
  94183. }
  94184. declare module BABYLON {
  94185. /**
  94186. * Default Inputs manager for the ArcRotateCamera.
  94187. * It groups all the default supported inputs for ease of use.
  94188. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  94189. */
  94190. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  94191. /**
  94192. * Instantiates a new ArcRotateCameraInputsManager.
  94193. * @param camera Defines the camera the inputs belong to
  94194. */
  94195. constructor(camera: ArcRotateCamera);
  94196. /**
  94197. * Add mouse wheel input support to the input manager.
  94198. * @returns the current input manager
  94199. */
  94200. addMouseWheel(): ArcRotateCameraInputsManager;
  94201. /**
  94202. * Add pointers input support to the input manager.
  94203. * @returns the current input manager
  94204. */
  94205. addPointers(): ArcRotateCameraInputsManager;
  94206. /**
  94207. * Add keyboard input support to the input manager.
  94208. * @returns the current input manager
  94209. */
  94210. addKeyboard(): ArcRotateCameraInputsManager;
  94211. }
  94212. }
  94213. declare module BABYLON {
  94214. /**
  94215. * This represents an orbital type of camera.
  94216. *
  94217. * 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.
  94218. * 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.
  94219. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  94220. */
  94221. export class ArcRotateCamera extends TargetCamera {
  94222. /**
  94223. * Defines the rotation angle of the camera along the longitudinal axis.
  94224. */
  94225. alpha: number;
  94226. /**
  94227. * Defines the rotation angle of the camera along the latitudinal axis.
  94228. */
  94229. beta: number;
  94230. /**
  94231. * Defines the radius of the camera from it s target point.
  94232. */
  94233. radius: number;
  94234. protected _target: Vector3;
  94235. protected _targetHost: Nullable<AbstractMesh>;
  94236. /**
  94237. * Defines the target point of the camera.
  94238. * The camera looks towards it form the radius distance.
  94239. */
  94240. target: Vector3;
  94241. /**
  94242. * Define the current local position of the camera in the scene
  94243. */
  94244. position: Vector3;
  94245. protected _upVector: Vector3;
  94246. protected _upToYMatrix: Matrix;
  94247. protected _YToUpMatrix: Matrix;
  94248. /**
  94249. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  94250. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  94251. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  94252. */
  94253. upVector: Vector3;
  94254. /**
  94255. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  94256. */
  94257. setMatUp(): void;
  94258. /**
  94259. * Current inertia value on the longitudinal axis.
  94260. * The bigger this number the longer it will take for the camera to stop.
  94261. */
  94262. inertialAlphaOffset: number;
  94263. /**
  94264. * Current inertia value on the latitudinal axis.
  94265. * The bigger this number the longer it will take for the camera to stop.
  94266. */
  94267. inertialBetaOffset: number;
  94268. /**
  94269. * Current inertia value on the radius axis.
  94270. * The bigger this number the longer it will take for the camera to stop.
  94271. */
  94272. inertialRadiusOffset: number;
  94273. /**
  94274. * Minimum allowed angle on the longitudinal axis.
  94275. * This can help limiting how the Camera is able to move in the scene.
  94276. */
  94277. lowerAlphaLimit: Nullable<number>;
  94278. /**
  94279. * Maximum allowed angle on the longitudinal axis.
  94280. * This can help limiting how the Camera is able to move in the scene.
  94281. */
  94282. upperAlphaLimit: Nullable<number>;
  94283. /**
  94284. * Minimum allowed angle on the latitudinal axis.
  94285. * This can help limiting how the Camera is able to move in the scene.
  94286. */
  94287. lowerBetaLimit: number;
  94288. /**
  94289. * Maximum allowed angle on the latitudinal axis.
  94290. * This can help limiting how the Camera is able to move in the scene.
  94291. */
  94292. upperBetaLimit: number;
  94293. /**
  94294. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  94295. * This can help limiting how the Camera is able to move in the scene.
  94296. */
  94297. lowerRadiusLimit: Nullable<number>;
  94298. /**
  94299. * Maximum allowed distance of the camera to the target (The camera can not get further).
  94300. * This can help limiting how the Camera is able to move in the scene.
  94301. */
  94302. upperRadiusLimit: Nullable<number>;
  94303. /**
  94304. * Defines the current inertia value used during panning of the camera along the X axis.
  94305. */
  94306. inertialPanningX: number;
  94307. /**
  94308. * Defines the current inertia value used during panning of the camera along the Y axis.
  94309. */
  94310. inertialPanningY: number;
  94311. /**
  94312. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  94313. * Basically if your fingers moves away from more than this distance you will be considered
  94314. * in pinch mode.
  94315. */
  94316. pinchToPanMaxDistance: number;
  94317. /**
  94318. * Defines the maximum distance the camera can pan.
  94319. * This could help keeping the cammera always in your scene.
  94320. */
  94321. panningDistanceLimit: Nullable<number>;
  94322. /**
  94323. * Defines the target of the camera before paning.
  94324. */
  94325. panningOriginTarget: Vector3;
  94326. /**
  94327. * Defines the value of the inertia used during panning.
  94328. * 0 would mean stop inertia and one would mean no decelleration at all.
  94329. */
  94330. panningInertia: number;
  94331. /**
  94332. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  94333. */
  94334. angularSensibilityX: number;
  94335. /**
  94336. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  94337. */
  94338. angularSensibilityY: number;
  94339. /**
  94340. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  94341. */
  94342. pinchPrecision: number;
  94343. /**
  94344. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  94345. * It will be used instead of pinchDeltaPrecision if different from 0.
  94346. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  94347. */
  94348. pinchDeltaPercentage: number;
  94349. /**
  94350. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  94351. */
  94352. panningSensibility: number;
  94353. /**
  94354. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  94355. */
  94356. keysUp: number[];
  94357. /**
  94358. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  94359. */
  94360. keysDown: number[];
  94361. /**
  94362. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  94363. */
  94364. keysLeft: number[];
  94365. /**
  94366. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  94367. */
  94368. keysRight: number[];
  94369. /**
  94370. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  94371. */
  94372. wheelPrecision: number;
  94373. /**
  94374. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  94375. * It will be used instead of pinchDeltaPrecision if different from 0.
  94376. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  94377. */
  94378. wheelDeltaPercentage: number;
  94379. /**
  94380. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  94381. */
  94382. zoomOnFactor: number;
  94383. /**
  94384. * Defines a screen offset for the camera position.
  94385. */
  94386. targetScreenOffset: Vector2;
  94387. /**
  94388. * Allows the camera to be completely reversed.
  94389. * If false the camera can not arrive upside down.
  94390. */
  94391. allowUpsideDown: boolean;
  94392. /**
  94393. * Define if double tap/click is used to restore the previously saved state of the camera.
  94394. */
  94395. useInputToRestoreState: boolean;
  94396. /** @hidden */
  94397. _viewMatrix: Matrix;
  94398. /** @hidden */
  94399. _useCtrlForPanning: boolean;
  94400. /** @hidden */
  94401. _panningMouseButton: number;
  94402. /**
  94403. * Defines the input associated to the camera.
  94404. */
  94405. inputs: ArcRotateCameraInputsManager;
  94406. /** @hidden */
  94407. _reset: () => void;
  94408. /**
  94409. * Defines the allowed panning axis.
  94410. */
  94411. panningAxis: Vector3;
  94412. protected _localDirection: Vector3;
  94413. protected _transformedDirection: Vector3;
  94414. private _bouncingBehavior;
  94415. /**
  94416. * Gets the bouncing behavior of the camera if it has been enabled.
  94417. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  94418. */
  94419. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  94420. /**
  94421. * Defines if the bouncing behavior of the camera is enabled on the camera.
  94422. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  94423. */
  94424. useBouncingBehavior: boolean;
  94425. private _framingBehavior;
  94426. /**
  94427. * Gets the framing behavior of the camera if it has been enabled.
  94428. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  94429. */
  94430. readonly framingBehavior: Nullable<FramingBehavior>;
  94431. /**
  94432. * Defines if the framing behavior of the camera is enabled on the camera.
  94433. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  94434. */
  94435. useFramingBehavior: boolean;
  94436. private _autoRotationBehavior;
  94437. /**
  94438. * Gets the auto rotation behavior of the camera if it has been enabled.
  94439. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  94440. */
  94441. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  94442. /**
  94443. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  94444. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  94445. */
  94446. useAutoRotationBehavior: boolean;
  94447. /**
  94448. * Observable triggered when the mesh target has been changed on the camera.
  94449. */
  94450. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  94451. /**
  94452. * Event raised when the camera is colliding with a mesh.
  94453. */
  94454. onCollide: (collidedMesh: AbstractMesh) => void;
  94455. /**
  94456. * Defines whether the camera should check collision with the objects oh the scene.
  94457. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  94458. */
  94459. checkCollisions: boolean;
  94460. /**
  94461. * Defines the collision radius of the camera.
  94462. * This simulates a sphere around the camera.
  94463. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  94464. */
  94465. collisionRadius: Vector3;
  94466. protected _collider: Collider;
  94467. protected _previousPosition: Vector3;
  94468. protected _collisionVelocity: Vector3;
  94469. protected _newPosition: Vector3;
  94470. protected _previousAlpha: number;
  94471. protected _previousBeta: number;
  94472. protected _previousRadius: number;
  94473. protected _collisionTriggered: boolean;
  94474. protected _targetBoundingCenter: Nullable<Vector3>;
  94475. private _computationVector;
  94476. /**
  94477. * Instantiates a new ArcRotateCamera in a given scene
  94478. * @param name Defines the name of the camera
  94479. * @param alpha Defines the camera rotation along the logitudinal axis
  94480. * @param beta Defines the camera rotation along the latitudinal axis
  94481. * @param radius Defines the camera distance from its target
  94482. * @param target Defines the camera target
  94483. * @param scene Defines the scene the camera belongs to
  94484. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  94485. */
  94486. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  94487. /** @hidden */
  94488. _initCache(): void;
  94489. /** @hidden */
  94490. _updateCache(ignoreParentClass?: boolean): void;
  94491. protected _getTargetPosition(): Vector3;
  94492. private _storedAlpha;
  94493. private _storedBeta;
  94494. private _storedRadius;
  94495. private _storedTarget;
  94496. /**
  94497. * Stores the current state of the camera (alpha, beta, radius and target)
  94498. * @returns the camera itself
  94499. */
  94500. storeState(): Camera;
  94501. /**
  94502. * @hidden
  94503. * Restored camera state. You must call storeState() first
  94504. */
  94505. _restoreStateValues(): boolean;
  94506. /** @hidden */
  94507. _isSynchronizedViewMatrix(): boolean;
  94508. /**
  94509. * Attached controls to the current camera.
  94510. * @param element Defines the element the controls should be listened from
  94511. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  94512. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  94513. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  94514. */
  94515. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  94516. /**
  94517. * Detach the current controls from the camera.
  94518. * The camera will stop reacting to inputs.
  94519. * @param element Defines the element to stop listening the inputs from
  94520. */
  94521. detachControl(element: HTMLElement): void;
  94522. /** @hidden */
  94523. _checkInputs(): void;
  94524. protected _checkLimits(): void;
  94525. /**
  94526. * Rebuilds angles (alpha, beta) and radius from the give position and target
  94527. */
  94528. rebuildAnglesAndRadius(): void;
  94529. /**
  94530. * Use a position to define the current camera related information like aplha, beta and radius
  94531. * @param position Defines the position to set the camera at
  94532. */
  94533. setPosition(position: Vector3): void;
  94534. /**
  94535. * Defines the target the camera should look at.
  94536. * This will automatically adapt alpha beta and radius to fit within the new target.
  94537. * @param target Defines the new target as a Vector or a mesh
  94538. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  94539. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  94540. */
  94541. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  94542. /** @hidden */
  94543. _getViewMatrix(): Matrix;
  94544. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  94545. /**
  94546. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  94547. * @param meshes Defines the mesh to zoom on
  94548. * @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)
  94549. */
  94550. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  94551. /**
  94552. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  94553. * The target will be changed but the radius
  94554. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  94555. * @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)
  94556. */
  94557. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  94558. min: Vector3;
  94559. max: Vector3;
  94560. distance: number;
  94561. }, doNotUpdateMaxZ?: boolean): void;
  94562. /**
  94563. * @override
  94564. * Override Camera.createRigCamera
  94565. */
  94566. createRigCamera(name: string, cameraIndex: number): Camera;
  94567. /**
  94568. * @hidden
  94569. * @override
  94570. * Override Camera._updateRigCameras
  94571. */
  94572. _updateRigCameras(): void;
  94573. /**
  94574. * Destroy the camera and release the current resources hold by it.
  94575. */
  94576. dispose(): void;
  94577. /**
  94578. * Gets the current object class name.
  94579. * @return the class name
  94580. */
  94581. getClassName(): string;
  94582. }
  94583. }
  94584. declare module BABYLON {
  94585. /**
  94586. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  94587. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  94588. */
  94589. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  94590. /**
  94591. * Gets the name of the behavior.
  94592. */
  94593. readonly name: string;
  94594. private _zoomStopsAnimation;
  94595. private _idleRotationSpeed;
  94596. private _idleRotationWaitTime;
  94597. private _idleRotationSpinupTime;
  94598. /**
  94599. * Sets the flag that indicates if user zooming should stop animation.
  94600. */
  94601. /**
  94602. * Gets the flag that indicates if user zooming should stop animation.
  94603. */
  94604. zoomStopsAnimation: boolean;
  94605. /**
  94606. * Sets the default speed at which the camera rotates around the model.
  94607. */
  94608. /**
  94609. * Gets the default speed at which the camera rotates around the model.
  94610. */
  94611. idleRotationSpeed: number;
  94612. /**
  94613. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  94614. */
  94615. /**
  94616. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  94617. */
  94618. idleRotationWaitTime: number;
  94619. /**
  94620. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  94621. */
  94622. /**
  94623. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  94624. */
  94625. idleRotationSpinupTime: number;
  94626. /**
  94627. * Gets a value indicating if the camera is currently rotating because of this behavior
  94628. */
  94629. readonly rotationInProgress: boolean;
  94630. private _onPrePointerObservableObserver;
  94631. private _onAfterCheckInputsObserver;
  94632. private _attachedCamera;
  94633. private _isPointerDown;
  94634. private _lastFrameTime;
  94635. private _lastInteractionTime;
  94636. private _cameraRotationSpeed;
  94637. /**
  94638. * Initializes the behavior.
  94639. */
  94640. init(): void;
  94641. /**
  94642. * Attaches the behavior to its arc rotate camera.
  94643. * @param camera Defines the camera to attach the behavior to
  94644. */
  94645. attach(camera: ArcRotateCamera): void;
  94646. /**
  94647. * Detaches the behavior from its current arc rotate camera.
  94648. */
  94649. detach(): void;
  94650. /**
  94651. * Returns true if user is scrolling.
  94652. * @return true if user is scrolling.
  94653. */
  94654. private _userIsZooming;
  94655. private _lastFrameRadius;
  94656. private _shouldAnimationStopForInteraction;
  94657. /**
  94658. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  94659. */
  94660. private _applyUserInteraction;
  94661. private _userIsMoving;
  94662. }
  94663. }
  94664. declare module BABYLON {
  94665. /**
  94666. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  94667. */
  94668. export class AttachToBoxBehavior implements Behavior<Mesh> {
  94669. private ui;
  94670. /**
  94671. * The name of the behavior
  94672. */
  94673. name: string;
  94674. /**
  94675. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  94676. */
  94677. distanceAwayFromFace: number;
  94678. /**
  94679. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  94680. */
  94681. distanceAwayFromBottomOfFace: number;
  94682. private _faceVectors;
  94683. private _target;
  94684. private _scene;
  94685. private _onRenderObserver;
  94686. private _tmpMatrix;
  94687. private _tmpVector;
  94688. /**
  94689. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  94690. * @param ui The transform node that should be attched to the mesh
  94691. */
  94692. constructor(ui: TransformNode);
  94693. /**
  94694. * Initializes the behavior
  94695. */
  94696. init(): void;
  94697. private _closestFace;
  94698. private _zeroVector;
  94699. private _lookAtTmpMatrix;
  94700. private _lookAtToRef;
  94701. /**
  94702. * Attaches the AttachToBoxBehavior to the passed in mesh
  94703. * @param target The mesh that the specified node will be attached to
  94704. */
  94705. attach(target: Mesh): void;
  94706. /**
  94707. * Detaches the behavior from the mesh
  94708. */
  94709. detach(): void;
  94710. }
  94711. }
  94712. declare module BABYLON {
  94713. /**
  94714. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  94715. */
  94716. export class FadeInOutBehavior implements Behavior<Mesh> {
  94717. /**
  94718. * Time in milliseconds to delay before fading in (Default: 0)
  94719. */
  94720. delay: number;
  94721. /**
  94722. * Time in milliseconds for the mesh to fade in (Default: 300)
  94723. */
  94724. fadeInTime: number;
  94725. private _millisecondsPerFrame;
  94726. private _hovered;
  94727. private _hoverValue;
  94728. private _ownerNode;
  94729. /**
  94730. * Instatiates the FadeInOutBehavior
  94731. */
  94732. constructor();
  94733. /**
  94734. * The name of the behavior
  94735. */
  94736. readonly name: string;
  94737. /**
  94738. * Initializes the behavior
  94739. */
  94740. init(): void;
  94741. /**
  94742. * Attaches the fade behavior on the passed in mesh
  94743. * @param ownerNode The mesh that will be faded in/out once attached
  94744. */
  94745. attach(ownerNode: Mesh): void;
  94746. /**
  94747. * Detaches the behavior from the mesh
  94748. */
  94749. detach(): void;
  94750. /**
  94751. * Triggers the mesh to begin fading in or out
  94752. * @param value if the object should fade in or out (true to fade in)
  94753. */
  94754. fadeIn(value: boolean): void;
  94755. private _update;
  94756. private _setAllVisibility;
  94757. }
  94758. }
  94759. declare module BABYLON {
  94760. /**
  94761. * Class containing a set of static utilities functions for managing Pivots
  94762. * @hidden
  94763. */
  94764. export class PivotTools {
  94765. private static _PivotCached;
  94766. private static _OldPivotPoint;
  94767. private static _PivotTranslation;
  94768. private static _PivotTmpVector;
  94769. /** @hidden */
  94770. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  94771. /** @hidden */
  94772. static _RestorePivotPoint(mesh: AbstractMesh): void;
  94773. }
  94774. }
  94775. declare module BABYLON {
  94776. /**
  94777. * Class containing static functions to help procedurally build meshes
  94778. */
  94779. export class PlaneBuilder {
  94780. /**
  94781. * Creates a plane mesh
  94782. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  94783. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  94784. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  94785. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  94786. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  94787. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  94788. * @param name defines the name of the mesh
  94789. * @param options defines the options used to create the mesh
  94790. * @param scene defines the hosting scene
  94791. * @returns the plane mesh
  94792. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  94793. */
  94794. static CreatePlane(name: string, options: {
  94795. size?: number;
  94796. width?: number;
  94797. height?: number;
  94798. sideOrientation?: number;
  94799. frontUVs?: Vector4;
  94800. backUVs?: Vector4;
  94801. updatable?: boolean;
  94802. sourcePlane?: Plane;
  94803. }, scene?: Nullable<Scene>): Mesh;
  94804. }
  94805. }
  94806. declare module BABYLON {
  94807. /**
  94808. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  94809. */
  94810. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  94811. private static _AnyMouseID;
  94812. private _attachedNode;
  94813. private _dragPlane;
  94814. private _scene;
  94815. private _pointerObserver;
  94816. private _beforeRenderObserver;
  94817. private static _planeScene;
  94818. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  94819. /**
  94820. * 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)
  94821. */
  94822. maxDragAngle: number;
  94823. /**
  94824. * @hidden
  94825. */
  94826. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  94827. /**
  94828. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  94829. */
  94830. currentDraggingPointerID: number;
  94831. /**
  94832. * The last position where the pointer hit the drag plane in world space
  94833. */
  94834. lastDragPosition: Vector3;
  94835. /**
  94836. * If the behavior is currently in a dragging state
  94837. */
  94838. dragging: boolean;
  94839. /**
  94840. * 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)
  94841. */
  94842. dragDeltaRatio: number;
  94843. /**
  94844. * If the drag plane orientation should be updated during the dragging (Default: true)
  94845. */
  94846. updateDragPlane: boolean;
  94847. private _debugMode;
  94848. private _moving;
  94849. /**
  94850. * Fires each time the attached mesh is dragged with the pointer
  94851. * * delta between last drag position and current drag position in world space
  94852. * * dragDistance along the drag axis
  94853. * * dragPlaneNormal normal of the current drag plane used during the drag
  94854. * * dragPlanePoint in world space where the drag intersects the drag plane
  94855. */
  94856. onDragObservable: Observable<{
  94857. delta: Vector3;
  94858. dragPlanePoint: Vector3;
  94859. dragPlaneNormal: Vector3;
  94860. dragDistance: number;
  94861. pointerId: number;
  94862. }>;
  94863. /**
  94864. * Fires each time a drag begins (eg. mouse down on mesh)
  94865. */
  94866. onDragStartObservable: Observable<{
  94867. dragPlanePoint: Vector3;
  94868. pointerId: number;
  94869. }>;
  94870. /**
  94871. * Fires each time a drag ends (eg. mouse release after drag)
  94872. */
  94873. onDragEndObservable: Observable<{
  94874. dragPlanePoint: Vector3;
  94875. pointerId: number;
  94876. }>;
  94877. /**
  94878. * If the attached mesh should be moved when dragged
  94879. */
  94880. moveAttached: boolean;
  94881. /**
  94882. * If the drag behavior will react to drag events (Default: true)
  94883. */
  94884. enabled: boolean;
  94885. /**
  94886. * If camera controls should be detached during the drag
  94887. */
  94888. detachCameraControls: boolean;
  94889. /**
  94890. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  94891. */
  94892. useObjectOrienationForDragging: boolean;
  94893. private _options;
  94894. /**
  94895. * Creates a pointer drag behavior that can be attached to a mesh
  94896. * @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)
  94897. */
  94898. constructor(options?: {
  94899. dragAxis?: Vector3;
  94900. dragPlaneNormal?: Vector3;
  94901. });
  94902. /**
  94903. * Predicate to determine if it is valid to move the object to a new position when it is moved
  94904. */
  94905. validateDrag: (targetPosition: Vector3) => boolean;
  94906. /**
  94907. * The name of the behavior
  94908. */
  94909. readonly name: string;
  94910. /**
  94911. * Initializes the behavior
  94912. */
  94913. init(): void;
  94914. private _tmpVector;
  94915. private _alternatePickedPoint;
  94916. private _worldDragAxis;
  94917. private _targetPosition;
  94918. private _attachedElement;
  94919. /**
  94920. * Attaches the drag behavior the passed in mesh
  94921. * @param ownerNode The mesh that will be dragged around once attached
  94922. */
  94923. attach(ownerNode: AbstractMesh): void;
  94924. /**
  94925. * Force relase the drag action by code.
  94926. */
  94927. releaseDrag(): void;
  94928. private _startDragRay;
  94929. private _lastPointerRay;
  94930. /**
  94931. * Simulates the start of a pointer drag event on the behavior
  94932. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  94933. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  94934. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  94935. */
  94936. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  94937. private _startDrag;
  94938. private _dragDelta;
  94939. private _moveDrag;
  94940. private _pickWithRayOnDragPlane;
  94941. private _pointA;
  94942. private _pointB;
  94943. private _pointC;
  94944. private _lineA;
  94945. private _lineB;
  94946. private _localAxis;
  94947. private _lookAt;
  94948. private _updateDragPlanePosition;
  94949. /**
  94950. * Detaches the behavior from the mesh
  94951. */
  94952. detach(): void;
  94953. }
  94954. }
  94955. declare module BABYLON {
  94956. /**
  94957. * A behavior that when attached to a mesh will allow the mesh to be scaled
  94958. */
  94959. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  94960. private _dragBehaviorA;
  94961. private _dragBehaviorB;
  94962. private _startDistance;
  94963. private _initialScale;
  94964. private _targetScale;
  94965. private _ownerNode;
  94966. private _sceneRenderObserver;
  94967. /**
  94968. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  94969. */
  94970. constructor();
  94971. /**
  94972. * The name of the behavior
  94973. */
  94974. readonly name: string;
  94975. /**
  94976. * Initializes the behavior
  94977. */
  94978. init(): void;
  94979. private _getCurrentDistance;
  94980. /**
  94981. * Attaches the scale behavior the passed in mesh
  94982. * @param ownerNode The mesh that will be scaled around once attached
  94983. */
  94984. attach(ownerNode: Mesh): void;
  94985. /**
  94986. * Detaches the behavior from the mesh
  94987. */
  94988. detach(): void;
  94989. }
  94990. }
  94991. declare module BABYLON {
  94992. /**
  94993. * 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
  94994. */
  94995. export class SixDofDragBehavior implements Behavior<Mesh> {
  94996. private static _virtualScene;
  94997. private _ownerNode;
  94998. private _sceneRenderObserver;
  94999. private _scene;
  95000. private _targetPosition;
  95001. private _virtualOriginMesh;
  95002. private _virtualDragMesh;
  95003. private _pointerObserver;
  95004. private _moving;
  95005. private _startingOrientation;
  95006. /**
  95007. * 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)
  95008. */
  95009. private zDragFactor;
  95010. /**
  95011. * If the object should rotate to face the drag origin
  95012. */
  95013. rotateDraggedObject: boolean;
  95014. /**
  95015. * If the behavior is currently in a dragging state
  95016. */
  95017. dragging: boolean;
  95018. /**
  95019. * 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)
  95020. */
  95021. dragDeltaRatio: number;
  95022. /**
  95023. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  95024. */
  95025. currentDraggingPointerID: number;
  95026. /**
  95027. * If camera controls should be detached during the drag
  95028. */
  95029. detachCameraControls: boolean;
  95030. /**
  95031. * Fires each time a drag starts
  95032. */
  95033. onDragStartObservable: Observable<{}>;
  95034. /**
  95035. * Fires each time a drag ends (eg. mouse release after drag)
  95036. */
  95037. onDragEndObservable: Observable<{}>;
  95038. /**
  95039. * 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
  95040. */
  95041. constructor();
  95042. /**
  95043. * The name of the behavior
  95044. */
  95045. readonly name: string;
  95046. /**
  95047. * Initializes the behavior
  95048. */
  95049. init(): void;
  95050. /**
  95051. * Attaches the scale behavior the passed in mesh
  95052. * @param ownerNode The mesh that will be scaled around once attached
  95053. */
  95054. attach(ownerNode: Mesh): void;
  95055. /**
  95056. * Detaches the behavior from the mesh
  95057. */
  95058. detach(): void;
  95059. }
  95060. }
  95061. declare module BABYLON {
  95062. /**
  95063. * Class used to apply inverse kinematics to bones
  95064. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  95065. */
  95066. export class BoneIKController {
  95067. private static _tmpVecs;
  95068. private static _tmpQuat;
  95069. private static _tmpMats;
  95070. /**
  95071. * Gets or sets the target mesh
  95072. */
  95073. targetMesh: AbstractMesh;
  95074. /** Gets or sets the mesh used as pole */
  95075. poleTargetMesh: AbstractMesh;
  95076. /**
  95077. * Gets or sets the bone used as pole
  95078. */
  95079. poleTargetBone: Nullable<Bone>;
  95080. /**
  95081. * Gets or sets the target position
  95082. */
  95083. targetPosition: Vector3;
  95084. /**
  95085. * Gets or sets the pole target position
  95086. */
  95087. poleTargetPosition: Vector3;
  95088. /**
  95089. * Gets or sets the pole target local offset
  95090. */
  95091. poleTargetLocalOffset: Vector3;
  95092. /**
  95093. * Gets or sets the pole angle
  95094. */
  95095. poleAngle: number;
  95096. /**
  95097. * Gets or sets the mesh associated with the controller
  95098. */
  95099. mesh: AbstractMesh;
  95100. /**
  95101. * 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)
  95102. */
  95103. slerpAmount: number;
  95104. private _bone1Quat;
  95105. private _bone1Mat;
  95106. private _bone2Ang;
  95107. private _bone1;
  95108. private _bone2;
  95109. private _bone1Length;
  95110. private _bone2Length;
  95111. private _maxAngle;
  95112. private _maxReach;
  95113. private _rightHandedSystem;
  95114. private _bendAxis;
  95115. private _slerping;
  95116. private _adjustRoll;
  95117. /**
  95118. * Gets or sets maximum allowed angle
  95119. */
  95120. maxAngle: number;
  95121. /**
  95122. * Creates a new BoneIKController
  95123. * @param mesh defines the mesh to control
  95124. * @param bone defines the bone to control
  95125. * @param options defines options to set up the controller
  95126. */
  95127. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  95128. targetMesh?: AbstractMesh;
  95129. poleTargetMesh?: AbstractMesh;
  95130. poleTargetBone?: Bone;
  95131. poleTargetLocalOffset?: Vector3;
  95132. poleAngle?: number;
  95133. bendAxis?: Vector3;
  95134. maxAngle?: number;
  95135. slerpAmount?: number;
  95136. });
  95137. private _setMaxAngle;
  95138. /**
  95139. * Force the controller to update the bones
  95140. */
  95141. update(): void;
  95142. }
  95143. }
  95144. declare module BABYLON {
  95145. /**
  95146. * Class used to make a bone look toward a point in space
  95147. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  95148. */
  95149. export class BoneLookController {
  95150. private static _tmpVecs;
  95151. private static _tmpQuat;
  95152. private static _tmpMats;
  95153. /**
  95154. * The target Vector3 that the bone will look at
  95155. */
  95156. target: Vector3;
  95157. /**
  95158. * The mesh that the bone is attached to
  95159. */
  95160. mesh: AbstractMesh;
  95161. /**
  95162. * The bone that will be looking to the target
  95163. */
  95164. bone: Bone;
  95165. /**
  95166. * The up axis of the coordinate system that is used when the bone is rotated
  95167. */
  95168. upAxis: Vector3;
  95169. /**
  95170. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  95171. */
  95172. upAxisSpace: Space;
  95173. /**
  95174. * Used to make an adjustment to the yaw of the bone
  95175. */
  95176. adjustYaw: number;
  95177. /**
  95178. * Used to make an adjustment to the pitch of the bone
  95179. */
  95180. adjustPitch: number;
  95181. /**
  95182. * Used to make an adjustment to the roll of the bone
  95183. */
  95184. adjustRoll: number;
  95185. /**
  95186. * 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)
  95187. */
  95188. slerpAmount: number;
  95189. private _minYaw;
  95190. private _maxYaw;
  95191. private _minPitch;
  95192. private _maxPitch;
  95193. private _minYawSin;
  95194. private _minYawCos;
  95195. private _maxYawSin;
  95196. private _maxYawCos;
  95197. private _midYawConstraint;
  95198. private _minPitchTan;
  95199. private _maxPitchTan;
  95200. private _boneQuat;
  95201. private _slerping;
  95202. private _transformYawPitch;
  95203. private _transformYawPitchInv;
  95204. private _firstFrameSkipped;
  95205. private _yawRange;
  95206. private _fowardAxis;
  95207. /**
  95208. * Gets or sets the minimum yaw angle that the bone can look to
  95209. */
  95210. minYaw: number;
  95211. /**
  95212. * Gets or sets the maximum yaw angle that the bone can look to
  95213. */
  95214. maxYaw: number;
  95215. /**
  95216. * Gets or sets the minimum pitch angle that the bone can look to
  95217. */
  95218. minPitch: number;
  95219. /**
  95220. * Gets or sets the maximum pitch angle that the bone can look to
  95221. */
  95222. maxPitch: number;
  95223. /**
  95224. * Create a BoneLookController
  95225. * @param mesh the mesh that the bone belongs to
  95226. * @param bone the bone that will be looking to the target
  95227. * @param target the target Vector3 to look at
  95228. * @param options optional settings:
  95229. * * maxYaw: the maximum angle the bone will yaw to
  95230. * * minYaw: the minimum angle the bone will yaw to
  95231. * * maxPitch: the maximum angle the bone will pitch to
  95232. * * minPitch: the minimum angle the bone will yaw to
  95233. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  95234. * * upAxis: the up axis of the coordinate system
  95235. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  95236. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  95237. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  95238. * * adjustYaw: used to make an adjustment to the yaw of the bone
  95239. * * adjustPitch: used to make an adjustment to the pitch of the bone
  95240. * * adjustRoll: used to make an adjustment to the roll of the bone
  95241. **/
  95242. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  95243. maxYaw?: number;
  95244. minYaw?: number;
  95245. maxPitch?: number;
  95246. minPitch?: number;
  95247. slerpAmount?: number;
  95248. upAxis?: Vector3;
  95249. upAxisSpace?: Space;
  95250. yawAxis?: Vector3;
  95251. pitchAxis?: Vector3;
  95252. adjustYaw?: number;
  95253. adjustPitch?: number;
  95254. adjustRoll?: number;
  95255. });
  95256. /**
  95257. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  95258. */
  95259. update(): void;
  95260. private _getAngleDiff;
  95261. private _getAngleBetween;
  95262. private _isAngleBetween;
  95263. }
  95264. }
  95265. declare module BABYLON {
  95266. /**
  95267. * Manage the gamepad inputs to control an arc rotate camera.
  95268. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  95269. */
  95270. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  95271. /**
  95272. * Defines the camera the input is attached to.
  95273. */
  95274. camera: ArcRotateCamera;
  95275. /**
  95276. * Defines the gamepad the input is gathering event from.
  95277. */
  95278. gamepad: Nullable<Gamepad>;
  95279. /**
  95280. * Defines the gamepad rotation sensiblity.
  95281. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  95282. */
  95283. gamepadRotationSensibility: number;
  95284. /**
  95285. * Defines the gamepad move sensiblity.
  95286. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  95287. */
  95288. gamepadMoveSensibility: number;
  95289. private _onGamepadConnectedObserver;
  95290. private _onGamepadDisconnectedObserver;
  95291. /**
  95292. * Attach the input controls to a specific dom element to get the input from.
  95293. * @param element Defines the element the controls should be listened from
  95294. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  95295. */
  95296. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  95297. /**
  95298. * Detach the current controls from the specified dom element.
  95299. * @param element Defines the element to stop listening the inputs from
  95300. */
  95301. detachControl(element: Nullable<HTMLElement>): void;
  95302. /**
  95303. * Update the current camera state depending on the inputs that have been used this frame.
  95304. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  95305. */
  95306. checkInputs(): void;
  95307. /**
  95308. * Gets the class name of the current intput.
  95309. * @returns the class name
  95310. */
  95311. getClassName(): string;
  95312. /**
  95313. * Get the friendly name associated with the input class.
  95314. * @returns the input friendly name
  95315. */
  95316. getSimpleName(): string;
  95317. }
  95318. }
  95319. declare module BABYLON {
  95320. interface ArcRotateCameraInputsManager {
  95321. /**
  95322. * Add orientation input support to the input manager.
  95323. * @returns the current input manager
  95324. */
  95325. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  95326. }
  95327. /**
  95328. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  95329. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  95330. */
  95331. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  95332. /**
  95333. * Defines the camera the input is attached to.
  95334. */
  95335. camera: ArcRotateCamera;
  95336. /**
  95337. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  95338. */
  95339. alphaCorrection: number;
  95340. /**
  95341. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  95342. */
  95343. gammaCorrection: number;
  95344. private _alpha;
  95345. private _gamma;
  95346. private _dirty;
  95347. private _deviceOrientationHandler;
  95348. /**
  95349. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  95350. */
  95351. constructor();
  95352. /**
  95353. * Attach the input controls to a specific dom element to get the input from.
  95354. * @param element Defines the element the controls should be listened from
  95355. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  95356. */
  95357. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  95358. /** @hidden */
  95359. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  95360. /**
  95361. * Update the current camera state depending on the inputs that have been used this frame.
  95362. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  95363. */
  95364. checkInputs(): void;
  95365. /**
  95366. * Detach the current controls from the specified dom element.
  95367. * @param element Defines the element to stop listening the inputs from
  95368. */
  95369. detachControl(element: Nullable<HTMLElement>): void;
  95370. /**
  95371. * Gets the class name of the current intput.
  95372. * @returns the class name
  95373. */
  95374. getClassName(): string;
  95375. /**
  95376. * Get the friendly name associated with the input class.
  95377. * @returns the input friendly name
  95378. */
  95379. getSimpleName(): string;
  95380. }
  95381. }
  95382. declare module BABYLON {
  95383. /**
  95384. * Listen to mouse events to control the camera.
  95385. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  95386. */
  95387. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  95388. /**
  95389. * Defines the camera the input is attached to.
  95390. */
  95391. camera: FlyCamera;
  95392. /**
  95393. * Defines if touch is enabled. (Default is true.)
  95394. */
  95395. touchEnabled: boolean;
  95396. /**
  95397. * Defines the buttons associated with the input to handle camera rotation.
  95398. */
  95399. buttons: number[];
  95400. /**
  95401. * Assign buttons for Yaw control.
  95402. */
  95403. buttonsYaw: number[];
  95404. /**
  95405. * Assign buttons for Pitch control.
  95406. */
  95407. buttonsPitch: number[];
  95408. /**
  95409. * Assign buttons for Roll control.
  95410. */
  95411. buttonsRoll: number[];
  95412. /**
  95413. * Detect if any button is being pressed while mouse is moved.
  95414. * -1 = Mouse locked.
  95415. * 0 = Left button.
  95416. * 1 = Middle Button.
  95417. * 2 = Right Button.
  95418. */
  95419. activeButton: number;
  95420. /**
  95421. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  95422. * Higher values reduce its sensitivity.
  95423. */
  95424. angularSensibility: number;
  95425. private _mousemoveCallback;
  95426. private _observer;
  95427. private _rollObserver;
  95428. private previousPosition;
  95429. private noPreventDefault;
  95430. private element;
  95431. /**
  95432. * Listen to mouse events to control the camera.
  95433. * @param touchEnabled Define if touch is enabled. (Default is true.)
  95434. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  95435. */
  95436. constructor(touchEnabled?: boolean);
  95437. /**
  95438. * Attach the mouse control to the HTML DOM element.
  95439. * @param element Defines the element that listens to the input events.
  95440. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  95441. */
  95442. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  95443. /**
  95444. * Detach the current controls from the specified dom element.
  95445. * @param element Defines the element to stop listening the inputs from
  95446. */
  95447. detachControl(element: Nullable<HTMLElement>): void;
  95448. /**
  95449. * Gets the class name of the current input.
  95450. * @returns the class name.
  95451. */
  95452. getClassName(): string;
  95453. /**
  95454. * Get the friendly name associated with the input class.
  95455. * @returns the input's friendly name.
  95456. */
  95457. getSimpleName(): string;
  95458. private _pointerInput;
  95459. private _onMouseMove;
  95460. /**
  95461. * Rotate camera by mouse offset.
  95462. */
  95463. private rotateCamera;
  95464. }
  95465. }
  95466. declare module BABYLON {
  95467. /**
  95468. * Default Inputs manager for the FlyCamera.
  95469. * It groups all the default supported inputs for ease of use.
  95470. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  95471. */
  95472. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  95473. /**
  95474. * Instantiates a new FlyCameraInputsManager.
  95475. * @param camera Defines the camera the inputs belong to.
  95476. */
  95477. constructor(camera: FlyCamera);
  95478. /**
  95479. * Add keyboard input support to the input manager.
  95480. * @returns the new FlyCameraKeyboardMoveInput().
  95481. */
  95482. addKeyboard(): FlyCameraInputsManager;
  95483. /**
  95484. * Add mouse input support to the input manager.
  95485. * @param touchEnabled Enable touch screen support.
  95486. * @returns the new FlyCameraMouseInput().
  95487. */
  95488. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  95489. }
  95490. }
  95491. declare module BABYLON {
  95492. /**
  95493. * This is a flying camera, designed for 3D movement and rotation in all directions,
  95494. * such as in a 3D Space Shooter or a Flight Simulator.
  95495. */
  95496. export class FlyCamera extends TargetCamera {
  95497. /**
  95498. * Define the collision ellipsoid of the camera.
  95499. * This is helpful for simulating a camera body, like a player's body.
  95500. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  95501. */
  95502. ellipsoid: Vector3;
  95503. /**
  95504. * Define an offset for the position of the ellipsoid around the camera.
  95505. * This can be helpful if the camera is attached away from the player's body center,
  95506. * such as at its head.
  95507. */
  95508. ellipsoidOffset: Vector3;
  95509. /**
  95510. * Enable or disable collisions of the camera with the rest of the scene objects.
  95511. */
  95512. checkCollisions: boolean;
  95513. /**
  95514. * Enable or disable gravity on the camera.
  95515. */
  95516. applyGravity: boolean;
  95517. /**
  95518. * Define the current direction the camera is moving to.
  95519. */
  95520. cameraDirection: Vector3;
  95521. /**
  95522. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  95523. * This overrides and empties cameraRotation.
  95524. */
  95525. rotationQuaternion: Quaternion;
  95526. /**
  95527. * Track Roll to maintain the wanted Rolling when looking around.
  95528. */
  95529. _trackRoll: number;
  95530. /**
  95531. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  95532. */
  95533. rollCorrect: number;
  95534. /**
  95535. * Mimic a banked turn, Rolling the camera when Yawing.
  95536. * It's recommended to use rollCorrect = 10 for faster banking correction.
  95537. */
  95538. bankedTurn: boolean;
  95539. /**
  95540. * Limit in radians for how much Roll banking will add. (Default: 90°)
  95541. */
  95542. bankedTurnLimit: number;
  95543. /**
  95544. * Value of 0 disables the banked Roll.
  95545. * Value of 1 is equal to the Yaw angle in radians.
  95546. */
  95547. bankedTurnMultiplier: number;
  95548. /**
  95549. * The inputs manager loads all the input sources, such as keyboard and mouse.
  95550. */
  95551. inputs: FlyCameraInputsManager;
  95552. /**
  95553. * Gets the input sensibility for mouse input.
  95554. * Higher values reduce sensitivity.
  95555. */
  95556. /**
  95557. * Sets the input sensibility for a mouse input.
  95558. * Higher values reduce sensitivity.
  95559. */
  95560. angularSensibility: number;
  95561. /**
  95562. * Get the keys for camera movement forward.
  95563. */
  95564. /**
  95565. * Set the keys for camera movement forward.
  95566. */
  95567. keysForward: number[];
  95568. /**
  95569. * Get the keys for camera movement backward.
  95570. */
  95571. keysBackward: number[];
  95572. /**
  95573. * Get the keys for camera movement up.
  95574. */
  95575. /**
  95576. * Set the keys for camera movement up.
  95577. */
  95578. keysUp: number[];
  95579. /**
  95580. * Get the keys for camera movement down.
  95581. */
  95582. /**
  95583. * Set the keys for camera movement down.
  95584. */
  95585. keysDown: number[];
  95586. /**
  95587. * Get the keys for camera movement left.
  95588. */
  95589. /**
  95590. * Set the keys for camera movement left.
  95591. */
  95592. keysLeft: number[];
  95593. /**
  95594. * Set the keys for camera movement right.
  95595. */
  95596. /**
  95597. * Set the keys for camera movement right.
  95598. */
  95599. keysRight: number[];
  95600. /**
  95601. * Event raised when the camera collides with a mesh in the scene.
  95602. */
  95603. onCollide: (collidedMesh: AbstractMesh) => void;
  95604. private _collider;
  95605. private _needMoveForGravity;
  95606. private _oldPosition;
  95607. private _diffPosition;
  95608. private _newPosition;
  95609. /** @hidden */
  95610. _localDirection: Vector3;
  95611. /** @hidden */
  95612. _transformedDirection: Vector3;
  95613. /**
  95614. * Instantiates a FlyCamera.
  95615. * This is a flying camera, designed for 3D movement and rotation in all directions,
  95616. * such as in a 3D Space Shooter or a Flight Simulator.
  95617. * @param name Define the name of the camera in the scene.
  95618. * @param position Define the starting position of the camera in the scene.
  95619. * @param scene Define the scene the camera belongs to.
  95620. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  95621. */
  95622. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  95623. /**
  95624. * Attach a control to the HTML DOM element.
  95625. * @param element Defines the element that listens to the input events.
  95626. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  95627. */
  95628. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  95629. /**
  95630. * Detach a control from the HTML DOM element.
  95631. * The camera will stop reacting to that input.
  95632. * @param element Defines the element that listens to the input events.
  95633. */
  95634. detachControl(element: HTMLElement): void;
  95635. private _collisionMask;
  95636. /**
  95637. * Get the mask that the camera ignores in collision events.
  95638. */
  95639. /**
  95640. * Set the mask that the camera ignores in collision events.
  95641. */
  95642. collisionMask: number;
  95643. /** @hidden */
  95644. _collideWithWorld(displacement: Vector3): void;
  95645. /** @hidden */
  95646. private _onCollisionPositionChange;
  95647. /** @hidden */
  95648. _checkInputs(): void;
  95649. /** @hidden */
  95650. _decideIfNeedsToMove(): boolean;
  95651. /** @hidden */
  95652. _updatePosition(): void;
  95653. /**
  95654. * Restore the Roll to its target value at the rate specified.
  95655. * @param rate - Higher means slower restoring.
  95656. * @hidden
  95657. */
  95658. restoreRoll(rate: number): void;
  95659. /**
  95660. * Destroy the camera and release the current resources held by it.
  95661. */
  95662. dispose(): void;
  95663. /**
  95664. * Get the current object class name.
  95665. * @returns the class name.
  95666. */
  95667. getClassName(): string;
  95668. }
  95669. }
  95670. declare module BABYLON {
  95671. /**
  95672. * Listen to keyboard events to control the camera.
  95673. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  95674. */
  95675. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  95676. /**
  95677. * Defines the camera the input is attached to.
  95678. */
  95679. camera: FlyCamera;
  95680. /**
  95681. * The list of keyboard keys used to control the forward move of the camera.
  95682. */
  95683. keysForward: number[];
  95684. /**
  95685. * The list of keyboard keys used to control the backward move of the camera.
  95686. */
  95687. keysBackward: number[];
  95688. /**
  95689. * The list of keyboard keys used to control the forward move of the camera.
  95690. */
  95691. keysUp: number[];
  95692. /**
  95693. * The list of keyboard keys used to control the backward move of the camera.
  95694. */
  95695. keysDown: number[];
  95696. /**
  95697. * The list of keyboard keys used to control the right strafe move of the camera.
  95698. */
  95699. keysRight: number[];
  95700. /**
  95701. * The list of keyboard keys used to control the left strafe move of the camera.
  95702. */
  95703. keysLeft: number[];
  95704. private _keys;
  95705. private _onCanvasBlurObserver;
  95706. private _onKeyboardObserver;
  95707. private _engine;
  95708. private _scene;
  95709. /**
  95710. * Attach the input controls to a specific dom element to get the input from.
  95711. * @param element Defines the element the controls should be listened from
  95712. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  95713. */
  95714. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  95715. /**
  95716. * Detach the current controls from the specified dom element.
  95717. * @param element Defines the element to stop listening the inputs from
  95718. */
  95719. detachControl(element: Nullable<HTMLElement>): void;
  95720. /**
  95721. * Gets the class name of the current intput.
  95722. * @returns the class name
  95723. */
  95724. getClassName(): string;
  95725. /** @hidden */
  95726. _onLostFocus(e: FocusEvent): void;
  95727. /**
  95728. * Get the friendly name associated with the input class.
  95729. * @returns the input friendly name
  95730. */
  95731. getSimpleName(): string;
  95732. /**
  95733. * Update the current camera state depending on the inputs that have been used this frame.
  95734. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  95735. */
  95736. checkInputs(): void;
  95737. }
  95738. }
  95739. declare module BABYLON {
  95740. /**
  95741. * Manage the mouse wheel inputs to control a follow camera.
  95742. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  95743. */
  95744. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  95745. /**
  95746. * Defines the camera the input is attached to.
  95747. */
  95748. camera: FollowCamera;
  95749. /**
  95750. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  95751. */
  95752. axisControlRadius: boolean;
  95753. /**
  95754. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  95755. */
  95756. axisControlHeight: boolean;
  95757. /**
  95758. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  95759. */
  95760. axisControlRotation: boolean;
  95761. /**
  95762. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  95763. * relation to mouseWheel events.
  95764. */
  95765. wheelPrecision: number;
  95766. /**
  95767. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  95768. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  95769. */
  95770. wheelDeltaPercentage: number;
  95771. private _wheel;
  95772. private _observer;
  95773. /**
  95774. * Attach the input controls to a specific dom element to get the input from.
  95775. * @param element Defines the element the controls should be listened from
  95776. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  95777. */
  95778. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  95779. /**
  95780. * Detach the current controls from the specified dom element.
  95781. * @param element Defines the element to stop listening the inputs from
  95782. */
  95783. detachControl(element: Nullable<HTMLElement>): void;
  95784. /**
  95785. * Gets the class name of the current intput.
  95786. * @returns the class name
  95787. */
  95788. getClassName(): string;
  95789. /**
  95790. * Get the friendly name associated with the input class.
  95791. * @returns the input friendly name
  95792. */
  95793. getSimpleName(): string;
  95794. }
  95795. }
  95796. declare module BABYLON {
  95797. /**
  95798. * Manage the pointers inputs to control an follow camera.
  95799. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  95800. */
  95801. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  95802. /**
  95803. * Defines the camera the input is attached to.
  95804. */
  95805. camera: FollowCamera;
  95806. /**
  95807. * Gets the class name of the current input.
  95808. * @returns the class name
  95809. */
  95810. getClassName(): string;
  95811. /**
  95812. * Defines the pointer angular sensibility along the X axis or how fast is
  95813. * the camera rotating.
  95814. * A negative number will reverse the axis direction.
  95815. */
  95816. angularSensibilityX: number;
  95817. /**
  95818. * Defines the pointer angular sensibility along the Y axis or how fast is
  95819. * the camera rotating.
  95820. * A negative number will reverse the axis direction.
  95821. */
  95822. angularSensibilityY: number;
  95823. /**
  95824. * Defines the pointer pinch precision or how fast is the camera zooming.
  95825. * A negative number will reverse the axis direction.
  95826. */
  95827. pinchPrecision: number;
  95828. /**
  95829. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  95830. * from 0.
  95831. * It defines the percentage of current camera.radius to use as delta when
  95832. * pinch zoom is used.
  95833. */
  95834. pinchDeltaPercentage: number;
  95835. /**
  95836. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  95837. */
  95838. axisXControlRadius: boolean;
  95839. /**
  95840. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  95841. */
  95842. axisXControlHeight: boolean;
  95843. /**
  95844. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  95845. */
  95846. axisXControlRotation: boolean;
  95847. /**
  95848. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  95849. */
  95850. axisYControlRadius: boolean;
  95851. /**
  95852. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  95853. */
  95854. axisYControlHeight: boolean;
  95855. /**
  95856. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  95857. */
  95858. axisYControlRotation: boolean;
  95859. /**
  95860. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  95861. */
  95862. axisPinchControlRadius: boolean;
  95863. /**
  95864. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  95865. */
  95866. axisPinchControlHeight: boolean;
  95867. /**
  95868. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  95869. */
  95870. axisPinchControlRotation: boolean;
  95871. /**
  95872. * Log error messages if basic misconfiguration has occurred.
  95873. */
  95874. warningEnable: boolean;
  95875. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  95876. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  95877. private _warningCounter;
  95878. private _warning;
  95879. }
  95880. }
  95881. declare module BABYLON {
  95882. /**
  95883. * Default Inputs manager for the FollowCamera.
  95884. * It groups all the default supported inputs for ease of use.
  95885. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  95886. */
  95887. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  95888. /**
  95889. * Instantiates a new FollowCameraInputsManager.
  95890. * @param camera Defines the camera the inputs belong to
  95891. */
  95892. constructor(camera: FollowCamera);
  95893. /**
  95894. * Add keyboard input support to the input manager.
  95895. * @returns the current input manager
  95896. */
  95897. addKeyboard(): FollowCameraInputsManager;
  95898. /**
  95899. * Add mouse wheel input support to the input manager.
  95900. * @returns the current input manager
  95901. */
  95902. addMouseWheel(): FollowCameraInputsManager;
  95903. /**
  95904. * Add pointers input support to the input manager.
  95905. * @returns the current input manager
  95906. */
  95907. addPointers(): FollowCameraInputsManager;
  95908. /**
  95909. * Add orientation input support to the input manager.
  95910. * @returns the current input manager
  95911. */
  95912. addVRDeviceOrientation(): FollowCameraInputsManager;
  95913. }
  95914. }
  95915. declare module BABYLON {
  95916. /**
  95917. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  95918. * an arc rotate version arcFollowCamera are available.
  95919. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  95920. */
  95921. export class FollowCamera extends TargetCamera {
  95922. /**
  95923. * Distance the follow camera should follow an object at
  95924. */
  95925. radius: number;
  95926. /**
  95927. * Minimum allowed distance of the camera to the axis of rotation
  95928. * (The camera can not get closer).
  95929. * This can help limiting how the Camera is able to move in the scene.
  95930. */
  95931. lowerRadiusLimit: Nullable<number>;
  95932. /**
  95933. * Maximum allowed distance of the camera to the axis of rotation
  95934. * (The camera can not get further).
  95935. * This can help limiting how the Camera is able to move in the scene.
  95936. */
  95937. upperRadiusLimit: Nullable<number>;
  95938. /**
  95939. * Define a rotation offset between the camera and the object it follows
  95940. */
  95941. rotationOffset: number;
  95942. /**
  95943. * Minimum allowed angle to camera position relative to target object.
  95944. * This can help limiting how the Camera is able to move in the scene.
  95945. */
  95946. lowerRotationOffsetLimit: Nullable<number>;
  95947. /**
  95948. * Maximum allowed angle to camera position relative to target object.
  95949. * This can help limiting how the Camera is able to move in the scene.
  95950. */
  95951. upperRotationOffsetLimit: Nullable<number>;
  95952. /**
  95953. * Define a height offset between the camera and the object it follows.
  95954. * It can help following an object from the top (like a car chaing a plane)
  95955. */
  95956. heightOffset: number;
  95957. /**
  95958. * Minimum allowed height of camera position relative to target object.
  95959. * This can help limiting how the Camera is able to move in the scene.
  95960. */
  95961. lowerHeightOffsetLimit: Nullable<number>;
  95962. /**
  95963. * Maximum allowed height of camera position relative to target object.
  95964. * This can help limiting how the Camera is able to move in the scene.
  95965. */
  95966. upperHeightOffsetLimit: Nullable<number>;
  95967. /**
  95968. * Define how fast the camera can accelerate to follow it s target.
  95969. */
  95970. cameraAcceleration: number;
  95971. /**
  95972. * Define the speed limit of the camera following an object.
  95973. */
  95974. maxCameraSpeed: number;
  95975. /**
  95976. * Define the target of the camera.
  95977. */
  95978. lockedTarget: Nullable<AbstractMesh>;
  95979. /**
  95980. * Defines the input associated with the camera.
  95981. */
  95982. inputs: FollowCameraInputsManager;
  95983. /**
  95984. * Instantiates the follow camera.
  95985. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  95986. * @param name Define the name of the camera in the scene
  95987. * @param position Define the position of the camera
  95988. * @param scene Define the scene the camera belong to
  95989. * @param lockedTarget Define the target of the camera
  95990. */
  95991. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  95992. private _follow;
  95993. /**
  95994. * Attached controls to the current camera.
  95995. * @param element Defines the element the controls should be listened from
  95996. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  95997. */
  95998. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  95999. /**
  96000. * Detach the current controls from the camera.
  96001. * The camera will stop reacting to inputs.
  96002. * @param element Defines the element to stop listening the inputs from
  96003. */
  96004. detachControl(element: HTMLElement): void;
  96005. /** @hidden */
  96006. _checkInputs(): void;
  96007. private _checkLimits;
  96008. /**
  96009. * Gets the camera class name.
  96010. * @returns the class name
  96011. */
  96012. getClassName(): string;
  96013. }
  96014. /**
  96015. * Arc Rotate version of the follow camera.
  96016. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  96017. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  96018. */
  96019. export class ArcFollowCamera extends TargetCamera {
  96020. /** The longitudinal angle of the camera */
  96021. alpha: number;
  96022. /** The latitudinal angle of the camera */
  96023. beta: number;
  96024. /** The radius of the camera from its target */
  96025. radius: number;
  96026. /** Define the camera target (the messh it should follow) */
  96027. target: Nullable<AbstractMesh>;
  96028. private _cartesianCoordinates;
  96029. /**
  96030. * Instantiates a new ArcFollowCamera
  96031. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  96032. * @param name Define the name of the camera
  96033. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  96034. * @param beta Define the rotation angle of the camera around the elevation axis
  96035. * @param radius Define the radius of the camera from its target point
  96036. * @param target Define the target of the camera
  96037. * @param scene Define the scene the camera belongs to
  96038. */
  96039. constructor(name: string,
  96040. /** The longitudinal angle of the camera */
  96041. alpha: number,
  96042. /** The latitudinal angle of the camera */
  96043. beta: number,
  96044. /** The radius of the camera from its target */
  96045. radius: number,
  96046. /** Define the camera target (the messh it should follow) */
  96047. target: Nullable<AbstractMesh>, scene: Scene);
  96048. private _follow;
  96049. /** @hidden */
  96050. _checkInputs(): void;
  96051. /**
  96052. * Returns the class name of the object.
  96053. * It is mostly used internally for serialization purposes.
  96054. */
  96055. getClassName(): string;
  96056. }
  96057. }
  96058. declare module BABYLON {
  96059. /**
  96060. * Manage the keyboard inputs to control the movement of a follow camera.
  96061. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  96062. */
  96063. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  96064. /**
  96065. * Defines the camera the input is attached to.
  96066. */
  96067. camera: FollowCamera;
  96068. /**
  96069. * Defines the list of key codes associated with the up action (increase heightOffset)
  96070. */
  96071. keysHeightOffsetIncr: number[];
  96072. /**
  96073. * Defines the list of key codes associated with the down action (decrease heightOffset)
  96074. */
  96075. keysHeightOffsetDecr: number[];
  96076. /**
  96077. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  96078. */
  96079. keysHeightOffsetModifierAlt: boolean;
  96080. /**
  96081. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  96082. */
  96083. keysHeightOffsetModifierCtrl: boolean;
  96084. /**
  96085. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  96086. */
  96087. keysHeightOffsetModifierShift: boolean;
  96088. /**
  96089. * Defines the list of key codes associated with the left action (increase rotationOffset)
  96090. */
  96091. keysRotationOffsetIncr: number[];
  96092. /**
  96093. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  96094. */
  96095. keysRotationOffsetDecr: number[];
  96096. /**
  96097. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  96098. */
  96099. keysRotationOffsetModifierAlt: boolean;
  96100. /**
  96101. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  96102. */
  96103. keysRotationOffsetModifierCtrl: boolean;
  96104. /**
  96105. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  96106. */
  96107. keysRotationOffsetModifierShift: boolean;
  96108. /**
  96109. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  96110. */
  96111. keysRadiusIncr: number[];
  96112. /**
  96113. * Defines the list of key codes associated with the zoom-out action (increase radius)
  96114. */
  96115. keysRadiusDecr: number[];
  96116. /**
  96117. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  96118. */
  96119. keysRadiusModifierAlt: boolean;
  96120. /**
  96121. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  96122. */
  96123. keysRadiusModifierCtrl: boolean;
  96124. /**
  96125. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  96126. */
  96127. keysRadiusModifierShift: boolean;
  96128. /**
  96129. * Defines the rate of change of heightOffset.
  96130. */
  96131. heightSensibility: number;
  96132. /**
  96133. * Defines the rate of change of rotationOffset.
  96134. */
  96135. rotationSensibility: number;
  96136. /**
  96137. * Defines the rate of change of radius.
  96138. */
  96139. radiusSensibility: number;
  96140. private _keys;
  96141. private _ctrlPressed;
  96142. private _altPressed;
  96143. private _shiftPressed;
  96144. private _onCanvasBlurObserver;
  96145. private _onKeyboardObserver;
  96146. private _engine;
  96147. private _scene;
  96148. /**
  96149. * Attach the input controls to a specific dom element to get the input from.
  96150. * @param element Defines the element the controls should be listened from
  96151. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  96152. */
  96153. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  96154. /**
  96155. * Detach the current controls from the specified dom element.
  96156. * @param element Defines the element to stop listening the inputs from
  96157. */
  96158. detachControl(element: Nullable<HTMLElement>): void;
  96159. /**
  96160. * Update the current camera state depending on the inputs that have been used this frame.
  96161. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  96162. */
  96163. checkInputs(): void;
  96164. /**
  96165. * Gets the class name of the current input.
  96166. * @returns the class name
  96167. */
  96168. getClassName(): string;
  96169. /**
  96170. * Get the friendly name associated with the input class.
  96171. * @returns the input friendly name
  96172. */
  96173. getSimpleName(): string;
  96174. /**
  96175. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  96176. * allow modification of the heightOffset value.
  96177. */
  96178. private _modifierHeightOffset;
  96179. /**
  96180. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  96181. * allow modification of the rotationOffset value.
  96182. */
  96183. private _modifierRotationOffset;
  96184. /**
  96185. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  96186. * allow modification of the radius value.
  96187. */
  96188. private _modifierRadius;
  96189. }
  96190. }
  96191. declare module BABYLON {
  96192. interface FreeCameraInputsManager {
  96193. /**
  96194. * @hidden
  96195. */
  96196. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  96197. /**
  96198. * Add orientation input support to the input manager.
  96199. * @returns the current input manager
  96200. */
  96201. addDeviceOrientation(): FreeCameraInputsManager;
  96202. }
  96203. /**
  96204. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  96205. * Screen rotation is taken into account.
  96206. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  96207. */
  96208. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  96209. private _camera;
  96210. private _screenOrientationAngle;
  96211. private _constantTranform;
  96212. private _screenQuaternion;
  96213. private _alpha;
  96214. private _beta;
  96215. private _gamma;
  96216. /**
  96217. * @hidden
  96218. */
  96219. _onDeviceOrientationChangedObservable: Observable<void>;
  96220. /**
  96221. * Instantiates a new input
  96222. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  96223. */
  96224. constructor();
  96225. /**
  96226. * Define the camera controlled by the input.
  96227. */
  96228. camera: FreeCamera;
  96229. /**
  96230. * Attach the input controls to a specific dom element to get the input from.
  96231. * @param element Defines the element the controls should be listened from
  96232. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  96233. */
  96234. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  96235. private _orientationChanged;
  96236. private _deviceOrientation;
  96237. /**
  96238. * Detach the current controls from the specified dom element.
  96239. * @param element Defines the element to stop listening the inputs from
  96240. */
  96241. detachControl(element: Nullable<HTMLElement>): void;
  96242. /**
  96243. * Update the current camera state depending on the inputs that have been used this frame.
  96244. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  96245. */
  96246. checkInputs(): void;
  96247. /**
  96248. * Gets the class name of the current intput.
  96249. * @returns the class name
  96250. */
  96251. getClassName(): string;
  96252. /**
  96253. * Get the friendly name associated with the input class.
  96254. * @returns the input friendly name
  96255. */
  96256. getSimpleName(): string;
  96257. }
  96258. }
  96259. declare module BABYLON {
  96260. /**
  96261. * Manage the gamepad inputs to control a free camera.
  96262. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  96263. */
  96264. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  96265. /**
  96266. * Define the camera the input is attached to.
  96267. */
  96268. camera: FreeCamera;
  96269. /**
  96270. * Define the Gamepad controlling the input
  96271. */
  96272. gamepad: Nullable<Gamepad>;
  96273. /**
  96274. * Defines the gamepad rotation sensiblity.
  96275. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  96276. */
  96277. gamepadAngularSensibility: number;
  96278. /**
  96279. * Defines the gamepad move sensiblity.
  96280. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  96281. */
  96282. gamepadMoveSensibility: number;
  96283. private _onGamepadConnectedObserver;
  96284. private _onGamepadDisconnectedObserver;
  96285. private _cameraTransform;
  96286. private _deltaTransform;
  96287. private _vector3;
  96288. private _vector2;
  96289. /**
  96290. * Attach the input controls to a specific dom element to get the input from.
  96291. * @param element Defines the element the controls should be listened from
  96292. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  96293. */
  96294. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  96295. /**
  96296. * Detach the current controls from the specified dom element.
  96297. * @param element Defines the element to stop listening the inputs from
  96298. */
  96299. detachControl(element: Nullable<HTMLElement>): void;
  96300. /**
  96301. * Update the current camera state depending on the inputs that have been used this frame.
  96302. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  96303. */
  96304. checkInputs(): void;
  96305. /**
  96306. * Gets the class name of the current intput.
  96307. * @returns the class name
  96308. */
  96309. getClassName(): string;
  96310. /**
  96311. * Get the friendly name associated with the input class.
  96312. * @returns the input friendly name
  96313. */
  96314. getSimpleName(): string;
  96315. }
  96316. }
  96317. declare module BABYLON {
  96318. /**
  96319. * Defines the potential axis of a Joystick
  96320. */
  96321. export enum JoystickAxis {
  96322. /** X axis */
  96323. X = 0,
  96324. /** Y axis */
  96325. Y = 1,
  96326. /** Z axis */
  96327. Z = 2
  96328. }
  96329. /**
  96330. * Class used to define virtual joystick (used in touch mode)
  96331. */
  96332. export class VirtualJoystick {
  96333. /**
  96334. * Gets or sets a boolean indicating that left and right values must be inverted
  96335. */
  96336. reverseLeftRight: boolean;
  96337. /**
  96338. * Gets or sets a boolean indicating that up and down values must be inverted
  96339. */
  96340. reverseUpDown: boolean;
  96341. /**
  96342. * Gets the offset value for the position (ie. the change of the position value)
  96343. */
  96344. deltaPosition: Vector3;
  96345. /**
  96346. * Gets a boolean indicating if the virtual joystick was pressed
  96347. */
  96348. pressed: boolean;
  96349. /**
  96350. * Canvas the virtual joystick will render onto, default z-index of this is 5
  96351. */
  96352. static Canvas: Nullable<HTMLCanvasElement>;
  96353. private static _globalJoystickIndex;
  96354. private static vjCanvasContext;
  96355. private static vjCanvasWidth;
  96356. private static vjCanvasHeight;
  96357. private static halfWidth;
  96358. private _action;
  96359. private _axisTargetedByLeftAndRight;
  96360. private _axisTargetedByUpAndDown;
  96361. private _joystickSensibility;
  96362. private _inversedSensibility;
  96363. private _joystickPointerID;
  96364. private _joystickColor;
  96365. private _joystickPointerPos;
  96366. private _joystickPreviousPointerPos;
  96367. private _joystickPointerStartPos;
  96368. private _deltaJoystickVector;
  96369. private _leftJoystick;
  96370. private _touches;
  96371. private _onPointerDownHandlerRef;
  96372. private _onPointerMoveHandlerRef;
  96373. private _onPointerUpHandlerRef;
  96374. private _onResize;
  96375. /**
  96376. * Creates a new virtual joystick
  96377. * @param leftJoystick defines that the joystick is for left hand (false by default)
  96378. */
  96379. constructor(leftJoystick?: boolean);
  96380. /**
  96381. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  96382. * @param newJoystickSensibility defines the new sensibility
  96383. */
  96384. setJoystickSensibility(newJoystickSensibility: number): void;
  96385. private _onPointerDown;
  96386. private _onPointerMove;
  96387. private _onPointerUp;
  96388. /**
  96389. * Change the color of the virtual joystick
  96390. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  96391. */
  96392. setJoystickColor(newColor: string): void;
  96393. /**
  96394. * Defines a callback to call when the joystick is touched
  96395. * @param action defines the callback
  96396. */
  96397. setActionOnTouch(action: () => any): void;
  96398. /**
  96399. * Defines which axis you'd like to control for left & right
  96400. * @param axis defines the axis to use
  96401. */
  96402. setAxisForLeftRight(axis: JoystickAxis): void;
  96403. /**
  96404. * Defines which axis you'd like to control for up & down
  96405. * @param axis defines the axis to use
  96406. */
  96407. setAxisForUpDown(axis: JoystickAxis): void;
  96408. private _drawVirtualJoystick;
  96409. /**
  96410. * Release internal HTML canvas
  96411. */
  96412. releaseCanvas(): void;
  96413. }
  96414. }
  96415. declare module BABYLON {
  96416. interface FreeCameraInputsManager {
  96417. /**
  96418. * Add virtual joystick input support to the input manager.
  96419. * @returns the current input manager
  96420. */
  96421. addVirtualJoystick(): FreeCameraInputsManager;
  96422. }
  96423. /**
  96424. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  96425. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  96426. */
  96427. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  96428. /**
  96429. * Defines the camera the input is attached to.
  96430. */
  96431. camera: FreeCamera;
  96432. private _leftjoystick;
  96433. private _rightjoystick;
  96434. /**
  96435. * Gets the left stick of the virtual joystick.
  96436. * @returns The virtual Joystick
  96437. */
  96438. getLeftJoystick(): VirtualJoystick;
  96439. /**
  96440. * Gets the right stick of the virtual joystick.
  96441. * @returns The virtual Joystick
  96442. */
  96443. getRightJoystick(): VirtualJoystick;
  96444. /**
  96445. * Update the current camera state depending on the inputs that have been used this frame.
  96446. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  96447. */
  96448. checkInputs(): void;
  96449. /**
  96450. * Attach the input controls to a specific dom element to get the input from.
  96451. * @param element Defines the element the controls should be listened from
  96452. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  96453. */
  96454. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  96455. /**
  96456. * Detach the current controls from the specified dom element.
  96457. * @param element Defines the element to stop listening the inputs from
  96458. */
  96459. detachControl(element: Nullable<HTMLElement>): void;
  96460. /**
  96461. * Gets the class name of the current intput.
  96462. * @returns the class name
  96463. */
  96464. getClassName(): string;
  96465. /**
  96466. * Get the friendly name associated with the input class.
  96467. * @returns the input friendly name
  96468. */
  96469. getSimpleName(): string;
  96470. }
  96471. }
  96472. declare module BABYLON {
  96473. /**
  96474. * This represents a FPS type of camera controlled by touch.
  96475. * This is like a universal camera minus the Gamepad controls.
  96476. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  96477. */
  96478. export class TouchCamera extends FreeCamera {
  96479. /**
  96480. * Defines the touch sensibility for rotation.
  96481. * The higher the faster.
  96482. */
  96483. touchAngularSensibility: number;
  96484. /**
  96485. * Defines the touch sensibility for move.
  96486. * The higher the faster.
  96487. */
  96488. touchMoveSensibility: number;
  96489. /**
  96490. * Instantiates a new touch camera.
  96491. * This represents a FPS type of camera controlled by touch.
  96492. * This is like a universal camera minus the Gamepad controls.
  96493. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  96494. * @param name Define the name of the camera in the scene
  96495. * @param position Define the start position of the camera in the scene
  96496. * @param scene Define the scene the camera belongs to
  96497. */
  96498. constructor(name: string, position: Vector3, scene: Scene);
  96499. /**
  96500. * Gets the current object class name.
  96501. * @return the class name
  96502. */
  96503. getClassName(): string;
  96504. /** @hidden */
  96505. _setupInputs(): void;
  96506. }
  96507. }
  96508. declare module BABYLON {
  96509. /**
  96510. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  96511. * being tilted forward or back and left or right.
  96512. */
  96513. export class DeviceOrientationCamera extends FreeCamera {
  96514. private _initialQuaternion;
  96515. private _quaternionCache;
  96516. private _tmpDragQuaternion;
  96517. /**
  96518. * Creates a new device orientation camera
  96519. * @param name The name of the camera
  96520. * @param position The start position camera
  96521. * @param scene The scene the camera belongs to
  96522. */
  96523. constructor(name: string, position: Vector3, scene: Scene);
  96524. /**
  96525. * Disabled pointer input on first orientation sensor update (Default: true)
  96526. */
  96527. disablePointerInputWhenUsingDeviceOrientation: boolean;
  96528. private _dragFactor;
  96529. /**
  96530. * Enabled turning on the y axis when the orientation sensor is active
  96531. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  96532. */
  96533. enableHorizontalDragging(dragFactor?: number): void;
  96534. /**
  96535. * Gets the current instance class name ("DeviceOrientationCamera").
  96536. * This helps avoiding instanceof at run time.
  96537. * @returns the class name
  96538. */
  96539. getClassName(): string;
  96540. /**
  96541. * @hidden
  96542. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  96543. */
  96544. _checkInputs(): void;
  96545. /**
  96546. * Reset the camera to its default orientation on the specified axis only.
  96547. * @param axis The axis to reset
  96548. */
  96549. resetToCurrentRotation(axis?: Axis): void;
  96550. }
  96551. }
  96552. declare module BABYLON {
  96553. /**
  96554. * 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,
  96555. * which still works and will still be found in many Playgrounds.
  96556. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  96557. */
  96558. export class UniversalCamera extends TouchCamera {
  96559. /**
  96560. * Defines the gamepad rotation sensiblity.
  96561. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  96562. */
  96563. gamepadAngularSensibility: number;
  96564. /**
  96565. * Defines the gamepad move sensiblity.
  96566. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  96567. */
  96568. gamepadMoveSensibility: number;
  96569. /**
  96570. * 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,
  96571. * which still works and will still be found in many Playgrounds.
  96572. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  96573. * @param name Define the name of the camera in the scene
  96574. * @param position Define the start position of the camera in the scene
  96575. * @param scene Define the scene the camera belongs to
  96576. */
  96577. constructor(name: string, position: Vector3, scene: Scene);
  96578. /**
  96579. * Gets the current object class name.
  96580. * @return the class name
  96581. */
  96582. getClassName(): string;
  96583. }
  96584. }
  96585. declare module BABYLON {
  96586. /**
  96587. * This represents a FPS type of camera. This is only here for back compat purpose.
  96588. * Please use the UniversalCamera instead as both are identical.
  96589. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  96590. */
  96591. export class GamepadCamera extends UniversalCamera {
  96592. /**
  96593. * Instantiates a new Gamepad Camera
  96594. * This represents a FPS type of camera. This is only here for back compat purpose.
  96595. * Please use the UniversalCamera instead as both are identical.
  96596. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  96597. * @param name Define the name of the camera in the scene
  96598. * @param position Define the start position of the camera in the scene
  96599. * @param scene Define the scene the camera belongs to
  96600. */
  96601. constructor(name: string, position: Vector3, scene: Scene);
  96602. /**
  96603. * Gets the current object class name.
  96604. * @return the class name
  96605. */
  96606. getClassName(): string;
  96607. }
  96608. }
  96609. declare module BABYLON {
  96610. /** @hidden */
  96611. export var passPixelShader: {
  96612. name: string;
  96613. shader: string;
  96614. };
  96615. }
  96616. declare module BABYLON {
  96617. /** @hidden */
  96618. export var passCubePixelShader: {
  96619. name: string;
  96620. shader: string;
  96621. };
  96622. }
  96623. declare module BABYLON {
  96624. /**
  96625. * PassPostProcess which produces an output the same as it's input
  96626. */
  96627. export class PassPostProcess extends PostProcess {
  96628. /**
  96629. * Creates the PassPostProcess
  96630. * @param name The name of the effect.
  96631. * @param options The required width/height ratio to downsize to before computing the render pass.
  96632. * @param camera The camera to apply the render pass to.
  96633. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  96634. * @param engine The engine which the post process will be applied. (default: current engine)
  96635. * @param reusable If the post process can be reused on the same frame. (default: false)
  96636. * @param textureType The type of texture to be used when performing the post processing.
  96637. * @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)
  96638. */
  96639. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  96640. }
  96641. /**
  96642. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  96643. */
  96644. export class PassCubePostProcess extends PostProcess {
  96645. private _face;
  96646. /**
  96647. * Gets or sets the cube face to display.
  96648. * * 0 is +X
  96649. * * 1 is -X
  96650. * * 2 is +Y
  96651. * * 3 is -Y
  96652. * * 4 is +Z
  96653. * * 5 is -Z
  96654. */
  96655. face: number;
  96656. /**
  96657. * Creates the PassCubePostProcess
  96658. * @param name The name of the effect.
  96659. * @param options The required width/height ratio to downsize to before computing the render pass.
  96660. * @param camera The camera to apply the render pass to.
  96661. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  96662. * @param engine The engine which the post process will be applied. (default: current engine)
  96663. * @param reusable If the post process can be reused on the same frame. (default: false)
  96664. * @param textureType The type of texture to be used when performing the post processing.
  96665. * @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)
  96666. */
  96667. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  96668. }
  96669. }
  96670. declare module BABYLON {
  96671. /** @hidden */
  96672. export var anaglyphPixelShader: {
  96673. name: string;
  96674. shader: string;
  96675. };
  96676. }
  96677. declare module BABYLON {
  96678. /**
  96679. * Postprocess used to generate anaglyphic rendering
  96680. */
  96681. export class AnaglyphPostProcess extends PostProcess {
  96682. private _passedProcess;
  96683. /**
  96684. * Creates a new AnaglyphPostProcess
  96685. * @param name defines postprocess name
  96686. * @param options defines creation options or target ratio scale
  96687. * @param rigCameras defines cameras using this postprocess
  96688. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  96689. * @param engine defines hosting engine
  96690. * @param reusable defines if the postprocess will be reused multiple times per frame
  96691. */
  96692. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  96693. }
  96694. }
  96695. declare module BABYLON {
  96696. /**
  96697. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  96698. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  96699. */
  96700. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  96701. /**
  96702. * Creates a new AnaglyphArcRotateCamera
  96703. * @param name defines camera name
  96704. * @param alpha defines alpha angle (in radians)
  96705. * @param beta defines beta angle (in radians)
  96706. * @param radius defines radius
  96707. * @param target defines camera target
  96708. * @param interaxialDistance defines distance between each color axis
  96709. * @param scene defines the hosting scene
  96710. */
  96711. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  96712. /**
  96713. * Gets camera class name
  96714. * @returns AnaglyphArcRotateCamera
  96715. */
  96716. getClassName(): string;
  96717. }
  96718. }
  96719. declare module BABYLON {
  96720. /**
  96721. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  96722. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  96723. */
  96724. export class AnaglyphFreeCamera extends FreeCamera {
  96725. /**
  96726. * Creates a new AnaglyphFreeCamera
  96727. * @param name defines camera name
  96728. * @param position defines initial position
  96729. * @param interaxialDistance defines distance between each color axis
  96730. * @param scene defines the hosting scene
  96731. */
  96732. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  96733. /**
  96734. * Gets camera class name
  96735. * @returns AnaglyphFreeCamera
  96736. */
  96737. getClassName(): string;
  96738. }
  96739. }
  96740. declare module BABYLON {
  96741. /**
  96742. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  96743. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  96744. */
  96745. export class AnaglyphGamepadCamera extends GamepadCamera {
  96746. /**
  96747. * Creates a new AnaglyphGamepadCamera
  96748. * @param name defines camera name
  96749. * @param position defines initial position
  96750. * @param interaxialDistance defines distance between each color axis
  96751. * @param scene defines the hosting scene
  96752. */
  96753. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  96754. /**
  96755. * Gets camera class name
  96756. * @returns AnaglyphGamepadCamera
  96757. */
  96758. getClassName(): string;
  96759. }
  96760. }
  96761. declare module BABYLON {
  96762. /**
  96763. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  96764. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  96765. */
  96766. export class AnaglyphUniversalCamera extends UniversalCamera {
  96767. /**
  96768. * Creates a new AnaglyphUniversalCamera
  96769. * @param name defines camera name
  96770. * @param position defines initial position
  96771. * @param interaxialDistance defines distance between each color axis
  96772. * @param scene defines the hosting scene
  96773. */
  96774. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  96775. /**
  96776. * Gets camera class name
  96777. * @returns AnaglyphUniversalCamera
  96778. */
  96779. getClassName(): string;
  96780. }
  96781. }
  96782. declare module BABYLON {
  96783. /** @hidden */
  96784. export var stereoscopicInterlacePixelShader: {
  96785. name: string;
  96786. shader: string;
  96787. };
  96788. }
  96789. declare module BABYLON {
  96790. /**
  96791. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  96792. */
  96793. export class StereoscopicInterlacePostProcess extends PostProcess {
  96794. private _stepSize;
  96795. private _passedProcess;
  96796. /**
  96797. * Initializes a StereoscopicInterlacePostProcess
  96798. * @param name The name of the effect.
  96799. * @param rigCameras The rig cameras to be appled to the post process
  96800. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  96801. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  96802. * @param engine The engine which the post process will be applied. (default: current engine)
  96803. * @param reusable If the post process can be reused on the same frame. (default: false)
  96804. */
  96805. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  96806. }
  96807. }
  96808. declare module BABYLON {
  96809. /**
  96810. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  96811. * @see http://doc.babylonjs.com/features/cameras
  96812. */
  96813. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  96814. /**
  96815. * Creates a new StereoscopicArcRotateCamera
  96816. * @param name defines camera name
  96817. * @param alpha defines alpha angle (in radians)
  96818. * @param beta defines beta angle (in radians)
  96819. * @param radius defines radius
  96820. * @param target defines camera target
  96821. * @param interaxialDistance defines distance between each color axis
  96822. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  96823. * @param scene defines the hosting scene
  96824. */
  96825. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  96826. /**
  96827. * Gets camera class name
  96828. * @returns StereoscopicArcRotateCamera
  96829. */
  96830. getClassName(): string;
  96831. }
  96832. }
  96833. declare module BABYLON {
  96834. /**
  96835. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  96836. * @see http://doc.babylonjs.com/features/cameras
  96837. */
  96838. export class StereoscopicFreeCamera extends FreeCamera {
  96839. /**
  96840. * Creates a new StereoscopicFreeCamera
  96841. * @param name defines camera name
  96842. * @param position defines initial position
  96843. * @param interaxialDistance defines distance between each color axis
  96844. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  96845. * @param scene defines the hosting scene
  96846. */
  96847. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  96848. /**
  96849. * Gets camera class name
  96850. * @returns StereoscopicFreeCamera
  96851. */
  96852. getClassName(): string;
  96853. }
  96854. }
  96855. declare module BABYLON {
  96856. /**
  96857. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  96858. * @see http://doc.babylonjs.com/features/cameras
  96859. */
  96860. export class StereoscopicGamepadCamera extends GamepadCamera {
  96861. /**
  96862. * Creates a new StereoscopicGamepadCamera
  96863. * @param name defines camera name
  96864. * @param position defines initial position
  96865. * @param interaxialDistance defines distance between each color axis
  96866. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  96867. * @param scene defines the hosting scene
  96868. */
  96869. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  96870. /**
  96871. * Gets camera class name
  96872. * @returns StereoscopicGamepadCamera
  96873. */
  96874. getClassName(): string;
  96875. }
  96876. }
  96877. declare module BABYLON {
  96878. /**
  96879. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  96880. * @see http://doc.babylonjs.com/features/cameras
  96881. */
  96882. export class StereoscopicUniversalCamera extends UniversalCamera {
  96883. /**
  96884. * Creates a new StereoscopicUniversalCamera
  96885. * @param name defines camera name
  96886. * @param position defines initial position
  96887. * @param interaxialDistance defines distance between each color axis
  96888. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  96889. * @param scene defines the hosting scene
  96890. */
  96891. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  96892. /**
  96893. * Gets camera class name
  96894. * @returns StereoscopicUniversalCamera
  96895. */
  96896. getClassName(): string;
  96897. }
  96898. }
  96899. declare module BABYLON {
  96900. /**
  96901. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  96902. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  96903. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  96904. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  96905. */
  96906. export class VirtualJoysticksCamera extends FreeCamera {
  96907. /**
  96908. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  96909. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  96910. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  96911. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  96912. * @param name Define the name of the camera in the scene
  96913. * @param position Define the start position of the camera in the scene
  96914. * @param scene Define the scene the camera belongs to
  96915. */
  96916. constructor(name: string, position: Vector3, scene: Scene);
  96917. /**
  96918. * Gets the current object class name.
  96919. * @return the class name
  96920. */
  96921. getClassName(): string;
  96922. }
  96923. }
  96924. declare module BABYLON {
  96925. /**
  96926. * This represents all the required metrics to create a VR camera.
  96927. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  96928. */
  96929. export class VRCameraMetrics {
  96930. /**
  96931. * Define the horizontal resolution off the screen.
  96932. */
  96933. hResolution: number;
  96934. /**
  96935. * Define the vertical resolution off the screen.
  96936. */
  96937. vResolution: number;
  96938. /**
  96939. * Define the horizontal screen size.
  96940. */
  96941. hScreenSize: number;
  96942. /**
  96943. * Define the vertical screen size.
  96944. */
  96945. vScreenSize: number;
  96946. /**
  96947. * Define the vertical screen center position.
  96948. */
  96949. vScreenCenter: number;
  96950. /**
  96951. * Define the distance of the eyes to the screen.
  96952. */
  96953. eyeToScreenDistance: number;
  96954. /**
  96955. * Define the distance between both lenses
  96956. */
  96957. lensSeparationDistance: number;
  96958. /**
  96959. * Define the distance between both viewer's eyes.
  96960. */
  96961. interpupillaryDistance: number;
  96962. /**
  96963. * Define the distortion factor of the VR postprocess.
  96964. * Please, touch with care.
  96965. */
  96966. distortionK: number[];
  96967. /**
  96968. * Define the chromatic aberration correction factors for the VR post process.
  96969. */
  96970. chromaAbCorrection: number[];
  96971. /**
  96972. * Define the scale factor of the post process.
  96973. * The smaller the better but the slower.
  96974. */
  96975. postProcessScaleFactor: number;
  96976. /**
  96977. * Define an offset for the lens center.
  96978. */
  96979. lensCenterOffset: number;
  96980. /**
  96981. * Define if the current vr camera should compensate the distortion of the lense or not.
  96982. */
  96983. compensateDistortion: boolean;
  96984. /**
  96985. * Defines if multiview should be enabled when rendering (Default: false)
  96986. */
  96987. multiviewEnabled: boolean;
  96988. /**
  96989. * Gets the rendering aspect ratio based on the provided resolutions.
  96990. */
  96991. readonly aspectRatio: number;
  96992. /**
  96993. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  96994. */
  96995. readonly aspectRatioFov: number;
  96996. /**
  96997. * @hidden
  96998. */
  96999. readonly leftHMatrix: Matrix;
  97000. /**
  97001. * @hidden
  97002. */
  97003. readonly rightHMatrix: Matrix;
  97004. /**
  97005. * @hidden
  97006. */
  97007. readonly leftPreViewMatrix: Matrix;
  97008. /**
  97009. * @hidden
  97010. */
  97011. readonly rightPreViewMatrix: Matrix;
  97012. /**
  97013. * Get the default VRMetrics based on the most generic setup.
  97014. * @returns the default vr metrics
  97015. */
  97016. static GetDefault(): VRCameraMetrics;
  97017. }
  97018. }
  97019. declare module BABYLON {
  97020. /** @hidden */
  97021. export var vrDistortionCorrectionPixelShader: {
  97022. name: string;
  97023. shader: string;
  97024. };
  97025. }
  97026. declare module BABYLON {
  97027. /**
  97028. * VRDistortionCorrectionPostProcess used for mobile VR
  97029. */
  97030. export class VRDistortionCorrectionPostProcess extends PostProcess {
  97031. private _isRightEye;
  97032. private _distortionFactors;
  97033. private _postProcessScaleFactor;
  97034. private _lensCenterOffset;
  97035. private _scaleIn;
  97036. private _scaleFactor;
  97037. private _lensCenter;
  97038. /**
  97039. * Initializes the VRDistortionCorrectionPostProcess
  97040. * @param name The name of the effect.
  97041. * @param camera The camera to apply the render pass to.
  97042. * @param isRightEye If this is for the right eye distortion
  97043. * @param vrMetrics All the required metrics for the VR camera
  97044. */
  97045. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  97046. }
  97047. }
  97048. declare module BABYLON {
  97049. /**
  97050. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  97051. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  97052. */
  97053. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  97054. /**
  97055. * Creates a new VRDeviceOrientationArcRotateCamera
  97056. * @param name defines camera name
  97057. * @param alpha defines the camera rotation along the logitudinal axis
  97058. * @param beta defines the camera rotation along the latitudinal axis
  97059. * @param radius defines the camera distance from its target
  97060. * @param target defines the camera target
  97061. * @param scene defines the scene the camera belongs to
  97062. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  97063. * @param vrCameraMetrics defines the vr metrics associated to the camera
  97064. */
  97065. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  97066. /**
  97067. * Gets camera class name
  97068. * @returns VRDeviceOrientationArcRotateCamera
  97069. */
  97070. getClassName(): string;
  97071. }
  97072. }
  97073. declare module BABYLON {
  97074. /**
  97075. * Camera used to simulate VR rendering (based on FreeCamera)
  97076. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  97077. */
  97078. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  97079. /**
  97080. * Creates a new VRDeviceOrientationFreeCamera
  97081. * @param name defines camera name
  97082. * @param position defines the start position of the camera
  97083. * @param scene defines the scene the camera belongs to
  97084. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  97085. * @param vrCameraMetrics defines the vr metrics associated to the camera
  97086. */
  97087. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  97088. /**
  97089. * Gets camera class name
  97090. * @returns VRDeviceOrientationFreeCamera
  97091. */
  97092. getClassName(): string;
  97093. }
  97094. }
  97095. declare module BABYLON {
  97096. /**
  97097. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  97098. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  97099. */
  97100. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  97101. /**
  97102. * Creates a new VRDeviceOrientationGamepadCamera
  97103. * @param name defines camera name
  97104. * @param position defines the start position of the camera
  97105. * @param scene defines the scene the camera belongs to
  97106. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  97107. * @param vrCameraMetrics defines the vr metrics associated to the camera
  97108. */
  97109. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  97110. /**
  97111. * Gets camera class name
  97112. * @returns VRDeviceOrientationGamepadCamera
  97113. */
  97114. getClassName(): string;
  97115. }
  97116. }
  97117. declare module BABYLON {
  97118. /**
  97119. * Defines supported buttons for XBox360 compatible gamepads
  97120. */
  97121. export enum Xbox360Button {
  97122. /** A */
  97123. A = 0,
  97124. /** B */
  97125. B = 1,
  97126. /** X */
  97127. X = 2,
  97128. /** Y */
  97129. Y = 3,
  97130. /** Start */
  97131. Start = 4,
  97132. /** Back */
  97133. Back = 5,
  97134. /** Left button */
  97135. LB = 6,
  97136. /** Right button */
  97137. RB = 7,
  97138. /** Left stick */
  97139. LeftStick = 8,
  97140. /** Right stick */
  97141. RightStick = 9
  97142. }
  97143. /** Defines values for XBox360 DPad */
  97144. export enum Xbox360Dpad {
  97145. /** Up */
  97146. Up = 0,
  97147. /** Down */
  97148. Down = 1,
  97149. /** Left */
  97150. Left = 2,
  97151. /** Right */
  97152. Right = 3
  97153. }
  97154. /**
  97155. * Defines a XBox360 gamepad
  97156. */
  97157. export class Xbox360Pad extends Gamepad {
  97158. private _leftTrigger;
  97159. private _rightTrigger;
  97160. private _onlefttriggerchanged;
  97161. private _onrighttriggerchanged;
  97162. private _onbuttondown;
  97163. private _onbuttonup;
  97164. private _ondpaddown;
  97165. private _ondpadup;
  97166. /** Observable raised when a button is pressed */
  97167. onButtonDownObservable: Observable<Xbox360Button>;
  97168. /** Observable raised when a button is released */
  97169. onButtonUpObservable: Observable<Xbox360Button>;
  97170. /** Observable raised when a pad is pressed */
  97171. onPadDownObservable: Observable<Xbox360Dpad>;
  97172. /** Observable raised when a pad is released */
  97173. onPadUpObservable: Observable<Xbox360Dpad>;
  97174. private _buttonA;
  97175. private _buttonB;
  97176. private _buttonX;
  97177. private _buttonY;
  97178. private _buttonBack;
  97179. private _buttonStart;
  97180. private _buttonLB;
  97181. private _buttonRB;
  97182. private _buttonLeftStick;
  97183. private _buttonRightStick;
  97184. private _dPadUp;
  97185. private _dPadDown;
  97186. private _dPadLeft;
  97187. private _dPadRight;
  97188. private _isXboxOnePad;
  97189. /**
  97190. * Creates a new XBox360 gamepad object
  97191. * @param id defines the id of this gamepad
  97192. * @param index defines its index
  97193. * @param gamepad defines the internal HTML gamepad object
  97194. * @param xboxOne defines if it is a XBox One gamepad
  97195. */
  97196. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  97197. /**
  97198. * Defines the callback to call when left trigger is pressed
  97199. * @param callback defines the callback to use
  97200. */
  97201. onlefttriggerchanged(callback: (value: number) => void): void;
  97202. /**
  97203. * Defines the callback to call when right trigger is pressed
  97204. * @param callback defines the callback to use
  97205. */
  97206. onrighttriggerchanged(callback: (value: number) => void): void;
  97207. /**
  97208. * Gets the left trigger value
  97209. */
  97210. /**
  97211. * Sets the left trigger value
  97212. */
  97213. leftTrigger: number;
  97214. /**
  97215. * Gets the right trigger value
  97216. */
  97217. /**
  97218. * Sets the right trigger value
  97219. */
  97220. rightTrigger: number;
  97221. /**
  97222. * Defines the callback to call when a button is pressed
  97223. * @param callback defines the callback to use
  97224. */
  97225. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  97226. /**
  97227. * Defines the callback to call when a button is released
  97228. * @param callback defines the callback to use
  97229. */
  97230. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  97231. /**
  97232. * Defines the callback to call when a pad is pressed
  97233. * @param callback defines the callback to use
  97234. */
  97235. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  97236. /**
  97237. * Defines the callback to call when a pad is released
  97238. * @param callback defines the callback to use
  97239. */
  97240. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  97241. private _setButtonValue;
  97242. private _setDPadValue;
  97243. /**
  97244. * Gets the value of the `A` button
  97245. */
  97246. /**
  97247. * Sets the value of the `A` button
  97248. */
  97249. buttonA: number;
  97250. /**
  97251. * Gets the value of the `B` button
  97252. */
  97253. /**
  97254. * Sets the value of the `B` button
  97255. */
  97256. buttonB: number;
  97257. /**
  97258. * Gets the value of the `X` button
  97259. */
  97260. /**
  97261. * Sets the value of the `X` button
  97262. */
  97263. buttonX: number;
  97264. /**
  97265. * Gets the value of the `Y` button
  97266. */
  97267. /**
  97268. * Sets the value of the `Y` button
  97269. */
  97270. buttonY: number;
  97271. /**
  97272. * Gets the value of the `Start` button
  97273. */
  97274. /**
  97275. * Sets the value of the `Start` button
  97276. */
  97277. buttonStart: number;
  97278. /**
  97279. * Gets the value of the `Back` button
  97280. */
  97281. /**
  97282. * Sets the value of the `Back` button
  97283. */
  97284. buttonBack: number;
  97285. /**
  97286. * Gets the value of the `Left` button
  97287. */
  97288. /**
  97289. * Sets the value of the `Left` button
  97290. */
  97291. buttonLB: number;
  97292. /**
  97293. * Gets the value of the `Right` button
  97294. */
  97295. /**
  97296. * Sets the value of the `Right` button
  97297. */
  97298. buttonRB: number;
  97299. /**
  97300. * Gets the value of the Left joystick
  97301. */
  97302. /**
  97303. * Sets the value of the Left joystick
  97304. */
  97305. buttonLeftStick: number;
  97306. /**
  97307. * Gets the value of the Right joystick
  97308. */
  97309. /**
  97310. * Sets the value of the Right joystick
  97311. */
  97312. buttonRightStick: number;
  97313. /**
  97314. * Gets the value of D-pad up
  97315. */
  97316. /**
  97317. * Sets the value of D-pad up
  97318. */
  97319. dPadUp: number;
  97320. /**
  97321. * Gets the value of D-pad down
  97322. */
  97323. /**
  97324. * Sets the value of D-pad down
  97325. */
  97326. dPadDown: number;
  97327. /**
  97328. * Gets the value of D-pad left
  97329. */
  97330. /**
  97331. * Sets the value of D-pad left
  97332. */
  97333. dPadLeft: number;
  97334. /**
  97335. * Gets the value of D-pad right
  97336. */
  97337. /**
  97338. * Sets the value of D-pad right
  97339. */
  97340. dPadRight: number;
  97341. /**
  97342. * Force the gamepad to synchronize with device values
  97343. */
  97344. update(): void;
  97345. /**
  97346. * Disposes the gamepad
  97347. */
  97348. dispose(): void;
  97349. }
  97350. }
  97351. declare module BABYLON {
  97352. /**
  97353. * Base class of materials working in push mode in babylon JS
  97354. * @hidden
  97355. */
  97356. export class PushMaterial extends Material {
  97357. protected _activeEffect: Effect;
  97358. protected _normalMatrix: Matrix;
  97359. /**
  97360. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  97361. * This means that the material can keep using a previous shader while a new one is being compiled.
  97362. * This is mostly used when shader parallel compilation is supported (true by default)
  97363. */
  97364. allowShaderHotSwapping: boolean;
  97365. constructor(name: string, scene: Scene);
  97366. getEffect(): Effect;
  97367. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  97368. /**
  97369. * Binds the given world matrix to the active effect
  97370. *
  97371. * @param world the matrix to bind
  97372. */
  97373. bindOnlyWorldMatrix(world: Matrix): void;
  97374. /**
  97375. * Binds the given normal matrix to the active effect
  97376. *
  97377. * @param normalMatrix the matrix to bind
  97378. */
  97379. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  97380. bind(world: Matrix, mesh?: Mesh): void;
  97381. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  97382. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  97383. }
  97384. }
  97385. declare module BABYLON {
  97386. /**
  97387. * This groups all the flags used to control the materials channel.
  97388. */
  97389. export class MaterialFlags {
  97390. private static _DiffuseTextureEnabled;
  97391. /**
  97392. * Are diffuse textures enabled in the application.
  97393. */
  97394. static DiffuseTextureEnabled: boolean;
  97395. private static _AmbientTextureEnabled;
  97396. /**
  97397. * Are ambient textures enabled in the application.
  97398. */
  97399. static AmbientTextureEnabled: boolean;
  97400. private static _OpacityTextureEnabled;
  97401. /**
  97402. * Are opacity textures enabled in the application.
  97403. */
  97404. static OpacityTextureEnabled: boolean;
  97405. private static _ReflectionTextureEnabled;
  97406. /**
  97407. * Are reflection textures enabled in the application.
  97408. */
  97409. static ReflectionTextureEnabled: boolean;
  97410. private static _EmissiveTextureEnabled;
  97411. /**
  97412. * Are emissive textures enabled in the application.
  97413. */
  97414. static EmissiveTextureEnabled: boolean;
  97415. private static _SpecularTextureEnabled;
  97416. /**
  97417. * Are specular textures enabled in the application.
  97418. */
  97419. static SpecularTextureEnabled: boolean;
  97420. private static _BumpTextureEnabled;
  97421. /**
  97422. * Are bump textures enabled in the application.
  97423. */
  97424. static BumpTextureEnabled: boolean;
  97425. private static _LightmapTextureEnabled;
  97426. /**
  97427. * Are lightmap textures enabled in the application.
  97428. */
  97429. static LightmapTextureEnabled: boolean;
  97430. private static _RefractionTextureEnabled;
  97431. /**
  97432. * Are refraction textures enabled in the application.
  97433. */
  97434. static RefractionTextureEnabled: boolean;
  97435. private static _ColorGradingTextureEnabled;
  97436. /**
  97437. * Are color grading textures enabled in the application.
  97438. */
  97439. static ColorGradingTextureEnabled: boolean;
  97440. private static _FresnelEnabled;
  97441. /**
  97442. * Are fresnels enabled in the application.
  97443. */
  97444. static FresnelEnabled: boolean;
  97445. private static _ClearCoatTextureEnabled;
  97446. /**
  97447. * Are clear coat textures enabled in the application.
  97448. */
  97449. static ClearCoatTextureEnabled: boolean;
  97450. private static _ClearCoatBumpTextureEnabled;
  97451. /**
  97452. * Are clear coat bump textures enabled in the application.
  97453. */
  97454. static ClearCoatBumpTextureEnabled: boolean;
  97455. private static _ClearCoatTintTextureEnabled;
  97456. /**
  97457. * Are clear coat tint textures enabled in the application.
  97458. */
  97459. static ClearCoatTintTextureEnabled: boolean;
  97460. private static _SheenTextureEnabled;
  97461. /**
  97462. * Are sheen textures enabled in the application.
  97463. */
  97464. static SheenTextureEnabled: boolean;
  97465. private static _AnisotropicTextureEnabled;
  97466. /**
  97467. * Are anisotropic textures enabled in the application.
  97468. */
  97469. static AnisotropicTextureEnabled: boolean;
  97470. private static _ThicknessTextureEnabled;
  97471. /**
  97472. * Are thickness textures enabled in the application.
  97473. */
  97474. static ThicknessTextureEnabled: boolean;
  97475. }
  97476. }
  97477. declare module BABYLON {
  97478. /** @hidden */
  97479. export var defaultFragmentDeclaration: {
  97480. name: string;
  97481. shader: string;
  97482. };
  97483. }
  97484. declare module BABYLON {
  97485. /** @hidden */
  97486. export var defaultUboDeclaration: {
  97487. name: string;
  97488. shader: string;
  97489. };
  97490. }
  97491. declare module BABYLON {
  97492. /** @hidden */
  97493. export var lightFragmentDeclaration: {
  97494. name: string;
  97495. shader: string;
  97496. };
  97497. }
  97498. declare module BABYLON {
  97499. /** @hidden */
  97500. export var lightUboDeclaration: {
  97501. name: string;
  97502. shader: string;
  97503. };
  97504. }
  97505. declare module BABYLON {
  97506. /** @hidden */
  97507. export var lightsFragmentFunctions: {
  97508. name: string;
  97509. shader: string;
  97510. };
  97511. }
  97512. declare module BABYLON {
  97513. /** @hidden */
  97514. export var shadowsFragmentFunctions: {
  97515. name: string;
  97516. shader: string;
  97517. };
  97518. }
  97519. declare module BABYLON {
  97520. /** @hidden */
  97521. export var fresnelFunction: {
  97522. name: string;
  97523. shader: string;
  97524. };
  97525. }
  97526. declare module BABYLON {
  97527. /** @hidden */
  97528. export var reflectionFunction: {
  97529. name: string;
  97530. shader: string;
  97531. };
  97532. }
  97533. declare module BABYLON {
  97534. /** @hidden */
  97535. export var bumpFragmentFunctions: {
  97536. name: string;
  97537. shader: string;
  97538. };
  97539. }
  97540. declare module BABYLON {
  97541. /** @hidden */
  97542. export var logDepthDeclaration: {
  97543. name: string;
  97544. shader: string;
  97545. };
  97546. }
  97547. declare module BABYLON {
  97548. /** @hidden */
  97549. export var bumpFragment: {
  97550. name: string;
  97551. shader: string;
  97552. };
  97553. }
  97554. declare module BABYLON {
  97555. /** @hidden */
  97556. export var depthPrePass: {
  97557. name: string;
  97558. shader: string;
  97559. };
  97560. }
  97561. declare module BABYLON {
  97562. /** @hidden */
  97563. export var lightFragment: {
  97564. name: string;
  97565. shader: string;
  97566. };
  97567. }
  97568. declare module BABYLON {
  97569. /** @hidden */
  97570. export var logDepthFragment: {
  97571. name: string;
  97572. shader: string;
  97573. };
  97574. }
  97575. declare module BABYLON {
  97576. /** @hidden */
  97577. export var defaultPixelShader: {
  97578. name: string;
  97579. shader: string;
  97580. };
  97581. }
  97582. declare module BABYLON {
  97583. /** @hidden */
  97584. export var defaultVertexDeclaration: {
  97585. name: string;
  97586. shader: string;
  97587. };
  97588. }
  97589. declare module BABYLON {
  97590. /** @hidden */
  97591. export var bumpVertexDeclaration: {
  97592. name: string;
  97593. shader: string;
  97594. };
  97595. }
  97596. declare module BABYLON {
  97597. /** @hidden */
  97598. export var bumpVertex: {
  97599. name: string;
  97600. shader: string;
  97601. };
  97602. }
  97603. declare module BABYLON {
  97604. /** @hidden */
  97605. export var fogVertex: {
  97606. name: string;
  97607. shader: string;
  97608. };
  97609. }
  97610. declare module BABYLON {
  97611. /** @hidden */
  97612. export var shadowsVertex: {
  97613. name: string;
  97614. shader: string;
  97615. };
  97616. }
  97617. declare module BABYLON {
  97618. /** @hidden */
  97619. export var pointCloudVertex: {
  97620. name: string;
  97621. shader: string;
  97622. };
  97623. }
  97624. declare module BABYLON {
  97625. /** @hidden */
  97626. export var logDepthVertex: {
  97627. name: string;
  97628. shader: string;
  97629. };
  97630. }
  97631. declare module BABYLON {
  97632. /** @hidden */
  97633. export var defaultVertexShader: {
  97634. name: string;
  97635. shader: string;
  97636. };
  97637. }
  97638. declare module BABYLON {
  97639. /** @hidden */
  97640. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  97641. MAINUV1: boolean;
  97642. MAINUV2: boolean;
  97643. DIFFUSE: boolean;
  97644. DIFFUSEDIRECTUV: number;
  97645. AMBIENT: boolean;
  97646. AMBIENTDIRECTUV: number;
  97647. OPACITY: boolean;
  97648. OPACITYDIRECTUV: number;
  97649. OPACITYRGB: boolean;
  97650. REFLECTION: boolean;
  97651. EMISSIVE: boolean;
  97652. EMISSIVEDIRECTUV: number;
  97653. SPECULAR: boolean;
  97654. SPECULARDIRECTUV: number;
  97655. BUMP: boolean;
  97656. BUMPDIRECTUV: number;
  97657. PARALLAX: boolean;
  97658. PARALLAXOCCLUSION: boolean;
  97659. SPECULAROVERALPHA: boolean;
  97660. CLIPPLANE: boolean;
  97661. CLIPPLANE2: boolean;
  97662. CLIPPLANE3: boolean;
  97663. CLIPPLANE4: boolean;
  97664. ALPHATEST: boolean;
  97665. DEPTHPREPASS: boolean;
  97666. ALPHAFROMDIFFUSE: boolean;
  97667. POINTSIZE: boolean;
  97668. FOG: boolean;
  97669. SPECULARTERM: boolean;
  97670. DIFFUSEFRESNEL: boolean;
  97671. OPACITYFRESNEL: boolean;
  97672. REFLECTIONFRESNEL: boolean;
  97673. REFRACTIONFRESNEL: boolean;
  97674. EMISSIVEFRESNEL: boolean;
  97675. FRESNEL: boolean;
  97676. NORMAL: boolean;
  97677. UV1: boolean;
  97678. UV2: boolean;
  97679. VERTEXCOLOR: boolean;
  97680. VERTEXALPHA: boolean;
  97681. NUM_BONE_INFLUENCERS: number;
  97682. BonesPerMesh: number;
  97683. BONETEXTURE: boolean;
  97684. INSTANCES: boolean;
  97685. GLOSSINESS: boolean;
  97686. ROUGHNESS: boolean;
  97687. EMISSIVEASILLUMINATION: boolean;
  97688. LINKEMISSIVEWITHDIFFUSE: boolean;
  97689. REFLECTIONFRESNELFROMSPECULAR: boolean;
  97690. LIGHTMAP: boolean;
  97691. LIGHTMAPDIRECTUV: number;
  97692. OBJECTSPACE_NORMALMAP: boolean;
  97693. USELIGHTMAPASSHADOWMAP: boolean;
  97694. REFLECTIONMAP_3D: boolean;
  97695. REFLECTIONMAP_SPHERICAL: boolean;
  97696. REFLECTIONMAP_PLANAR: boolean;
  97697. REFLECTIONMAP_CUBIC: boolean;
  97698. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  97699. REFLECTIONMAP_PROJECTION: boolean;
  97700. REFLECTIONMAP_SKYBOX: boolean;
  97701. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  97702. REFLECTIONMAP_EXPLICIT: boolean;
  97703. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  97704. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  97705. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  97706. INVERTCUBICMAP: boolean;
  97707. LOGARITHMICDEPTH: boolean;
  97708. REFRACTION: boolean;
  97709. REFRACTIONMAP_3D: boolean;
  97710. REFLECTIONOVERALPHA: boolean;
  97711. TWOSIDEDLIGHTING: boolean;
  97712. SHADOWFLOAT: boolean;
  97713. MORPHTARGETS: boolean;
  97714. MORPHTARGETS_NORMAL: boolean;
  97715. MORPHTARGETS_TANGENT: boolean;
  97716. NUM_MORPH_INFLUENCERS: number;
  97717. NONUNIFORMSCALING: boolean;
  97718. PREMULTIPLYALPHA: boolean;
  97719. IMAGEPROCESSING: boolean;
  97720. VIGNETTE: boolean;
  97721. VIGNETTEBLENDMODEMULTIPLY: boolean;
  97722. VIGNETTEBLENDMODEOPAQUE: boolean;
  97723. TONEMAPPING: boolean;
  97724. TONEMAPPING_ACES: boolean;
  97725. CONTRAST: boolean;
  97726. COLORCURVES: boolean;
  97727. COLORGRADING: boolean;
  97728. COLORGRADING3D: boolean;
  97729. SAMPLER3DGREENDEPTH: boolean;
  97730. SAMPLER3DBGRMAP: boolean;
  97731. IMAGEPROCESSINGPOSTPROCESS: boolean;
  97732. MULTIVIEW: boolean;
  97733. /**
  97734. * If the reflection texture on this material is in linear color space
  97735. * @hidden
  97736. */
  97737. IS_REFLECTION_LINEAR: boolean;
  97738. /**
  97739. * If the refraction texture on this material is in linear color space
  97740. * @hidden
  97741. */
  97742. IS_REFRACTION_LINEAR: boolean;
  97743. EXPOSURE: boolean;
  97744. constructor();
  97745. setReflectionMode(modeToEnable: string): void;
  97746. }
  97747. /**
  97748. * This is the default material used in Babylon. It is the best trade off between quality
  97749. * and performances.
  97750. * @see http://doc.babylonjs.com/babylon101/materials
  97751. */
  97752. export class StandardMaterial extends PushMaterial {
  97753. private _diffuseTexture;
  97754. /**
  97755. * The basic texture of the material as viewed under a light.
  97756. */
  97757. diffuseTexture: Nullable<BaseTexture>;
  97758. private _ambientTexture;
  97759. /**
  97760. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  97761. */
  97762. ambientTexture: Nullable<BaseTexture>;
  97763. private _opacityTexture;
  97764. /**
  97765. * Define the transparency of the material from a texture.
  97766. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  97767. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  97768. */
  97769. opacityTexture: Nullable<BaseTexture>;
  97770. private _reflectionTexture;
  97771. /**
  97772. * Define the texture used to display the reflection.
  97773. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  97774. */
  97775. reflectionTexture: Nullable<BaseTexture>;
  97776. private _emissiveTexture;
  97777. /**
  97778. * Define texture of the material as if self lit.
  97779. * This will be mixed in the final result even in the absence of light.
  97780. */
  97781. emissiveTexture: Nullable<BaseTexture>;
  97782. private _specularTexture;
  97783. /**
  97784. * Define how the color and intensity of the highlight given by the light in the material.
  97785. */
  97786. specularTexture: Nullable<BaseTexture>;
  97787. private _bumpTexture;
  97788. /**
  97789. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  97790. * 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.
  97791. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  97792. */
  97793. bumpTexture: Nullable<BaseTexture>;
  97794. private _lightmapTexture;
  97795. /**
  97796. * Complex lighting can be computationally expensive to compute at runtime.
  97797. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  97798. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  97799. */
  97800. lightmapTexture: Nullable<BaseTexture>;
  97801. private _refractionTexture;
  97802. /**
  97803. * Define the texture used to display the refraction.
  97804. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  97805. */
  97806. refractionTexture: Nullable<BaseTexture>;
  97807. /**
  97808. * The color of the material lit by the environmental background lighting.
  97809. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  97810. */
  97811. ambientColor: Color3;
  97812. /**
  97813. * The basic color of the material as viewed under a light.
  97814. */
  97815. diffuseColor: Color3;
  97816. /**
  97817. * Define how the color and intensity of the highlight given by the light in the material.
  97818. */
  97819. specularColor: Color3;
  97820. /**
  97821. * Define the color of the material as if self lit.
  97822. * This will be mixed in the final result even in the absence of light.
  97823. */
  97824. emissiveColor: Color3;
  97825. /**
  97826. * Defines how sharp are the highlights in the material.
  97827. * The bigger the value the sharper giving a more glossy feeling to the result.
  97828. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  97829. */
  97830. specularPower: number;
  97831. private _useAlphaFromDiffuseTexture;
  97832. /**
  97833. * Does the transparency come from the diffuse texture alpha channel.
  97834. */
  97835. useAlphaFromDiffuseTexture: boolean;
  97836. private _useEmissiveAsIllumination;
  97837. /**
  97838. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  97839. */
  97840. useEmissiveAsIllumination: boolean;
  97841. private _linkEmissiveWithDiffuse;
  97842. /**
  97843. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  97844. * the emissive level when the final color is close to one.
  97845. */
  97846. linkEmissiveWithDiffuse: boolean;
  97847. private _useSpecularOverAlpha;
  97848. /**
  97849. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  97850. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  97851. */
  97852. useSpecularOverAlpha: boolean;
  97853. private _useReflectionOverAlpha;
  97854. /**
  97855. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  97856. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  97857. */
  97858. useReflectionOverAlpha: boolean;
  97859. private _disableLighting;
  97860. /**
  97861. * Does lights from the scene impacts this material.
  97862. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  97863. */
  97864. disableLighting: boolean;
  97865. private _useObjectSpaceNormalMap;
  97866. /**
  97867. * Allows using an object space normal map (instead of tangent space).
  97868. */
  97869. useObjectSpaceNormalMap: boolean;
  97870. private _useParallax;
  97871. /**
  97872. * Is parallax enabled or not.
  97873. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  97874. */
  97875. useParallax: boolean;
  97876. private _useParallaxOcclusion;
  97877. /**
  97878. * Is parallax occlusion enabled or not.
  97879. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  97880. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  97881. */
  97882. useParallaxOcclusion: boolean;
  97883. /**
  97884. * 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.
  97885. */
  97886. parallaxScaleBias: number;
  97887. private _roughness;
  97888. /**
  97889. * Helps to define how blurry the reflections should appears in the material.
  97890. */
  97891. roughness: number;
  97892. /**
  97893. * In case of refraction, define the value of the indice of refraction.
  97894. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  97895. */
  97896. indexOfRefraction: number;
  97897. /**
  97898. * Invert the refraction texture alongside the y axis.
  97899. * It can be useful with procedural textures or probe for instance.
  97900. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  97901. */
  97902. invertRefractionY: boolean;
  97903. /**
  97904. * Defines the alpha limits in alpha test mode.
  97905. */
  97906. alphaCutOff: number;
  97907. private _useLightmapAsShadowmap;
  97908. /**
  97909. * In case of light mapping, define whether the map contains light or shadow informations.
  97910. */
  97911. useLightmapAsShadowmap: boolean;
  97912. private _diffuseFresnelParameters;
  97913. /**
  97914. * Define the diffuse fresnel parameters of the material.
  97915. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  97916. */
  97917. diffuseFresnelParameters: FresnelParameters;
  97918. private _opacityFresnelParameters;
  97919. /**
  97920. * Define the opacity fresnel parameters of the material.
  97921. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  97922. */
  97923. opacityFresnelParameters: FresnelParameters;
  97924. private _reflectionFresnelParameters;
  97925. /**
  97926. * Define the reflection fresnel parameters of the material.
  97927. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  97928. */
  97929. reflectionFresnelParameters: FresnelParameters;
  97930. private _refractionFresnelParameters;
  97931. /**
  97932. * Define the refraction fresnel parameters of the material.
  97933. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  97934. */
  97935. refractionFresnelParameters: FresnelParameters;
  97936. private _emissiveFresnelParameters;
  97937. /**
  97938. * Define the emissive fresnel parameters of the material.
  97939. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  97940. */
  97941. emissiveFresnelParameters: FresnelParameters;
  97942. private _useReflectionFresnelFromSpecular;
  97943. /**
  97944. * If true automatically deducts the fresnels values from the material specularity.
  97945. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  97946. */
  97947. useReflectionFresnelFromSpecular: boolean;
  97948. private _useGlossinessFromSpecularMapAlpha;
  97949. /**
  97950. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  97951. */
  97952. useGlossinessFromSpecularMapAlpha: boolean;
  97953. private _maxSimultaneousLights;
  97954. /**
  97955. * Defines the maximum number of lights that can be used in the material
  97956. */
  97957. maxSimultaneousLights: number;
  97958. private _invertNormalMapX;
  97959. /**
  97960. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  97961. */
  97962. invertNormalMapX: boolean;
  97963. private _invertNormalMapY;
  97964. /**
  97965. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  97966. */
  97967. invertNormalMapY: boolean;
  97968. private _twoSidedLighting;
  97969. /**
  97970. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  97971. */
  97972. twoSidedLighting: boolean;
  97973. /**
  97974. * Default configuration related to image processing available in the standard Material.
  97975. */
  97976. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  97977. /**
  97978. * Gets the image processing configuration used either in this material.
  97979. */
  97980. /**
  97981. * Sets the Default image processing configuration used either in the this material.
  97982. *
  97983. * If sets to null, the scene one is in use.
  97984. */
  97985. imageProcessingConfiguration: ImageProcessingConfiguration;
  97986. /**
  97987. * Keep track of the image processing observer to allow dispose and replace.
  97988. */
  97989. private _imageProcessingObserver;
  97990. /**
  97991. * Attaches a new image processing configuration to the Standard Material.
  97992. * @param configuration
  97993. */
  97994. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  97995. /**
  97996. * Gets wether the color curves effect is enabled.
  97997. */
  97998. /**
  97999. * Sets wether the color curves effect is enabled.
  98000. */
  98001. cameraColorCurvesEnabled: boolean;
  98002. /**
  98003. * Gets wether the color grading effect is enabled.
  98004. */
  98005. /**
  98006. * Gets wether the color grading effect is enabled.
  98007. */
  98008. cameraColorGradingEnabled: boolean;
  98009. /**
  98010. * Gets wether tonemapping is enabled or not.
  98011. */
  98012. /**
  98013. * Sets wether tonemapping is enabled or not
  98014. */
  98015. cameraToneMappingEnabled: boolean;
  98016. /**
  98017. * The camera exposure used on this material.
  98018. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  98019. * This corresponds to a photographic exposure.
  98020. */
  98021. /**
  98022. * The camera exposure used on this material.
  98023. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  98024. * This corresponds to a photographic exposure.
  98025. */
  98026. cameraExposure: number;
  98027. /**
  98028. * Gets The camera contrast used on this material.
  98029. */
  98030. /**
  98031. * Sets The camera contrast used on this material.
  98032. */
  98033. cameraContrast: number;
  98034. /**
  98035. * Gets the Color Grading 2D Lookup Texture.
  98036. */
  98037. /**
  98038. * Sets the Color Grading 2D Lookup Texture.
  98039. */
  98040. cameraColorGradingTexture: Nullable<BaseTexture>;
  98041. /**
  98042. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  98043. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  98044. * 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;
  98045. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  98046. */
  98047. /**
  98048. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  98049. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  98050. * 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;
  98051. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  98052. */
  98053. cameraColorCurves: Nullable<ColorCurves>;
  98054. /**
  98055. * Custom callback helping to override the default shader used in the material.
  98056. */
  98057. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  98058. protected _renderTargets: SmartArray<RenderTargetTexture>;
  98059. protected _worldViewProjectionMatrix: Matrix;
  98060. protected _globalAmbientColor: Color3;
  98061. protected _useLogarithmicDepth: boolean;
  98062. /**
  98063. * Instantiates a new standard material.
  98064. * This is the default material used in Babylon. It is the best trade off between quality
  98065. * and performances.
  98066. * @see http://doc.babylonjs.com/babylon101/materials
  98067. * @param name Define the name of the material in the scene
  98068. * @param scene Define the scene the material belong to
  98069. */
  98070. constructor(name: string, scene: Scene);
  98071. /**
  98072. * Gets a boolean indicating that current material needs to register RTT
  98073. */
  98074. readonly hasRenderTargetTextures: boolean;
  98075. /**
  98076. * Gets the current class name of the material e.g. "StandardMaterial"
  98077. * Mainly use in serialization.
  98078. * @returns the class name
  98079. */
  98080. getClassName(): string;
  98081. /**
  98082. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  98083. * You can try switching to logarithmic depth.
  98084. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  98085. */
  98086. useLogarithmicDepth: boolean;
  98087. /**
  98088. * Specifies if the material will require alpha blending
  98089. * @returns a boolean specifying if alpha blending is needed
  98090. */
  98091. needAlphaBlending(): boolean;
  98092. /**
  98093. * Specifies if this material should be rendered in alpha test mode
  98094. * @returns a boolean specifying if an alpha test is needed.
  98095. */
  98096. needAlphaTesting(): boolean;
  98097. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  98098. /**
  98099. * Get the texture used for alpha test purpose.
  98100. * @returns the diffuse texture in case of the standard material.
  98101. */
  98102. getAlphaTestTexture(): Nullable<BaseTexture>;
  98103. /**
  98104. * Get if the submesh is ready to be used and all its information available.
  98105. * Child classes can use it to update shaders
  98106. * @param mesh defines the mesh to check
  98107. * @param subMesh defines which submesh to check
  98108. * @param useInstances specifies that instances should be used
  98109. * @returns a boolean indicating that the submesh is ready or not
  98110. */
  98111. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  98112. /**
  98113. * Builds the material UBO layouts.
  98114. * Used internally during the effect preparation.
  98115. */
  98116. buildUniformLayout(): void;
  98117. /**
  98118. * Unbinds the material from the mesh
  98119. */
  98120. unbind(): void;
  98121. /**
  98122. * Binds the submesh to this material by preparing the effect and shader to draw
  98123. * @param world defines the world transformation matrix
  98124. * @param mesh defines the mesh containing the submesh
  98125. * @param subMesh defines the submesh to bind the material to
  98126. */
  98127. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  98128. /**
  98129. * Get the list of animatables in the material.
  98130. * @returns the list of animatables object used in the material
  98131. */
  98132. getAnimatables(): IAnimatable[];
  98133. /**
  98134. * Gets the active textures from the material
  98135. * @returns an array of textures
  98136. */
  98137. getActiveTextures(): BaseTexture[];
  98138. /**
  98139. * Specifies if the material uses a texture
  98140. * @param texture defines the texture to check against the material
  98141. * @returns a boolean specifying if the material uses the texture
  98142. */
  98143. hasTexture(texture: BaseTexture): boolean;
  98144. /**
  98145. * Disposes the material
  98146. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  98147. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  98148. */
  98149. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  98150. /**
  98151. * Makes a duplicate of the material, and gives it a new name
  98152. * @param name defines the new name for the duplicated material
  98153. * @returns the cloned material
  98154. */
  98155. clone(name: string): StandardMaterial;
  98156. /**
  98157. * Serializes this material in a JSON representation
  98158. * @returns the serialized material object
  98159. */
  98160. serialize(): any;
  98161. /**
  98162. * Creates a standard material from parsed material data
  98163. * @param source defines the JSON representation of the material
  98164. * @param scene defines the hosting scene
  98165. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  98166. * @returns a new standard material
  98167. */
  98168. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  98169. /**
  98170. * Are diffuse textures enabled in the application.
  98171. */
  98172. static DiffuseTextureEnabled: boolean;
  98173. /**
  98174. * Are ambient textures enabled in the application.
  98175. */
  98176. static AmbientTextureEnabled: boolean;
  98177. /**
  98178. * Are opacity textures enabled in the application.
  98179. */
  98180. static OpacityTextureEnabled: boolean;
  98181. /**
  98182. * Are reflection textures enabled in the application.
  98183. */
  98184. static ReflectionTextureEnabled: boolean;
  98185. /**
  98186. * Are emissive textures enabled in the application.
  98187. */
  98188. static EmissiveTextureEnabled: boolean;
  98189. /**
  98190. * Are specular textures enabled in the application.
  98191. */
  98192. static SpecularTextureEnabled: boolean;
  98193. /**
  98194. * Are bump textures enabled in the application.
  98195. */
  98196. static BumpTextureEnabled: boolean;
  98197. /**
  98198. * Are lightmap textures enabled in the application.
  98199. */
  98200. static LightmapTextureEnabled: boolean;
  98201. /**
  98202. * Are refraction textures enabled in the application.
  98203. */
  98204. static RefractionTextureEnabled: boolean;
  98205. /**
  98206. * Are color grading textures enabled in the application.
  98207. */
  98208. static ColorGradingTextureEnabled: boolean;
  98209. /**
  98210. * Are fresnels enabled in the application.
  98211. */
  98212. static FresnelEnabled: boolean;
  98213. }
  98214. }
  98215. declare module BABYLON {
  98216. /**
  98217. * A class extending Texture allowing drawing on a texture
  98218. * @see http://doc.babylonjs.com/how_to/dynamictexture
  98219. */
  98220. export class DynamicTexture extends Texture {
  98221. private _generateMipMaps;
  98222. private _canvas;
  98223. private _context;
  98224. private _engine;
  98225. /**
  98226. * Creates a DynamicTexture
  98227. * @param name defines the name of the texture
  98228. * @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
  98229. * @param scene defines the scene where you want the texture
  98230. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  98231. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  98232. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  98233. */
  98234. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  98235. /**
  98236. * Get the current class name of the texture useful for serialization or dynamic coding.
  98237. * @returns "DynamicTexture"
  98238. */
  98239. getClassName(): string;
  98240. /**
  98241. * Gets the current state of canRescale
  98242. */
  98243. readonly canRescale: boolean;
  98244. private _recreate;
  98245. /**
  98246. * Scales the texture
  98247. * @param ratio the scale factor to apply to both width and height
  98248. */
  98249. scale(ratio: number): void;
  98250. /**
  98251. * Resizes the texture
  98252. * @param width the new width
  98253. * @param height the new height
  98254. */
  98255. scaleTo(width: number, height: number): void;
  98256. /**
  98257. * Gets the context of the canvas used by the texture
  98258. * @returns the canvas context of the dynamic texture
  98259. */
  98260. getContext(): CanvasRenderingContext2D;
  98261. /**
  98262. * Clears the texture
  98263. */
  98264. clear(): void;
  98265. /**
  98266. * Updates the texture
  98267. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  98268. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  98269. */
  98270. update(invertY?: boolean, premulAlpha?: boolean): void;
  98271. /**
  98272. * Draws text onto the texture
  98273. * @param text defines the text to be drawn
  98274. * @param x defines the placement of the text from the left
  98275. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  98276. * @param font defines the font to be used with font-style, font-size, font-name
  98277. * @param color defines the color used for the text
  98278. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  98279. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  98280. * @param update defines whether texture is immediately update (default is true)
  98281. */
  98282. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  98283. /**
  98284. * Clones the texture
  98285. * @returns the clone of the texture.
  98286. */
  98287. clone(): DynamicTexture;
  98288. /**
  98289. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  98290. * @returns a serialized dynamic texture object
  98291. */
  98292. serialize(): any;
  98293. /** @hidden */
  98294. _rebuild(): void;
  98295. }
  98296. }
  98297. declare module BABYLON {
  98298. /** @hidden */
  98299. export var imageProcessingPixelShader: {
  98300. name: string;
  98301. shader: string;
  98302. };
  98303. }
  98304. declare module BABYLON {
  98305. /**
  98306. * ImageProcessingPostProcess
  98307. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  98308. */
  98309. export class ImageProcessingPostProcess extends PostProcess {
  98310. /**
  98311. * Default configuration related to image processing available in the PBR Material.
  98312. */
  98313. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  98314. /**
  98315. * Gets the image processing configuration used either in this material.
  98316. */
  98317. /**
  98318. * Sets the Default image processing configuration used either in the this material.
  98319. *
  98320. * If sets to null, the scene one is in use.
  98321. */
  98322. imageProcessingConfiguration: ImageProcessingConfiguration;
  98323. /**
  98324. * Keep track of the image processing observer to allow dispose and replace.
  98325. */
  98326. private _imageProcessingObserver;
  98327. /**
  98328. * Attaches a new image processing configuration to the PBR Material.
  98329. * @param configuration
  98330. */
  98331. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  98332. /**
  98333. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  98334. */
  98335. /**
  98336. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  98337. */
  98338. colorCurves: Nullable<ColorCurves>;
  98339. /**
  98340. * Gets wether the color curves effect is enabled.
  98341. */
  98342. /**
  98343. * Sets wether the color curves effect is enabled.
  98344. */
  98345. colorCurvesEnabled: boolean;
  98346. /**
  98347. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  98348. */
  98349. /**
  98350. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  98351. */
  98352. colorGradingTexture: Nullable<BaseTexture>;
  98353. /**
  98354. * Gets wether the color grading effect is enabled.
  98355. */
  98356. /**
  98357. * Gets wether the color grading effect is enabled.
  98358. */
  98359. colorGradingEnabled: boolean;
  98360. /**
  98361. * Gets exposure used in the effect.
  98362. */
  98363. /**
  98364. * Sets exposure used in the effect.
  98365. */
  98366. exposure: number;
  98367. /**
  98368. * Gets wether tonemapping is enabled or not.
  98369. */
  98370. /**
  98371. * Sets wether tonemapping is enabled or not
  98372. */
  98373. toneMappingEnabled: boolean;
  98374. /**
  98375. * Gets the type of tone mapping effect.
  98376. */
  98377. /**
  98378. * Sets the type of tone mapping effect.
  98379. */
  98380. toneMappingType: number;
  98381. /**
  98382. * Gets contrast used in the effect.
  98383. */
  98384. /**
  98385. * Sets contrast used in the effect.
  98386. */
  98387. contrast: number;
  98388. /**
  98389. * Gets Vignette stretch size.
  98390. */
  98391. /**
  98392. * Sets Vignette stretch size.
  98393. */
  98394. vignetteStretch: number;
  98395. /**
  98396. * Gets Vignette centre X Offset.
  98397. */
  98398. /**
  98399. * Sets Vignette centre X Offset.
  98400. */
  98401. vignetteCentreX: number;
  98402. /**
  98403. * Gets Vignette centre Y Offset.
  98404. */
  98405. /**
  98406. * Sets Vignette centre Y Offset.
  98407. */
  98408. vignetteCentreY: number;
  98409. /**
  98410. * Gets Vignette weight or intensity of the vignette effect.
  98411. */
  98412. /**
  98413. * Sets Vignette weight or intensity of the vignette effect.
  98414. */
  98415. vignetteWeight: number;
  98416. /**
  98417. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  98418. * if vignetteEnabled is set to true.
  98419. */
  98420. /**
  98421. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  98422. * if vignetteEnabled is set to true.
  98423. */
  98424. vignetteColor: Color4;
  98425. /**
  98426. * Gets Camera field of view used by the Vignette effect.
  98427. */
  98428. /**
  98429. * Sets Camera field of view used by the Vignette effect.
  98430. */
  98431. vignetteCameraFov: number;
  98432. /**
  98433. * Gets the vignette blend mode allowing different kind of effect.
  98434. */
  98435. /**
  98436. * Sets the vignette blend mode allowing different kind of effect.
  98437. */
  98438. vignetteBlendMode: number;
  98439. /**
  98440. * Gets wether the vignette effect is enabled.
  98441. */
  98442. /**
  98443. * Sets wether the vignette effect is enabled.
  98444. */
  98445. vignetteEnabled: boolean;
  98446. private _fromLinearSpace;
  98447. /**
  98448. * Gets wether the input of the processing is in Gamma or Linear Space.
  98449. */
  98450. /**
  98451. * Sets wether the input of the processing is in Gamma or Linear Space.
  98452. */
  98453. fromLinearSpace: boolean;
  98454. /**
  98455. * Defines cache preventing GC.
  98456. */
  98457. private _defines;
  98458. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  98459. /**
  98460. * "ImageProcessingPostProcess"
  98461. * @returns "ImageProcessingPostProcess"
  98462. */
  98463. getClassName(): string;
  98464. protected _updateParameters(): void;
  98465. dispose(camera?: Camera): void;
  98466. }
  98467. }
  98468. declare module BABYLON {
  98469. /**
  98470. * Class containing static functions to help procedurally build meshes
  98471. */
  98472. export class GroundBuilder {
  98473. /**
  98474. * Creates a ground mesh
  98475. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  98476. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  98477. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  98478. * @param name defines the name of the mesh
  98479. * @param options defines the options used to create the mesh
  98480. * @param scene defines the hosting scene
  98481. * @returns the ground mesh
  98482. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  98483. */
  98484. static CreateGround(name: string, options: {
  98485. width?: number;
  98486. height?: number;
  98487. subdivisions?: number;
  98488. subdivisionsX?: number;
  98489. subdivisionsY?: number;
  98490. updatable?: boolean;
  98491. }, scene: any): Mesh;
  98492. /**
  98493. * Creates a tiled ground mesh
  98494. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  98495. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  98496. * * 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
  98497. * * 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
  98498. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  98499. * @param name defines the name of the mesh
  98500. * @param options defines the options used to create the mesh
  98501. * @param scene defines the hosting scene
  98502. * @returns the tiled ground mesh
  98503. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  98504. */
  98505. static CreateTiledGround(name: string, options: {
  98506. xmin: number;
  98507. zmin: number;
  98508. xmax: number;
  98509. zmax: number;
  98510. subdivisions?: {
  98511. w: number;
  98512. h: number;
  98513. };
  98514. precision?: {
  98515. w: number;
  98516. h: number;
  98517. };
  98518. updatable?: boolean;
  98519. }, scene?: Nullable<Scene>): Mesh;
  98520. /**
  98521. * Creates a ground mesh from a height map
  98522. * * The parameter `url` sets the URL of the height map image resource.
  98523. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  98524. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  98525. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  98526. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  98527. * * 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.
  98528. * * 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).
  98529. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  98530. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  98531. * @param name defines the name of the mesh
  98532. * @param url defines the url to the height map
  98533. * @param options defines the options used to create the mesh
  98534. * @param scene defines the hosting scene
  98535. * @returns the ground mesh
  98536. * @see https://doc.babylonjs.com/babylon101/height_map
  98537. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  98538. */
  98539. static CreateGroundFromHeightMap(name: string, url: string, options: {
  98540. width?: number;
  98541. height?: number;
  98542. subdivisions?: number;
  98543. minHeight?: number;
  98544. maxHeight?: number;
  98545. colorFilter?: Color3;
  98546. alphaFilter?: number;
  98547. updatable?: boolean;
  98548. onReady?: (mesh: GroundMesh) => void;
  98549. }, scene?: Nullable<Scene>): GroundMesh;
  98550. }
  98551. }
  98552. declare module BABYLON {
  98553. /**
  98554. * Class containing static functions to help procedurally build meshes
  98555. */
  98556. export class TorusBuilder {
  98557. /**
  98558. * Creates a torus mesh
  98559. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  98560. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  98561. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  98562. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  98563. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  98564. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  98565. * @param name defines the name of the mesh
  98566. * @param options defines the options used to create the mesh
  98567. * @param scene defines the hosting scene
  98568. * @returns the torus mesh
  98569. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  98570. */
  98571. static CreateTorus(name: string, options: {
  98572. diameter?: number;
  98573. thickness?: number;
  98574. tessellation?: number;
  98575. updatable?: boolean;
  98576. sideOrientation?: number;
  98577. frontUVs?: Vector4;
  98578. backUVs?: Vector4;
  98579. }, scene: any): Mesh;
  98580. }
  98581. }
  98582. declare module BABYLON {
  98583. /**
  98584. * Class containing static functions to help procedurally build meshes
  98585. */
  98586. export class CylinderBuilder {
  98587. /**
  98588. * Creates a cylinder or a cone mesh
  98589. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  98590. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  98591. * * 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.
  98592. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  98593. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  98594. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  98595. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  98596. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  98597. * * 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).
  98598. * * 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
  98599. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  98600. * * 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
  98601. * * 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.
  98602. * * If `enclose` is false, a ring surface is one element.
  98603. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  98604. * * 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
  98605. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  98606. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  98607. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  98608. * @param name defines the name of the mesh
  98609. * @param options defines the options used to create the mesh
  98610. * @param scene defines the hosting scene
  98611. * @returns the cylinder mesh
  98612. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  98613. */
  98614. static CreateCylinder(name: string, options: {
  98615. height?: number;
  98616. diameterTop?: number;
  98617. diameterBottom?: number;
  98618. diameter?: number;
  98619. tessellation?: number;
  98620. subdivisions?: number;
  98621. arc?: number;
  98622. faceColors?: Color4[];
  98623. faceUV?: Vector4[];
  98624. updatable?: boolean;
  98625. hasRings?: boolean;
  98626. enclose?: boolean;
  98627. sideOrientation?: number;
  98628. frontUVs?: Vector4;
  98629. backUVs?: Vector4;
  98630. }, scene: any): Mesh;
  98631. }
  98632. }
  98633. declare module BABYLON {
  98634. /**
  98635. * Manager for handling gamepads
  98636. */
  98637. export class GamepadManager {
  98638. private _scene?;
  98639. private _babylonGamepads;
  98640. private _oneGamepadConnected;
  98641. /** @hidden */
  98642. _isMonitoring: boolean;
  98643. private _gamepadEventSupported;
  98644. private _gamepadSupport;
  98645. /**
  98646. * observable to be triggered when the gamepad controller has been connected
  98647. */
  98648. onGamepadConnectedObservable: Observable<Gamepad>;
  98649. /**
  98650. * observable to be triggered when the gamepad controller has been disconnected
  98651. */
  98652. onGamepadDisconnectedObservable: Observable<Gamepad>;
  98653. private _onGamepadConnectedEvent;
  98654. private _onGamepadDisconnectedEvent;
  98655. /**
  98656. * Initializes the gamepad manager
  98657. * @param _scene BabylonJS scene
  98658. */
  98659. constructor(_scene?: Scene | undefined);
  98660. /**
  98661. * The gamepads in the game pad manager
  98662. */
  98663. readonly gamepads: Gamepad[];
  98664. /**
  98665. * Get the gamepad controllers based on type
  98666. * @param type The type of gamepad controller
  98667. * @returns Nullable gamepad
  98668. */
  98669. getGamepadByType(type?: number): Nullable<Gamepad>;
  98670. /**
  98671. * Disposes the gamepad manager
  98672. */
  98673. dispose(): void;
  98674. private _addNewGamepad;
  98675. private _startMonitoringGamepads;
  98676. private _stopMonitoringGamepads;
  98677. /** @hidden */
  98678. _checkGamepadsStatus(): void;
  98679. private _updateGamepadObjects;
  98680. }
  98681. }
  98682. declare module BABYLON {
  98683. interface Scene {
  98684. /** @hidden */
  98685. _gamepadManager: Nullable<GamepadManager>;
  98686. /**
  98687. * Gets the gamepad manager associated with the scene
  98688. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  98689. */
  98690. gamepadManager: GamepadManager;
  98691. }
  98692. /**
  98693. * Interface representing a free camera inputs manager
  98694. */
  98695. interface FreeCameraInputsManager {
  98696. /**
  98697. * Adds gamepad input support to the FreeCameraInputsManager.
  98698. * @returns the FreeCameraInputsManager
  98699. */
  98700. addGamepad(): FreeCameraInputsManager;
  98701. }
  98702. /**
  98703. * Interface representing an arc rotate camera inputs manager
  98704. */
  98705. interface ArcRotateCameraInputsManager {
  98706. /**
  98707. * Adds gamepad input support to the ArcRotateCamera InputManager.
  98708. * @returns the camera inputs manager
  98709. */
  98710. addGamepad(): ArcRotateCameraInputsManager;
  98711. }
  98712. /**
  98713. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  98714. */
  98715. export class GamepadSystemSceneComponent implements ISceneComponent {
  98716. /**
  98717. * The component name helpfull to identify the component in the list of scene components.
  98718. */
  98719. readonly name: string;
  98720. /**
  98721. * The scene the component belongs to.
  98722. */
  98723. scene: Scene;
  98724. /**
  98725. * Creates a new instance of the component for the given scene
  98726. * @param scene Defines the scene to register the component in
  98727. */
  98728. constructor(scene: Scene);
  98729. /**
  98730. * Registers the component in a given scene
  98731. */
  98732. register(): void;
  98733. /**
  98734. * Rebuilds the elements related to this component in case of
  98735. * context lost for instance.
  98736. */
  98737. rebuild(): void;
  98738. /**
  98739. * Disposes the component and the associated ressources
  98740. */
  98741. dispose(): void;
  98742. private _beforeCameraUpdate;
  98743. }
  98744. }
  98745. declare module BABYLON {
  98746. /**
  98747. * Options to modify the vr teleportation behavior.
  98748. */
  98749. export interface VRTeleportationOptions {
  98750. /**
  98751. * The name of the mesh which should be used as the teleportation floor. (default: null)
  98752. */
  98753. floorMeshName?: string;
  98754. /**
  98755. * A list of meshes to be used as the teleportation floor. (default: empty)
  98756. */
  98757. floorMeshes?: Mesh[];
  98758. }
  98759. /**
  98760. * Options to modify the vr experience helper's behavior.
  98761. */
  98762. export interface VRExperienceHelperOptions extends WebVROptions {
  98763. /**
  98764. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  98765. */
  98766. createDeviceOrientationCamera?: boolean;
  98767. /**
  98768. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  98769. */
  98770. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  98771. /**
  98772. * Uses the main button on the controller to toggle the laser casted. (default: true)
  98773. */
  98774. laserToggle?: boolean;
  98775. /**
  98776. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  98777. */
  98778. floorMeshes?: Mesh[];
  98779. /**
  98780. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  98781. */
  98782. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  98783. }
  98784. /**
  98785. * Event containing information after VR has been entered
  98786. */
  98787. export class OnAfterEnteringVRObservableEvent {
  98788. /**
  98789. * If entering vr was successful
  98790. */
  98791. success: boolean;
  98792. }
  98793. /**
  98794. * Helps to quickly add VR support to an existing scene.
  98795. * See http://doc.babylonjs.com/how_to/webvr_helper
  98796. */
  98797. export class VRExperienceHelper {
  98798. /** Options to modify the vr experience helper's behavior. */
  98799. webVROptions: VRExperienceHelperOptions;
  98800. private _scene;
  98801. private _position;
  98802. private _btnVR;
  98803. private _btnVRDisplayed;
  98804. private _webVRsupported;
  98805. private _webVRready;
  98806. private _webVRrequesting;
  98807. private _webVRpresenting;
  98808. private _hasEnteredVR;
  98809. private _fullscreenVRpresenting;
  98810. private _canvas;
  98811. private _webVRCamera;
  98812. private _vrDeviceOrientationCamera;
  98813. private _deviceOrientationCamera;
  98814. private _existingCamera;
  98815. private _onKeyDown;
  98816. private _onVrDisplayPresentChange;
  98817. private _onVRDisplayChanged;
  98818. private _onVRRequestPresentStart;
  98819. private _onVRRequestPresentComplete;
  98820. /**
  98821. * Observable raised right before entering VR.
  98822. */
  98823. onEnteringVRObservable: Observable<VRExperienceHelper>;
  98824. /**
  98825. * Observable raised when entering VR has completed.
  98826. */
  98827. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  98828. /**
  98829. * Observable raised when exiting VR.
  98830. */
  98831. onExitingVRObservable: Observable<VRExperienceHelper>;
  98832. /**
  98833. * Observable raised when controller mesh is loaded.
  98834. */
  98835. onControllerMeshLoadedObservable: Observable<WebVRController>;
  98836. /** Return this.onEnteringVRObservable
  98837. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  98838. */
  98839. readonly onEnteringVR: Observable<VRExperienceHelper>;
  98840. /** Return this.onExitingVRObservable
  98841. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  98842. */
  98843. readonly onExitingVR: Observable<VRExperienceHelper>;
  98844. /** Return this.onControllerMeshLoadedObservable
  98845. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  98846. */
  98847. readonly onControllerMeshLoaded: Observable<WebVRController>;
  98848. private _rayLength;
  98849. private _useCustomVRButton;
  98850. private _teleportationRequested;
  98851. private _teleportActive;
  98852. private _floorMeshName;
  98853. private _floorMeshesCollection;
  98854. private _rotationAllowed;
  98855. private _teleportBackwardsVector;
  98856. private _teleportationTarget;
  98857. private _isDefaultTeleportationTarget;
  98858. private _postProcessMove;
  98859. private _teleportationFillColor;
  98860. private _teleportationBorderColor;
  98861. private _rotationAngle;
  98862. private _haloCenter;
  98863. private _cameraGazer;
  98864. private _padSensibilityUp;
  98865. private _padSensibilityDown;
  98866. private _leftController;
  98867. private _rightController;
  98868. /**
  98869. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  98870. */
  98871. onNewMeshSelected: Observable<AbstractMesh>;
  98872. /**
  98873. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  98874. */
  98875. onNewMeshPicked: Observable<PickingInfo>;
  98876. private _circleEase;
  98877. /**
  98878. * Observable raised before camera teleportation
  98879. */
  98880. onBeforeCameraTeleport: Observable<Vector3>;
  98881. /**
  98882. * Observable raised after camera teleportation
  98883. */
  98884. onAfterCameraTeleport: Observable<Vector3>;
  98885. /**
  98886. * Observable raised when current selected mesh gets unselected
  98887. */
  98888. onSelectedMeshUnselected: Observable<AbstractMesh>;
  98889. private _raySelectionPredicate;
  98890. /**
  98891. * To be optionaly changed by user to define custom ray selection
  98892. */
  98893. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  98894. /**
  98895. * To be optionaly changed by user to define custom selection logic (after ray selection)
  98896. */
  98897. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  98898. /**
  98899. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  98900. */
  98901. teleportationEnabled: boolean;
  98902. private _defaultHeight;
  98903. private _teleportationInitialized;
  98904. private _interactionsEnabled;
  98905. private _interactionsRequested;
  98906. private _displayGaze;
  98907. private _displayLaserPointer;
  98908. /**
  98909. * The mesh used to display where the user is going to teleport.
  98910. */
  98911. /**
  98912. * Sets the mesh to be used to display where the user is going to teleport.
  98913. */
  98914. teleportationTarget: Mesh;
  98915. /**
  98916. * 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
  98917. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  98918. * See http://doc.babylonjs.com/resources/baking_transformations
  98919. */
  98920. gazeTrackerMesh: Mesh;
  98921. /**
  98922. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  98923. */
  98924. updateGazeTrackerScale: boolean;
  98925. /**
  98926. * If the gaze trackers color should be updated when selecting meshes
  98927. */
  98928. updateGazeTrackerColor: boolean;
  98929. /**
  98930. * The gaze tracking mesh corresponding to the left controller
  98931. */
  98932. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  98933. /**
  98934. * The gaze tracking mesh corresponding to the right controller
  98935. */
  98936. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  98937. /**
  98938. * If the ray of the gaze should be displayed.
  98939. */
  98940. /**
  98941. * Sets if the ray of the gaze should be displayed.
  98942. */
  98943. displayGaze: boolean;
  98944. /**
  98945. * If the ray of the LaserPointer should be displayed.
  98946. */
  98947. /**
  98948. * Sets if the ray of the LaserPointer should be displayed.
  98949. */
  98950. displayLaserPointer: boolean;
  98951. /**
  98952. * The deviceOrientationCamera used as the camera when not in VR.
  98953. */
  98954. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  98955. /**
  98956. * Based on the current WebVR support, returns the current VR camera used.
  98957. */
  98958. readonly currentVRCamera: Nullable<Camera>;
  98959. /**
  98960. * The webVRCamera which is used when in VR.
  98961. */
  98962. readonly webVRCamera: WebVRFreeCamera;
  98963. /**
  98964. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  98965. */
  98966. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  98967. private readonly _teleportationRequestInitiated;
  98968. /**
  98969. * Defines wether or not Pointer lock should be requested when switching to
  98970. * full screen.
  98971. */
  98972. requestPointerLockOnFullScreen: boolean;
  98973. /**
  98974. * Instantiates a VRExperienceHelper.
  98975. * Helps to quickly add VR support to an existing scene.
  98976. * @param scene The scene the VRExperienceHelper belongs to.
  98977. * @param webVROptions Options to modify the vr experience helper's behavior.
  98978. */
  98979. constructor(scene: Scene,
  98980. /** Options to modify the vr experience helper's behavior. */
  98981. webVROptions?: VRExperienceHelperOptions);
  98982. private _onDefaultMeshLoaded;
  98983. private _onResize;
  98984. private _onFullscreenChange;
  98985. /**
  98986. * Gets a value indicating if we are currently in VR mode.
  98987. */
  98988. readonly isInVRMode: boolean;
  98989. private onVrDisplayPresentChange;
  98990. private onVRDisplayChanged;
  98991. private moveButtonToBottomRight;
  98992. private displayVRButton;
  98993. private updateButtonVisibility;
  98994. private _cachedAngularSensibility;
  98995. /**
  98996. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  98997. * Otherwise, will use the fullscreen API.
  98998. */
  98999. enterVR(): void;
  99000. /**
  99001. * Attempt to exit VR, or fullscreen.
  99002. */
  99003. exitVR(): void;
  99004. /**
  99005. * The position of the vr experience helper.
  99006. */
  99007. /**
  99008. * Sets the position of the vr experience helper.
  99009. */
  99010. position: Vector3;
  99011. /**
  99012. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  99013. */
  99014. enableInteractions(): void;
  99015. private readonly _noControllerIsActive;
  99016. private beforeRender;
  99017. private _isTeleportationFloor;
  99018. /**
  99019. * Adds a floor mesh to be used for teleportation.
  99020. * @param floorMesh the mesh to be used for teleportation.
  99021. */
  99022. addFloorMesh(floorMesh: Mesh): void;
  99023. /**
  99024. * Removes a floor mesh from being used for teleportation.
  99025. * @param floorMesh the mesh to be removed.
  99026. */
  99027. removeFloorMesh(floorMesh: Mesh): void;
  99028. /**
  99029. * Enables interactions and teleportation using the VR controllers and gaze.
  99030. * @param vrTeleportationOptions options to modify teleportation behavior.
  99031. */
  99032. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  99033. private _onNewGamepadConnected;
  99034. private _tryEnableInteractionOnController;
  99035. private _onNewGamepadDisconnected;
  99036. private _enableInteractionOnController;
  99037. private _checkTeleportWithRay;
  99038. private _checkRotate;
  99039. private _checkTeleportBackwards;
  99040. private _enableTeleportationOnController;
  99041. private _createTeleportationCircles;
  99042. private _displayTeleportationTarget;
  99043. private _hideTeleportationTarget;
  99044. private _rotateCamera;
  99045. private _moveTeleportationSelectorTo;
  99046. private _workingVector;
  99047. private _workingQuaternion;
  99048. private _workingMatrix;
  99049. /**
  99050. * Teleports the users feet to the desired location
  99051. * @param location The location where the user's feet should be placed
  99052. */
  99053. teleportCamera(location: Vector3): void;
  99054. private _convertNormalToDirectionOfRay;
  99055. private _castRayAndSelectObject;
  99056. private _notifySelectedMeshUnselected;
  99057. /**
  99058. * Sets the color of the laser ray from the vr controllers.
  99059. * @param color new color for the ray.
  99060. */
  99061. changeLaserColor(color: Color3): void;
  99062. /**
  99063. * Sets the color of the ray from the vr headsets gaze.
  99064. * @param color new color for the ray.
  99065. */
  99066. changeGazeColor(color: Color3): void;
  99067. /**
  99068. * Exits VR and disposes of the vr experience helper
  99069. */
  99070. dispose(): void;
  99071. /**
  99072. * Gets the name of the VRExperienceHelper class
  99073. * @returns "VRExperienceHelper"
  99074. */
  99075. getClassName(): string;
  99076. }
  99077. }
  99078. declare module BABYLON {
  99079. /**
  99080. * Manages an XRSession
  99081. * @see https://doc.babylonjs.com/how_to/webxr
  99082. */
  99083. export class WebXRSessionManager implements IDisposable {
  99084. private scene;
  99085. /**
  99086. * Fires every time a new xrFrame arrives which can be used to update the camera
  99087. */
  99088. onXRFrameObservable: Observable<any>;
  99089. /**
  99090. * Fires when the xr session is ended either by the device or manually done
  99091. */
  99092. onXRSessionEnded: Observable<any>;
  99093. /** @hidden */
  99094. _xrSession: XRSession;
  99095. /** @hidden */
  99096. _frameOfReference: XRFrameOfReference;
  99097. /** @hidden */
  99098. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  99099. /** @hidden */
  99100. _currentXRFrame: Nullable<XRFrame>;
  99101. private _xrNavigator;
  99102. private _xrDevice;
  99103. private _tmpMatrix;
  99104. /**
  99105. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  99106. * @param scene The scene which the session should be created for
  99107. */
  99108. constructor(scene: Scene);
  99109. /**
  99110. * Initializes the manager
  99111. * After initialization enterXR can be called to start an XR session
  99112. * @returns Promise which resolves after it is initialized
  99113. */
  99114. initializeAsync(): Promise<void>;
  99115. /**
  99116. * Enters XR with the desired XR session options, this must be done with a user action (eg. button click event)
  99117. * @param sessionCreationOptions xr options to create the session with
  99118. * @param frameOfReferenceType option to configure how the xr pose is expressed
  99119. * @returns Promise which resolves after it enters XR
  99120. */
  99121. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReferenceType: string): Promise<void>;
  99122. /**
  99123. * Stops the xrSession and restores the renderloop
  99124. * @returns Promise which resolves after it exits XR
  99125. */
  99126. exitXRAsync(): Promise<void>;
  99127. /**
  99128. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  99129. * @param ray ray to cast into the environment
  99130. * @returns Promise which resolves with a collision point in the environment if it exists
  99131. */
  99132. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  99133. /**
  99134. * Checks if a session would be supported for the creation options specified
  99135. * @param options creation options to check if they are supported
  99136. * @returns true if supported
  99137. */
  99138. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  99139. /**
  99140. * @hidden
  99141. * Converts the render layer of xrSession to a render target
  99142. * @param session session to create render target for
  99143. * @param scene scene the new render target should be created for
  99144. */
  99145. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene): RenderTargetTexture;
  99146. /**
  99147. * Disposes of the session manager
  99148. */
  99149. dispose(): void;
  99150. }
  99151. }
  99152. declare module BABYLON {
  99153. /**
  99154. * WebXR Camera which holds the views for the xrSession
  99155. * @see https://doc.babylonjs.com/how_to/webxr
  99156. */
  99157. export class WebXRCamera extends FreeCamera {
  99158. private static _TmpMatrix;
  99159. /**
  99160. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  99161. * @param name the name of the camera
  99162. * @param scene the scene to add the camera to
  99163. */
  99164. constructor(name: string, scene: Scene);
  99165. private _updateNumberOfRigCameras;
  99166. /** @hidden */
  99167. _updateForDualEyeDebugging(pupilDistance?: number): void;
  99168. /**
  99169. * Updates the cameras position from the current pose information of the XR session
  99170. * @param xrSessionManager the session containing pose information
  99171. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  99172. */
  99173. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  99174. }
  99175. }
  99176. declare module BABYLON {
  99177. /**
  99178. * States of the webXR experience
  99179. */
  99180. export enum WebXRState {
  99181. /**
  99182. * Transitioning to being in XR mode
  99183. */
  99184. ENTERING_XR = 0,
  99185. /**
  99186. * Transitioning to non XR mode
  99187. */
  99188. EXITING_XR = 1,
  99189. /**
  99190. * In XR mode and presenting
  99191. */
  99192. IN_XR = 2,
  99193. /**
  99194. * Not entered XR mode
  99195. */
  99196. NOT_IN_XR = 3
  99197. }
  99198. /**
  99199. * Helper class used to enable XR
  99200. * @see https://doc.babylonjs.com/how_to/webxr
  99201. */
  99202. export class WebXRExperienceHelper implements IDisposable {
  99203. private scene;
  99204. /**
  99205. * 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
  99206. */
  99207. container: AbstractMesh;
  99208. /**
  99209. * Camera used to render xr content
  99210. */
  99211. camera: WebXRCamera;
  99212. /**
  99213. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  99214. */
  99215. state: WebXRState;
  99216. private _setState;
  99217. private static _TmpVector;
  99218. /**
  99219. * Fires when the state of the experience helper has changed
  99220. */
  99221. onStateChangedObservable: Observable<WebXRState>;
  99222. /** @hidden */
  99223. _sessionManager: WebXRSessionManager;
  99224. private _nonVRCamera;
  99225. private _originalSceneAutoClear;
  99226. private _supported;
  99227. /**
  99228. * Creates the experience helper
  99229. * @param scene the scene to attach the experience helper to
  99230. * @returns a promise for the experience helper
  99231. */
  99232. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  99233. /**
  99234. * Creates a WebXRExperienceHelper
  99235. * @param scene The scene the helper should be created in
  99236. */
  99237. private constructor();
  99238. /**
  99239. * Exits XR mode and returns the scene to its original state
  99240. * @returns promise that resolves after xr mode has exited
  99241. */
  99242. exitXRAsync(): Promise<void>;
  99243. /**
  99244. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  99245. * @param sessionCreationOptions options for the XR session
  99246. * @param frameOfReference frame of reference of the XR session
  99247. * @returns promise that resolves after xr mode has entered
  99248. */
  99249. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReference: string): Promise<void>;
  99250. /**
  99251. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  99252. * @param ray ray to cast into the environment
  99253. * @returns Promise which resolves with a collision point in the environment if it exists
  99254. */
  99255. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  99256. /**
  99257. * Updates the global position of the camera by moving the camera's container
  99258. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  99259. * @param position The desired global position of the camera
  99260. */
  99261. setPositionOfCameraUsingContainer(position: Vector3): void;
  99262. /**
  99263. * Rotates the xr camera by rotating the camera's container around the camera's position
  99264. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  99265. * @param rotation the desired quaternion rotation to apply to the camera
  99266. */
  99267. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  99268. /**
  99269. * Checks if the creation options are supported by the xr session
  99270. * @param options creation options
  99271. * @returns true if supported
  99272. */
  99273. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  99274. /**
  99275. * Disposes of the experience helper
  99276. */
  99277. dispose(): void;
  99278. }
  99279. }
  99280. declare module BABYLON {
  99281. /**
  99282. * Button which can be used to enter a different mode of XR
  99283. */
  99284. export class WebXREnterExitUIButton {
  99285. /** button element */
  99286. element: HTMLElement;
  99287. /** XR initialization options for the button */
  99288. initializationOptions: XRSessionCreationOptions;
  99289. /**
  99290. * Creates a WebXREnterExitUIButton
  99291. * @param element button element
  99292. * @param initializationOptions XR initialization options for the button
  99293. */
  99294. constructor(
  99295. /** button element */
  99296. element: HTMLElement,
  99297. /** XR initialization options for the button */
  99298. initializationOptions: XRSessionCreationOptions);
  99299. /**
  99300. * Overwritable function which can be used to update the button's visuals when the state changes
  99301. * @param activeButton the current active button in the UI
  99302. */
  99303. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  99304. }
  99305. /**
  99306. * Options to create the webXR UI
  99307. */
  99308. export class WebXREnterExitUIOptions {
  99309. /**
  99310. * Context to enter xr with
  99311. */
  99312. outputCanvasContext?: Nullable<WebGLRenderingContext>;
  99313. /**
  99314. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  99315. */
  99316. customButtons?: Array<WebXREnterExitUIButton>;
  99317. }
  99318. /**
  99319. * UI to allow the user to enter/exit XR mode
  99320. */
  99321. export class WebXREnterExitUI implements IDisposable {
  99322. private scene;
  99323. private _overlay;
  99324. private _buttons;
  99325. private _activeButton;
  99326. /**
  99327. * Fired every time the active button is changed.
  99328. *
  99329. * When xr is entered via a button that launches xr that button will be the callback parameter
  99330. *
  99331. * When exiting xr the callback parameter will be null)
  99332. */
  99333. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  99334. /**
  99335. * Creates UI to allow the user to enter/exit XR mode
  99336. * @param scene the scene to add the ui to
  99337. * @param helper the xr experience helper to enter/exit xr with
  99338. * @param options options to configure the UI
  99339. * @returns the created ui
  99340. */
  99341. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  99342. private constructor();
  99343. private _updateButtons;
  99344. /**
  99345. * Disposes of the object
  99346. */
  99347. dispose(): void;
  99348. }
  99349. }
  99350. declare module BABYLON {
  99351. /**
  99352. * Represents an XR input
  99353. */
  99354. export class WebXRController {
  99355. /**
  99356. * 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
  99357. */
  99358. grip?: AbstractMesh;
  99359. /**
  99360. * Pointer which can be used to select objects or attach a visible laser to
  99361. */
  99362. pointer: AbstractMesh;
  99363. /**
  99364. * Creates the controller
  99365. * @see https://doc.babylonjs.com/how_to/webxr
  99366. * @param scene the scene which the controller should be associated to
  99367. */
  99368. constructor(scene: Scene);
  99369. /**
  99370. * Disposes of the object
  99371. */
  99372. dispose(): void;
  99373. }
  99374. /**
  99375. * XR input used to track XR inputs such as controllers/rays
  99376. */
  99377. export class WebXRInput implements IDisposable {
  99378. private helper;
  99379. /**
  99380. * XR controllers being tracked
  99381. */
  99382. controllers: Array<WebXRController>;
  99383. private _tmpMatrix;
  99384. private _frameObserver;
  99385. /**
  99386. * Initializes the WebXRInput
  99387. * @param helper experience helper which the input should be created for
  99388. */
  99389. constructor(helper: WebXRExperienceHelper);
  99390. /**
  99391. * Disposes of the object
  99392. */
  99393. dispose(): void;
  99394. }
  99395. }
  99396. declare module BABYLON {
  99397. /**
  99398. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  99399. */
  99400. export class WebXRManagedOutputCanvas implements IDisposable {
  99401. private _canvas;
  99402. /**
  99403. * xrpresent context of the canvas which can be used to display/mirror xr content
  99404. */
  99405. canvasContext: Nullable<WebGLRenderingContext>;
  99406. /**
  99407. * Initializes the canvas to be added/removed upon entering/exiting xr
  99408. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  99409. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  99410. */
  99411. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  99412. /**
  99413. * Disposes of the object
  99414. */
  99415. dispose(): void;
  99416. private _setManagedOutputCanvas;
  99417. private _addCanvas;
  99418. private _removeCanvas;
  99419. }
  99420. }
  99421. declare module BABYLON {
  99422. /**
  99423. * Contains an array of blocks representing the octree
  99424. */
  99425. export interface IOctreeContainer<T> {
  99426. /**
  99427. * Blocks within the octree
  99428. */
  99429. blocks: Array<OctreeBlock<T>>;
  99430. }
  99431. /**
  99432. * Class used to store a cell in an octree
  99433. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  99434. */
  99435. export class OctreeBlock<T> {
  99436. /**
  99437. * Gets the content of the current block
  99438. */
  99439. entries: T[];
  99440. /**
  99441. * Gets the list of block children
  99442. */
  99443. blocks: Array<OctreeBlock<T>>;
  99444. private _depth;
  99445. private _maxDepth;
  99446. private _capacity;
  99447. private _minPoint;
  99448. private _maxPoint;
  99449. private _boundingVectors;
  99450. private _creationFunc;
  99451. /**
  99452. * Creates a new block
  99453. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  99454. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  99455. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  99456. * @param depth defines the current depth of this block in the octree
  99457. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  99458. * @param creationFunc defines a callback to call when an element is added to the block
  99459. */
  99460. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  99461. /**
  99462. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  99463. */
  99464. readonly capacity: number;
  99465. /**
  99466. * Gets the minimum vector (in world space) of the block's bounding box
  99467. */
  99468. readonly minPoint: Vector3;
  99469. /**
  99470. * Gets the maximum vector (in world space) of the block's bounding box
  99471. */
  99472. readonly maxPoint: Vector3;
  99473. /**
  99474. * Add a new element to this block
  99475. * @param entry defines the element to add
  99476. */
  99477. addEntry(entry: T): void;
  99478. /**
  99479. * Remove an element from this block
  99480. * @param entry defines the element to remove
  99481. */
  99482. removeEntry(entry: T): void;
  99483. /**
  99484. * Add an array of elements to this block
  99485. * @param entries defines the array of elements to add
  99486. */
  99487. addEntries(entries: T[]): void;
  99488. /**
  99489. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  99490. * @param frustumPlanes defines the frustum planes to test
  99491. * @param selection defines the array to store current content if selection is positive
  99492. * @param allowDuplicate defines if the selection array can contains duplicated entries
  99493. */
  99494. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  99495. /**
  99496. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  99497. * @param sphereCenter defines the bounding sphere center
  99498. * @param sphereRadius defines the bounding sphere radius
  99499. * @param selection defines the array to store current content if selection is positive
  99500. * @param allowDuplicate defines if the selection array can contains duplicated entries
  99501. */
  99502. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  99503. /**
  99504. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  99505. * @param ray defines the ray to test with
  99506. * @param selection defines the array to store current content if selection is positive
  99507. */
  99508. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  99509. /**
  99510. * Subdivide the content into child blocks (this block will then be empty)
  99511. */
  99512. createInnerBlocks(): void;
  99513. /**
  99514. * @hidden
  99515. */
  99516. 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;
  99517. }
  99518. }
  99519. declare module BABYLON {
  99520. /**
  99521. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  99522. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  99523. */
  99524. export class Octree<T> {
  99525. /** 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.) */
  99526. maxDepth: number;
  99527. /**
  99528. * Blocks within the octree containing objects
  99529. */
  99530. blocks: Array<OctreeBlock<T>>;
  99531. /**
  99532. * Content stored in the octree
  99533. */
  99534. dynamicContent: T[];
  99535. private _maxBlockCapacity;
  99536. private _selectionContent;
  99537. private _creationFunc;
  99538. /**
  99539. * Creates a octree
  99540. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  99541. * @param creationFunc function to be used to instatiate the octree
  99542. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  99543. * @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.)
  99544. */
  99545. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  99546. /** 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.) */
  99547. maxDepth?: number);
  99548. /**
  99549. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  99550. * @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);
  99551. * @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);
  99552. * @param entries meshes to be added to the octree blocks
  99553. */
  99554. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  99555. /**
  99556. * Adds a mesh to the octree
  99557. * @param entry Mesh to add to the octree
  99558. */
  99559. addMesh(entry: T): void;
  99560. /**
  99561. * Remove an element from the octree
  99562. * @param entry defines the element to remove
  99563. */
  99564. removeMesh(entry: T): void;
  99565. /**
  99566. * Selects an array of meshes within the frustum
  99567. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  99568. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  99569. * @returns array of meshes within the frustum
  99570. */
  99571. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  99572. /**
  99573. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  99574. * @param sphereCenter defines the bounding sphere center
  99575. * @param sphereRadius defines the bounding sphere radius
  99576. * @param allowDuplicate defines if the selection array can contains duplicated entries
  99577. * @returns an array of objects that intersect the sphere
  99578. */
  99579. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  99580. /**
  99581. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  99582. * @param ray defines the ray to test with
  99583. * @returns array of intersected objects
  99584. */
  99585. intersectsRay(ray: Ray): SmartArray<T>;
  99586. /**
  99587. * Adds a mesh into the octree block if it intersects the block
  99588. */
  99589. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  99590. /**
  99591. * Adds a submesh into the octree block if it intersects the block
  99592. */
  99593. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  99594. }
  99595. }
  99596. declare module BABYLON {
  99597. interface Scene {
  99598. /**
  99599. * @hidden
  99600. * Backing Filed
  99601. */
  99602. _selectionOctree: Octree<AbstractMesh>;
  99603. /**
  99604. * Gets the octree used to boost mesh selection (picking)
  99605. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  99606. */
  99607. selectionOctree: Octree<AbstractMesh>;
  99608. /**
  99609. * Creates or updates the octree used to boost selection (picking)
  99610. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  99611. * @param maxCapacity defines the maximum capacity per leaf
  99612. * @param maxDepth defines the maximum depth of the octree
  99613. * @returns an octree of AbstractMesh
  99614. */
  99615. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  99616. }
  99617. interface AbstractMesh {
  99618. /**
  99619. * @hidden
  99620. * Backing Field
  99621. */
  99622. _submeshesOctree: Octree<SubMesh>;
  99623. /**
  99624. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  99625. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  99626. * @param maxCapacity defines the maximum size of each block (64 by default)
  99627. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  99628. * @returns the new octree
  99629. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  99630. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  99631. */
  99632. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  99633. }
  99634. /**
  99635. * Defines the octree scene component responsible to manage any octrees
  99636. * in a given scene.
  99637. */
  99638. export class OctreeSceneComponent {
  99639. /**
  99640. * The component name helpfull to identify the component in the list of scene components.
  99641. */
  99642. readonly name: string;
  99643. /**
  99644. * The scene the component belongs to.
  99645. */
  99646. scene: Scene;
  99647. /**
  99648. * Indicates if the meshes have been checked to make sure they are isEnabled()
  99649. */
  99650. readonly checksIsEnabled: boolean;
  99651. /**
  99652. * Creates a new instance of the component for the given scene
  99653. * @param scene Defines the scene to register the component in
  99654. */
  99655. constructor(scene: Scene);
  99656. /**
  99657. * Registers the component in a given scene
  99658. */
  99659. register(): void;
  99660. /**
  99661. * Return the list of active meshes
  99662. * @returns the list of active meshes
  99663. */
  99664. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  99665. /**
  99666. * Return the list of active sub meshes
  99667. * @param mesh The mesh to get the candidates sub meshes from
  99668. * @returns the list of active sub meshes
  99669. */
  99670. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  99671. private _tempRay;
  99672. /**
  99673. * Return the list of sub meshes intersecting with a given local ray
  99674. * @param mesh defines the mesh to find the submesh for
  99675. * @param localRay defines the ray in local space
  99676. * @returns the list of intersecting sub meshes
  99677. */
  99678. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  99679. /**
  99680. * Return the list of sub meshes colliding with a collider
  99681. * @param mesh defines the mesh to find the submesh for
  99682. * @param collider defines the collider to evaluate the collision against
  99683. * @returns the list of colliding sub meshes
  99684. */
  99685. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  99686. /**
  99687. * Rebuilds the elements related to this component in case of
  99688. * context lost for instance.
  99689. */
  99690. rebuild(): void;
  99691. /**
  99692. * Disposes the component and the associated ressources.
  99693. */
  99694. dispose(): void;
  99695. }
  99696. }
  99697. declare module BABYLON {
  99698. /**
  99699. * Renders a layer on top of an existing scene
  99700. */
  99701. export class UtilityLayerRenderer implements IDisposable {
  99702. /** the original scene that will be rendered on top of */
  99703. originalScene: Scene;
  99704. private _pointerCaptures;
  99705. private _lastPointerEvents;
  99706. private static _DefaultUtilityLayer;
  99707. private static _DefaultKeepDepthUtilityLayer;
  99708. private _sharedGizmoLight;
  99709. /**
  99710. * @hidden
  99711. * Light which used by gizmos to get light shading
  99712. */
  99713. _getSharedGizmoLight(): HemisphericLight;
  99714. /**
  99715. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  99716. */
  99717. pickUtilitySceneFirst: boolean;
  99718. /**
  99719. * 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)
  99720. */
  99721. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  99722. /**
  99723. * 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)
  99724. */
  99725. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  99726. /**
  99727. * The scene that is rendered on top of the original scene
  99728. */
  99729. utilityLayerScene: Scene;
  99730. /**
  99731. * If the utility layer should automatically be rendered on top of existing scene
  99732. */
  99733. shouldRender: boolean;
  99734. /**
  99735. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  99736. */
  99737. onlyCheckPointerDownEvents: boolean;
  99738. /**
  99739. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  99740. */
  99741. processAllEvents: boolean;
  99742. /**
  99743. * Observable raised when the pointer move from the utility layer scene to the main scene
  99744. */
  99745. onPointerOutObservable: Observable<number>;
  99746. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  99747. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  99748. private _afterRenderObserver;
  99749. private _sceneDisposeObserver;
  99750. private _originalPointerObserver;
  99751. /**
  99752. * Instantiates a UtilityLayerRenderer
  99753. * @param originalScene the original scene that will be rendered on top of
  99754. * @param handleEvents boolean indicating if the utility layer should handle events
  99755. */
  99756. constructor(
  99757. /** the original scene that will be rendered on top of */
  99758. originalScene: Scene, handleEvents?: boolean);
  99759. private _notifyObservers;
  99760. /**
  99761. * Renders the utility layers scene on top of the original scene
  99762. */
  99763. render(): void;
  99764. /**
  99765. * Disposes of the renderer
  99766. */
  99767. dispose(): void;
  99768. private _updateCamera;
  99769. }
  99770. }
  99771. declare module BABYLON {
  99772. /**
  99773. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  99774. */
  99775. export class Gizmo implements IDisposable {
  99776. /** The utility layer the gizmo will be added to */
  99777. gizmoLayer: UtilityLayerRenderer;
  99778. /**
  99779. * The root mesh of the gizmo
  99780. */
  99781. _rootMesh: Mesh;
  99782. private _attachedMesh;
  99783. /**
  99784. * Ratio for the scale of the gizmo (Default: 1)
  99785. */
  99786. scaleRatio: number;
  99787. private _tmpMatrix;
  99788. /**
  99789. * If a custom mesh has been set (Default: false)
  99790. */
  99791. protected _customMeshSet: boolean;
  99792. /**
  99793. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  99794. * * When set, interactions will be enabled
  99795. */
  99796. attachedMesh: Nullable<AbstractMesh>;
  99797. /**
  99798. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  99799. * @param mesh The mesh to replace the default mesh of the gizmo
  99800. */
  99801. setCustomMesh(mesh: Mesh): void;
  99802. /**
  99803. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  99804. */
  99805. updateGizmoRotationToMatchAttachedMesh: boolean;
  99806. /**
  99807. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  99808. */
  99809. updateGizmoPositionToMatchAttachedMesh: boolean;
  99810. /**
  99811. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  99812. */
  99813. protected _updateScale: boolean;
  99814. protected _interactionsEnabled: boolean;
  99815. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  99816. private _beforeRenderObserver;
  99817. /**
  99818. * Creates a gizmo
  99819. * @param gizmoLayer The utility layer the gizmo will be added to
  99820. */
  99821. constructor(
  99822. /** The utility layer the gizmo will be added to */
  99823. gizmoLayer?: UtilityLayerRenderer);
  99824. private _tempVector;
  99825. /**
  99826. * @hidden
  99827. * Updates the gizmo to match the attached mesh's position/rotation
  99828. */
  99829. protected _update(): void;
  99830. /**
  99831. * Disposes of the gizmo
  99832. */
  99833. dispose(): void;
  99834. }
  99835. }
  99836. declare module BABYLON {
  99837. /**
  99838. * Single axis drag gizmo
  99839. */
  99840. export class AxisDragGizmo extends Gizmo {
  99841. /**
  99842. * Drag behavior responsible for the gizmos dragging interactions
  99843. */
  99844. dragBehavior: PointerDragBehavior;
  99845. private _pointerObserver;
  99846. /**
  99847. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  99848. */
  99849. snapDistance: number;
  99850. /**
  99851. * Event that fires each time the gizmo snaps to a new location.
  99852. * * snapDistance is the the change in distance
  99853. */
  99854. onSnapObservable: Observable<{
  99855. snapDistance: number;
  99856. }>;
  99857. /** @hidden */
  99858. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  99859. /** @hidden */
  99860. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  99861. /**
  99862. * Creates an AxisDragGizmo
  99863. * @param gizmoLayer The utility layer the gizmo will be added to
  99864. * @param dragAxis The axis which the gizmo will be able to drag on
  99865. * @param color The color of the gizmo
  99866. */
  99867. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  99868. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  99869. /**
  99870. * Disposes of the gizmo
  99871. */
  99872. dispose(): void;
  99873. }
  99874. }
  99875. declare module BABYLON.Debug {
  99876. /**
  99877. * The Axes viewer will show 3 axes in a specific point in space
  99878. */
  99879. export class AxesViewer {
  99880. private _xAxis;
  99881. private _yAxis;
  99882. private _zAxis;
  99883. private _scaleLinesFactor;
  99884. private _instanced;
  99885. /**
  99886. * Gets the hosting scene
  99887. */
  99888. scene: Scene;
  99889. /**
  99890. * Gets or sets a number used to scale line length
  99891. */
  99892. scaleLines: number;
  99893. /** Gets the node hierarchy used to render x-axis */
  99894. readonly xAxis: TransformNode;
  99895. /** Gets the node hierarchy used to render y-axis */
  99896. readonly yAxis: TransformNode;
  99897. /** Gets the node hierarchy used to render z-axis */
  99898. readonly zAxis: TransformNode;
  99899. /**
  99900. * Creates a new AxesViewer
  99901. * @param scene defines the hosting scene
  99902. * @param scaleLines defines a number used to scale line length (1 by default)
  99903. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  99904. * @param xAxis defines the node hierarchy used to render the x-axis
  99905. * @param yAxis defines the node hierarchy used to render the y-axis
  99906. * @param zAxis defines the node hierarchy used to render the z-axis
  99907. */
  99908. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  99909. /**
  99910. * Force the viewer to update
  99911. * @param position defines the position of the viewer
  99912. * @param xaxis defines the x axis of the viewer
  99913. * @param yaxis defines the y axis of the viewer
  99914. * @param zaxis defines the z axis of the viewer
  99915. */
  99916. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  99917. /**
  99918. * Creates an instance of this axes viewer.
  99919. * @returns a new axes viewer with instanced meshes
  99920. */
  99921. createInstance(): AxesViewer;
  99922. /** Releases resources */
  99923. dispose(): void;
  99924. private static _SetRenderingGroupId;
  99925. }
  99926. }
  99927. declare module BABYLON.Debug {
  99928. /**
  99929. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  99930. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  99931. */
  99932. export class BoneAxesViewer extends AxesViewer {
  99933. /**
  99934. * Gets or sets the target mesh where to display the axes viewer
  99935. */
  99936. mesh: Nullable<Mesh>;
  99937. /**
  99938. * Gets or sets the target bone where to display the axes viewer
  99939. */
  99940. bone: Nullable<Bone>;
  99941. /** Gets current position */
  99942. pos: Vector3;
  99943. /** Gets direction of X axis */
  99944. xaxis: Vector3;
  99945. /** Gets direction of Y axis */
  99946. yaxis: Vector3;
  99947. /** Gets direction of Z axis */
  99948. zaxis: Vector3;
  99949. /**
  99950. * Creates a new BoneAxesViewer
  99951. * @param scene defines the hosting scene
  99952. * @param bone defines the target bone
  99953. * @param mesh defines the target mesh
  99954. * @param scaleLines defines a scaling factor for line length (1 by default)
  99955. */
  99956. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  99957. /**
  99958. * Force the viewer to update
  99959. */
  99960. update(): void;
  99961. /** Releases resources */
  99962. dispose(): void;
  99963. }
  99964. }
  99965. declare module BABYLON {
  99966. /**
  99967. * Interface used to define scene explorer extensibility option
  99968. */
  99969. export interface IExplorerExtensibilityOption {
  99970. /**
  99971. * Define the option label
  99972. */
  99973. label: string;
  99974. /**
  99975. * Defines the action to execute on click
  99976. */
  99977. action: (entity: any) => void;
  99978. }
  99979. /**
  99980. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  99981. */
  99982. export interface IExplorerExtensibilityGroup {
  99983. /**
  99984. * Defines a predicate to test if a given type mut be extended
  99985. */
  99986. predicate: (entity: any) => boolean;
  99987. /**
  99988. * Gets the list of options added to a type
  99989. */
  99990. entries: IExplorerExtensibilityOption[];
  99991. }
  99992. /**
  99993. * Interface used to define the options to use to create the Inspector
  99994. */
  99995. export interface IInspectorOptions {
  99996. /**
  99997. * Display in overlay mode (default: false)
  99998. */
  99999. overlay?: boolean;
  100000. /**
  100001. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  100002. */
  100003. globalRoot?: HTMLElement;
  100004. /**
  100005. * Display the Scene explorer
  100006. */
  100007. showExplorer?: boolean;
  100008. /**
  100009. * Display the property inspector
  100010. */
  100011. showInspector?: boolean;
  100012. /**
  100013. * Display in embed mode (both panes on the right)
  100014. */
  100015. embedMode?: boolean;
  100016. /**
  100017. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  100018. */
  100019. handleResize?: boolean;
  100020. /**
  100021. * Allow the panes to popup (default: true)
  100022. */
  100023. enablePopup?: boolean;
  100024. /**
  100025. * Allow the panes to be closed by users (default: true)
  100026. */
  100027. enableClose?: boolean;
  100028. /**
  100029. * Optional list of extensibility entries
  100030. */
  100031. explorerExtensibility?: IExplorerExtensibilityGroup[];
  100032. /**
  100033. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  100034. */
  100035. inspectorURL?: string;
  100036. }
  100037. interface Scene {
  100038. /**
  100039. * @hidden
  100040. * Backing field
  100041. */
  100042. _debugLayer: DebugLayer;
  100043. /**
  100044. * Gets the debug layer (aka Inspector) associated with the scene
  100045. * @see http://doc.babylonjs.com/features/playground_debuglayer
  100046. */
  100047. debugLayer: DebugLayer;
  100048. }
  100049. /**
  100050. * The debug layer (aka Inspector) is the go to tool in order to better understand
  100051. * what is happening in your scene
  100052. * @see http://doc.babylonjs.com/features/playground_debuglayer
  100053. */
  100054. export class DebugLayer {
  100055. /**
  100056. * Define the url to get the inspector script from.
  100057. * By default it uses the babylonjs CDN.
  100058. * @ignoreNaming
  100059. */
  100060. static InspectorURL: string;
  100061. private _scene;
  100062. private BJSINSPECTOR;
  100063. /**
  100064. * Observable triggered when a property is changed through the inspector.
  100065. */
  100066. onPropertyChangedObservable: Observable<{
  100067. object: any;
  100068. property: string;
  100069. value: any;
  100070. initialValue: any;
  100071. }>;
  100072. /**
  100073. * Instantiates a new debug layer.
  100074. * The debug layer (aka Inspector) is the go to tool in order to better understand
  100075. * what is happening in your scene
  100076. * @see http://doc.babylonjs.com/features/playground_debuglayer
  100077. * @param scene Defines the scene to inspect
  100078. */
  100079. constructor(scene: Scene);
  100080. /** Creates the inspector window. */
  100081. private _createInspector;
  100082. /**
  100083. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  100084. * @param entity defines the entity to select
  100085. * @param lineContainerTitle defines the specific block to highlight
  100086. */
  100087. select(entity: any, lineContainerTitle?: string): void;
  100088. /** Get the inspector from bundle or global */
  100089. private _getGlobalInspector;
  100090. /**
  100091. * Get if the inspector is visible or not.
  100092. * @returns true if visible otherwise, false
  100093. */
  100094. isVisible(): boolean;
  100095. /**
  100096. * Hide the inspector and close its window.
  100097. */
  100098. hide(): void;
  100099. /**
  100100. * Launch the debugLayer.
  100101. * @param config Define the configuration of the inspector
  100102. * @return a promise fulfilled when the debug layer is visible
  100103. */
  100104. show(config?: IInspectorOptions): Promise<DebugLayer>;
  100105. }
  100106. }
  100107. declare module BABYLON {
  100108. /**
  100109. * Class containing static functions to help procedurally build meshes
  100110. */
  100111. export class BoxBuilder {
  100112. /**
  100113. * Creates a box mesh
  100114. * * The parameter `size` sets the size (float) of each box side (default 1)
  100115. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  100116. * * 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)
  100117. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  100118. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  100119. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  100120. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  100121. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  100122. * @param name defines the name of the mesh
  100123. * @param options defines the options used to create the mesh
  100124. * @param scene defines the hosting scene
  100125. * @returns the box mesh
  100126. */
  100127. static CreateBox(name: string, options: {
  100128. size?: number;
  100129. width?: number;
  100130. height?: number;
  100131. depth?: number;
  100132. faceUV?: Vector4[];
  100133. faceColors?: Color4[];
  100134. sideOrientation?: number;
  100135. frontUVs?: Vector4;
  100136. backUVs?: Vector4;
  100137. updatable?: boolean;
  100138. }, scene?: Nullable<Scene>): Mesh;
  100139. }
  100140. }
  100141. declare module BABYLON {
  100142. /**
  100143. * Class containing static functions to help procedurally build meshes
  100144. */
  100145. export class SphereBuilder {
  100146. /**
  100147. * Creates a sphere mesh
  100148. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  100149. * * 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`)
  100150. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  100151. * * 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
  100152. * * 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)
  100153. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  100154. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  100155. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  100156. * @param name defines the name of the mesh
  100157. * @param options defines the options used to create the mesh
  100158. * @param scene defines the hosting scene
  100159. * @returns the sphere mesh
  100160. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  100161. */
  100162. static CreateSphere(name: string, options: {
  100163. segments?: number;
  100164. diameter?: number;
  100165. diameterX?: number;
  100166. diameterY?: number;
  100167. diameterZ?: number;
  100168. arc?: number;
  100169. slice?: number;
  100170. sideOrientation?: number;
  100171. frontUVs?: Vector4;
  100172. backUVs?: Vector4;
  100173. updatable?: boolean;
  100174. }, scene: any): Mesh;
  100175. }
  100176. }
  100177. declare module BABYLON.Debug {
  100178. /**
  100179. * Used to show the physics impostor around the specific mesh
  100180. */
  100181. export class PhysicsViewer {
  100182. /** @hidden */
  100183. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  100184. /** @hidden */
  100185. protected _meshes: Array<Nullable<AbstractMesh>>;
  100186. /** @hidden */
  100187. protected _scene: Nullable<Scene>;
  100188. /** @hidden */
  100189. protected _numMeshes: number;
  100190. /** @hidden */
  100191. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  100192. private _renderFunction;
  100193. private _utilityLayer;
  100194. private _debugBoxMesh;
  100195. private _debugSphereMesh;
  100196. private _debugCylinderMesh;
  100197. private _debugMaterial;
  100198. private _debugMeshMeshes;
  100199. /**
  100200. * Creates a new PhysicsViewer
  100201. * @param scene defines the hosting scene
  100202. */
  100203. constructor(scene: Scene);
  100204. /** @hidden */
  100205. protected _updateDebugMeshes(): void;
  100206. /**
  100207. * Renders a specified physic impostor
  100208. * @param impostor defines the impostor to render
  100209. * @param targetMesh defines the mesh represented by the impostor
  100210. * @returns the new debug mesh used to render the impostor
  100211. */
  100212. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  100213. /**
  100214. * Hides a specified physic impostor
  100215. * @param impostor defines the impostor to hide
  100216. */
  100217. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  100218. private _getDebugMaterial;
  100219. private _getDebugBoxMesh;
  100220. private _getDebugSphereMesh;
  100221. private _getDebugCylinderMesh;
  100222. private _getDebugMeshMesh;
  100223. private _getDebugMesh;
  100224. /** Releases all resources */
  100225. dispose(): void;
  100226. }
  100227. }
  100228. declare module BABYLON {
  100229. /**
  100230. * Class containing static functions to help procedurally build meshes
  100231. */
  100232. export class LinesBuilder {
  100233. /**
  100234. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  100235. * * 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
  100236. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  100237. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  100238. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  100239. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  100240. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  100241. * * 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
  100242. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  100243. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  100244. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  100245. * @param name defines the name of the new line system
  100246. * @param options defines the options used to create the line system
  100247. * @param scene defines the hosting scene
  100248. * @returns a new line system mesh
  100249. */
  100250. static CreateLineSystem(name: string, options: {
  100251. lines: Vector3[][];
  100252. updatable?: boolean;
  100253. instance?: Nullable<LinesMesh>;
  100254. colors?: Nullable<Color4[][]>;
  100255. useVertexAlpha?: boolean;
  100256. }, scene: Nullable<Scene>): LinesMesh;
  100257. /**
  100258. * Creates a line mesh
  100259. * 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
  100260. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  100261. * * The parameter `points` is an array successive Vector3
  100262. * * 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
  100263. * * The optional parameter `colors` is an array of successive Color4, one per line point
  100264. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  100265. * * When updating an instance, remember that only point positions can change, not the number of points
  100266. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  100267. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  100268. * @param name defines the name of the new line system
  100269. * @param options defines the options used to create the line system
  100270. * @param scene defines the hosting scene
  100271. * @returns a new line mesh
  100272. */
  100273. static CreateLines(name: string, options: {
  100274. points: Vector3[];
  100275. updatable?: boolean;
  100276. instance?: Nullable<LinesMesh>;
  100277. colors?: Color4[];
  100278. useVertexAlpha?: boolean;
  100279. }, scene?: Nullable<Scene>): LinesMesh;
  100280. /**
  100281. * Creates a dashed line mesh
  100282. * * 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
  100283. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  100284. * * The parameter `points` is an array successive Vector3
  100285. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  100286. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  100287. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  100288. * * 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
  100289. * * When updating an instance, remember that only point positions can change, not the number of points
  100290. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  100291. * @param name defines the name of the mesh
  100292. * @param options defines the options used to create the mesh
  100293. * @param scene defines the hosting scene
  100294. * @returns the dashed line mesh
  100295. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  100296. */
  100297. static CreateDashedLines(name: string, options: {
  100298. points: Vector3[];
  100299. dashSize?: number;
  100300. gapSize?: number;
  100301. dashNb?: number;
  100302. updatable?: boolean;
  100303. instance?: LinesMesh;
  100304. }, scene?: Nullable<Scene>): LinesMesh;
  100305. }
  100306. }
  100307. declare module BABYLON {
  100308. /**
  100309. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  100310. * in order to better appreciate the issue one might have.
  100311. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  100312. */
  100313. export class RayHelper {
  100314. /**
  100315. * Defines the ray we are currently tryin to visualize.
  100316. */
  100317. ray: Nullable<Ray>;
  100318. private _renderPoints;
  100319. private _renderLine;
  100320. private _renderFunction;
  100321. private _scene;
  100322. private _updateToMeshFunction;
  100323. private _attachedToMesh;
  100324. private _meshSpaceDirection;
  100325. private _meshSpaceOrigin;
  100326. /**
  100327. * Helper function to create a colored helper in a scene in one line.
  100328. * @param ray Defines the ray we are currently tryin to visualize
  100329. * @param scene Defines the scene the ray is used in
  100330. * @param color Defines the color we want to see the ray in
  100331. * @returns The newly created ray helper.
  100332. */
  100333. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  100334. /**
  100335. * Instantiate a new ray helper.
  100336. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  100337. * in order to better appreciate the issue one might have.
  100338. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  100339. * @param ray Defines the ray we are currently tryin to visualize
  100340. */
  100341. constructor(ray: Ray);
  100342. /**
  100343. * Shows the ray we are willing to debug.
  100344. * @param scene Defines the scene the ray needs to be rendered in
  100345. * @param color Defines the color the ray needs to be rendered in
  100346. */
  100347. show(scene: Scene, color?: Color3): void;
  100348. /**
  100349. * Hides the ray we are debugging.
  100350. */
  100351. hide(): void;
  100352. private _render;
  100353. /**
  100354. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  100355. * @param mesh Defines the mesh we want the helper attached to
  100356. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  100357. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  100358. * @param length Defines the length of the ray
  100359. */
  100360. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  100361. /**
  100362. * Detach the ray helper from the mesh it has previously been attached to.
  100363. */
  100364. detachFromMesh(): void;
  100365. private _updateToMesh;
  100366. /**
  100367. * Dispose the helper and release its associated resources.
  100368. */
  100369. dispose(): void;
  100370. }
  100371. }
  100372. declare module BABYLON.Debug {
  100373. /**
  100374. * Class used to render a debug view of a given skeleton
  100375. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  100376. */
  100377. export class SkeletonViewer {
  100378. /** defines the skeleton to render */
  100379. skeleton: Skeleton;
  100380. /** defines the mesh attached to the skeleton */
  100381. mesh: AbstractMesh;
  100382. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  100383. autoUpdateBonesMatrices: boolean;
  100384. /** defines the rendering group id to use with the viewer */
  100385. renderingGroupId: number;
  100386. /** Gets or sets the color used to render the skeleton */
  100387. color: Color3;
  100388. private _scene;
  100389. private _debugLines;
  100390. private _debugMesh;
  100391. private _isEnabled;
  100392. private _renderFunction;
  100393. private _utilityLayer;
  100394. /**
  100395. * Returns the mesh used to render the bones
  100396. */
  100397. readonly debugMesh: Nullable<LinesMesh>;
  100398. /**
  100399. * Creates a new SkeletonViewer
  100400. * @param skeleton defines the skeleton to render
  100401. * @param mesh defines the mesh attached to the skeleton
  100402. * @param scene defines the hosting scene
  100403. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  100404. * @param renderingGroupId defines the rendering group id to use with the viewer
  100405. */
  100406. constructor(
  100407. /** defines the skeleton to render */
  100408. skeleton: Skeleton,
  100409. /** defines the mesh attached to the skeleton */
  100410. mesh: AbstractMesh, scene: Scene,
  100411. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  100412. autoUpdateBonesMatrices?: boolean,
  100413. /** defines the rendering group id to use with the viewer */
  100414. renderingGroupId?: number);
  100415. /** Gets or sets a boolean indicating if the viewer is enabled */
  100416. isEnabled: boolean;
  100417. private _getBonePosition;
  100418. private _getLinesForBonesWithLength;
  100419. private _getLinesForBonesNoLength;
  100420. /** Update the viewer to sync with current skeleton state */
  100421. update(): void;
  100422. /** Release associated resources */
  100423. dispose(): void;
  100424. }
  100425. }
  100426. declare module BABYLON {
  100427. /**
  100428. * Options to create the null engine
  100429. */
  100430. export class NullEngineOptions {
  100431. /**
  100432. * Render width (Default: 512)
  100433. */
  100434. renderWidth: number;
  100435. /**
  100436. * Render height (Default: 256)
  100437. */
  100438. renderHeight: number;
  100439. /**
  100440. * Texture size (Default: 512)
  100441. */
  100442. textureSize: number;
  100443. /**
  100444. * If delta time between frames should be constant
  100445. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  100446. */
  100447. deterministicLockstep: boolean;
  100448. /**
  100449. * Maximum about of steps between frames (Default: 4)
  100450. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  100451. */
  100452. lockstepMaxSteps: number;
  100453. }
  100454. /**
  100455. * The null engine class provides support for headless version of babylon.js.
  100456. * This can be used in server side scenario or for testing purposes
  100457. */
  100458. export class NullEngine extends Engine {
  100459. private _options;
  100460. /**
  100461. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  100462. */
  100463. isDeterministicLockStep(): boolean;
  100464. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  100465. getLockstepMaxSteps(): number;
  100466. /**
  100467. * Sets hardware scaling, used to save performance if needed
  100468. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  100469. */
  100470. getHardwareScalingLevel(): number;
  100471. constructor(options?: NullEngineOptions);
  100472. createVertexBuffer(vertices: FloatArray): WebGLBuffer;
  100473. createIndexBuffer(indices: IndicesArray): WebGLBuffer;
  100474. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  100475. getRenderWidth(useScreen?: boolean): number;
  100476. getRenderHeight(useScreen?: boolean): number;
  100477. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  100478. createShaderProgram(vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  100479. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): WebGLUniformLocation[];
  100480. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  100481. bindSamplers(effect: Effect): void;
  100482. enableEffect(effect: Effect): void;
  100483. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  100484. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  100485. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  100486. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  100487. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  100488. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  100489. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  100490. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  100491. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  100492. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  100493. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  100494. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  100495. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  100496. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  100497. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  100498. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  100499. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  100500. setFloat(uniform: WebGLUniformLocation, value: number): void;
  100501. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  100502. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  100503. setBool(uniform: WebGLUniformLocation, bool: number): void;
  100504. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  100505. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  100506. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  100507. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  100508. bindBuffers(vertexBuffers: {
  100509. [key: string]: VertexBuffer;
  100510. }, indexBuffer: WebGLBuffer, effect: Effect): void;
  100511. wipeCaches(bruteForce?: boolean): void;
  100512. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  100513. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  100514. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  100515. /** @hidden */
  100516. _createTexture(): WebGLTexture;
  100517. /** @hidden */
  100518. _releaseTexture(texture: InternalTexture): void;
  100519. 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;
  100520. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  100521. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  100522. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  100523. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  100524. createDynamicVertexBuffer(vertices: FloatArray): WebGLBuffer;
  100525. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  100526. areAllEffectsReady(): boolean;
  100527. /**
  100528. * @hidden
  100529. * Get the current error code of the webGL context
  100530. * @returns the error code
  100531. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  100532. */
  100533. getError(): number;
  100534. /** @hidden */
  100535. _getUnpackAlignement(): number;
  100536. /** @hidden */
  100537. _unpackFlipY(value: boolean): void;
  100538. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  100539. /**
  100540. * Updates a dynamic vertex buffer.
  100541. * @param vertexBuffer the vertex buffer to update
  100542. * @param data the data used to update the vertex buffer
  100543. * @param byteOffset the byte offset of the data (optional)
  100544. * @param byteLength the byte length of the data (optional)
  100545. */
  100546. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  100547. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  100548. /** @hidden */
  100549. _bindTexture(channel: number, texture: InternalTexture): void;
  100550. /** @hidden */
  100551. _releaseBuffer(buffer: WebGLBuffer): boolean;
  100552. releaseEffects(): void;
  100553. displayLoadingUI(): void;
  100554. hideLoadingUI(): void;
  100555. /** @hidden */
  100556. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  100557. /** @hidden */
  100558. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  100559. /** @hidden */
  100560. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  100561. /** @hidden */
  100562. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  100563. }
  100564. }
  100565. declare module BABYLON {
  100566. /** @hidden */
  100567. export class _OcclusionDataStorage {
  100568. /** @hidden */
  100569. occlusionInternalRetryCounter: number;
  100570. /** @hidden */
  100571. isOcclusionQueryInProgress: boolean;
  100572. /** @hidden */
  100573. isOccluded: boolean;
  100574. /** @hidden */
  100575. occlusionRetryCount: number;
  100576. /** @hidden */
  100577. occlusionType: number;
  100578. /** @hidden */
  100579. occlusionQueryAlgorithmType: number;
  100580. }
  100581. interface Engine {
  100582. /**
  100583. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  100584. * @return the new query
  100585. */
  100586. createQuery(): WebGLQuery;
  100587. /**
  100588. * Delete and release a webGL query
  100589. * @param query defines the query to delete
  100590. * @return the current engine
  100591. */
  100592. deleteQuery(query: WebGLQuery): Engine;
  100593. /**
  100594. * Check if a given query has resolved and got its value
  100595. * @param query defines the query to check
  100596. * @returns true if the query got its value
  100597. */
  100598. isQueryResultAvailable(query: WebGLQuery): boolean;
  100599. /**
  100600. * Gets the value of a given query
  100601. * @param query defines the query to check
  100602. * @returns the value of the query
  100603. */
  100604. getQueryResult(query: WebGLQuery): number;
  100605. /**
  100606. * Initiates an occlusion query
  100607. * @param algorithmType defines the algorithm to use
  100608. * @param query defines the query to use
  100609. * @returns the current engine
  100610. * @see http://doc.babylonjs.com/features/occlusionquery
  100611. */
  100612. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  100613. /**
  100614. * Ends an occlusion query
  100615. * @see http://doc.babylonjs.com/features/occlusionquery
  100616. * @param algorithmType defines the algorithm to use
  100617. * @returns the current engine
  100618. */
  100619. endOcclusionQuery(algorithmType: number): Engine;
  100620. /**
  100621. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  100622. * Please note that only one query can be issued at a time
  100623. * @returns a time token used to track the time span
  100624. */
  100625. startTimeQuery(): Nullable<_TimeToken>;
  100626. /**
  100627. * Ends a time query
  100628. * @param token defines the token used to measure the time span
  100629. * @returns the time spent (in ns)
  100630. */
  100631. endTimeQuery(token: _TimeToken): int;
  100632. /** @hidden */
  100633. _currentNonTimestampToken: Nullable<_TimeToken>;
  100634. /** @hidden */
  100635. _createTimeQuery(): WebGLQuery;
  100636. /** @hidden */
  100637. _deleteTimeQuery(query: WebGLQuery): void;
  100638. /** @hidden */
  100639. _getGlAlgorithmType(algorithmType: number): number;
  100640. /** @hidden */
  100641. _getTimeQueryResult(query: WebGLQuery): any;
  100642. /** @hidden */
  100643. _getTimeQueryAvailability(query: WebGLQuery): any;
  100644. }
  100645. interface AbstractMesh {
  100646. /**
  100647. * Backing filed
  100648. * @hidden
  100649. */
  100650. __occlusionDataStorage: _OcclusionDataStorage;
  100651. /**
  100652. * Access property
  100653. * @hidden
  100654. */
  100655. _occlusionDataStorage: _OcclusionDataStorage;
  100656. /**
  100657. * 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.
  100658. * The default value is -1 which means don't break the query and wait till the result
  100659. * @see http://doc.babylonjs.com/features/occlusionquery
  100660. */
  100661. occlusionRetryCount: number;
  100662. /**
  100663. * 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:
  100664. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  100665. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  100666. * * 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.
  100667. * @see http://doc.babylonjs.com/features/occlusionquery
  100668. */
  100669. occlusionType: number;
  100670. /**
  100671. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  100672. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  100673. * * 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.
  100674. * @see http://doc.babylonjs.com/features/occlusionquery
  100675. */
  100676. occlusionQueryAlgorithmType: number;
  100677. /**
  100678. * 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
  100679. * @see http://doc.babylonjs.com/features/occlusionquery
  100680. */
  100681. isOccluded: boolean;
  100682. /**
  100683. * Flag to check the progress status of the query
  100684. * @see http://doc.babylonjs.com/features/occlusionquery
  100685. */
  100686. isOcclusionQueryInProgress: boolean;
  100687. }
  100688. }
  100689. declare module BABYLON {
  100690. /** @hidden */
  100691. export var _forceTransformFeedbackToBundle: boolean;
  100692. interface Engine {
  100693. /**
  100694. * Creates a webGL transform feedback object
  100695. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  100696. * @returns the webGL transform feedback object
  100697. */
  100698. createTransformFeedback(): WebGLTransformFeedback;
  100699. /**
  100700. * Delete a webGL transform feedback object
  100701. * @param value defines the webGL transform feedback object to delete
  100702. */
  100703. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  100704. /**
  100705. * Bind a webGL transform feedback object to the webgl context
  100706. * @param value defines the webGL transform feedback object to bind
  100707. */
  100708. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  100709. /**
  100710. * Begins a transform feedback operation
  100711. * @param usePoints defines if points or triangles must be used
  100712. */
  100713. beginTransformFeedback(usePoints: boolean): void;
  100714. /**
  100715. * Ends a transform feedback operation
  100716. */
  100717. endTransformFeedback(): void;
  100718. /**
  100719. * Specify the varyings to use with transform feedback
  100720. * @param program defines the associated webGL program
  100721. * @param value defines the list of strings representing the varying names
  100722. */
  100723. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  100724. /**
  100725. * Bind a webGL buffer for a transform feedback operation
  100726. * @param value defines the webGL buffer to bind
  100727. */
  100728. bindTransformFeedbackBuffer(value: Nullable<WebGLBuffer>): void;
  100729. }
  100730. }
  100731. declare module BABYLON {
  100732. /**
  100733. * Gather the list of clipboard event types as constants.
  100734. */
  100735. export class ClipboardEventTypes {
  100736. /**
  100737. * The clipboard event is fired when a copy command is active (pressed).
  100738. */
  100739. static readonly COPY: number;
  100740. /**
  100741. * The clipboard event is fired when a cut command is active (pressed).
  100742. */
  100743. static readonly CUT: number;
  100744. /**
  100745. * The clipboard event is fired when a paste command is active (pressed).
  100746. */
  100747. static readonly PASTE: number;
  100748. }
  100749. /**
  100750. * This class is used to store clipboard related info for the onClipboardObservable event.
  100751. */
  100752. export class ClipboardInfo {
  100753. /**
  100754. * Defines the type of event (BABYLON.ClipboardEventTypes)
  100755. */
  100756. type: number;
  100757. /**
  100758. * Defines the related dom event
  100759. */
  100760. event: ClipboardEvent;
  100761. /**
  100762. *Creates an instance of ClipboardInfo.
  100763. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  100764. * @param event Defines the related dom event
  100765. */
  100766. constructor(
  100767. /**
  100768. * Defines the type of event (BABYLON.ClipboardEventTypes)
  100769. */
  100770. type: number,
  100771. /**
  100772. * Defines the related dom event
  100773. */
  100774. event: ClipboardEvent);
  100775. /**
  100776. * Get the clipboard event's type from the keycode.
  100777. * @param keyCode Defines the keyCode for the current keyboard event.
  100778. * @return {number}
  100779. */
  100780. static GetTypeFromCharacter(keyCode: number): number;
  100781. }
  100782. }
  100783. declare module BABYLON {
  100784. /**
  100785. * Class used to represent data loading progression
  100786. */
  100787. export class SceneLoaderProgressEvent {
  100788. /** defines if data length to load can be evaluated */
  100789. readonly lengthComputable: boolean;
  100790. /** defines the loaded data length */
  100791. readonly loaded: number;
  100792. /** defines the data length to load */
  100793. readonly total: number;
  100794. /**
  100795. * Create a new progress event
  100796. * @param lengthComputable defines if data length to load can be evaluated
  100797. * @param loaded defines the loaded data length
  100798. * @param total defines the data length to load
  100799. */
  100800. constructor(
  100801. /** defines if data length to load can be evaluated */
  100802. lengthComputable: boolean,
  100803. /** defines the loaded data length */
  100804. loaded: number,
  100805. /** defines the data length to load */
  100806. total: number);
  100807. /**
  100808. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  100809. * @param event defines the source event
  100810. * @returns a new SceneLoaderProgressEvent
  100811. */
  100812. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  100813. }
  100814. /**
  100815. * Interface used by SceneLoader plugins to define supported file extensions
  100816. */
  100817. export interface ISceneLoaderPluginExtensions {
  100818. /**
  100819. * Defines the list of supported extensions
  100820. */
  100821. [extension: string]: {
  100822. isBinary: boolean;
  100823. };
  100824. }
  100825. /**
  100826. * Interface used by SceneLoader plugin factory
  100827. */
  100828. export interface ISceneLoaderPluginFactory {
  100829. /**
  100830. * Defines the name of the factory
  100831. */
  100832. name: string;
  100833. /**
  100834. * Function called to create a new plugin
  100835. * @return the new plugin
  100836. */
  100837. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  100838. /**
  100839. * Boolean indicating if the plugin can direct load specific data
  100840. */
  100841. canDirectLoad?: (data: string) => boolean;
  100842. }
  100843. /**
  100844. * Interface used to define a SceneLoader plugin
  100845. */
  100846. export interface ISceneLoaderPlugin {
  100847. /**
  100848. * The friendly name of this plugin.
  100849. */
  100850. name: string;
  100851. /**
  100852. * The file extensions supported by this plugin.
  100853. */
  100854. extensions: string | ISceneLoaderPluginExtensions;
  100855. /**
  100856. * Import meshes into a scene.
  100857. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  100858. * @param scene The scene to import into
  100859. * @param data The data to import
  100860. * @param rootUrl The root url for scene and resources
  100861. * @param meshes The meshes array to import into
  100862. * @param particleSystems The particle systems array to import into
  100863. * @param skeletons The skeletons array to import into
  100864. * @param onError The callback when import fails
  100865. * @returns True if successful or false otherwise
  100866. */
  100867. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  100868. /**
  100869. * Load into a scene.
  100870. * @param scene The scene to load into
  100871. * @param data The data to import
  100872. * @param rootUrl The root url for scene and resources
  100873. * @param onError The callback when import fails
  100874. * @returns true if successful or false otherwise
  100875. */
  100876. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  100877. /**
  100878. * The callback that returns true if the data can be directly loaded.
  100879. */
  100880. canDirectLoad?: (data: string) => boolean;
  100881. /**
  100882. * The callback that allows custom handling of the root url based on the response url.
  100883. */
  100884. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  100885. /**
  100886. * Load into an asset container.
  100887. * @param scene The scene to load into
  100888. * @param data The data to import
  100889. * @param rootUrl The root url for scene and resources
  100890. * @param onError The callback when import fails
  100891. * @returns The loaded asset container
  100892. */
  100893. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  100894. }
  100895. /**
  100896. * Interface used to define an async SceneLoader plugin
  100897. */
  100898. export interface ISceneLoaderPluginAsync {
  100899. /**
  100900. * The friendly name of this plugin.
  100901. */
  100902. name: string;
  100903. /**
  100904. * The file extensions supported by this plugin.
  100905. */
  100906. extensions: string | ISceneLoaderPluginExtensions;
  100907. /**
  100908. * Import meshes into a scene.
  100909. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  100910. * @param scene The scene to import into
  100911. * @param data The data to import
  100912. * @param rootUrl The root url for scene and resources
  100913. * @param onProgress The callback when the load progresses
  100914. * @param fileName Defines the name of the file to load
  100915. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  100916. */
  100917. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  100918. meshes: AbstractMesh[];
  100919. particleSystems: IParticleSystem[];
  100920. skeletons: Skeleton[];
  100921. animationGroups: AnimationGroup[];
  100922. }>;
  100923. /**
  100924. * Load into a scene.
  100925. * @param scene The scene to load into
  100926. * @param data The data to import
  100927. * @param rootUrl The root url for scene and resources
  100928. * @param onProgress The callback when the load progresses
  100929. * @param fileName Defines the name of the file to load
  100930. * @returns Nothing
  100931. */
  100932. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  100933. /**
  100934. * The callback that returns true if the data can be directly loaded.
  100935. */
  100936. canDirectLoad?: (data: string) => boolean;
  100937. /**
  100938. * The callback that allows custom handling of the root url based on the response url.
  100939. */
  100940. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  100941. /**
  100942. * Load into an asset container.
  100943. * @param scene The scene to load into
  100944. * @param data The data to import
  100945. * @param rootUrl The root url for scene and resources
  100946. * @param onProgress The callback when the load progresses
  100947. * @param fileName Defines the name of the file to load
  100948. * @returns The loaded asset container
  100949. */
  100950. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  100951. }
  100952. /**
  100953. * Class used to load scene from various file formats using registered plugins
  100954. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  100955. */
  100956. export class SceneLoader {
  100957. /**
  100958. * No logging while loading
  100959. */
  100960. static readonly NO_LOGGING: number;
  100961. /**
  100962. * Minimal logging while loading
  100963. */
  100964. static readonly MINIMAL_LOGGING: number;
  100965. /**
  100966. * Summary logging while loading
  100967. */
  100968. static readonly SUMMARY_LOGGING: number;
  100969. /**
  100970. * Detailled logging while loading
  100971. */
  100972. static readonly DETAILED_LOGGING: number;
  100973. /**
  100974. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  100975. */
  100976. static ForceFullSceneLoadingForIncremental: boolean;
  100977. /**
  100978. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  100979. */
  100980. static ShowLoadingScreen: boolean;
  100981. /**
  100982. * Defines the current logging level (while loading the scene)
  100983. * @ignorenaming
  100984. */
  100985. static loggingLevel: number;
  100986. /**
  100987. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  100988. */
  100989. static CleanBoneMatrixWeights: boolean;
  100990. /**
  100991. * Event raised when a plugin is used to load a scene
  100992. */
  100993. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  100994. private static _registeredPlugins;
  100995. private static _getDefaultPlugin;
  100996. private static _getPluginForExtension;
  100997. private static _getPluginForDirectLoad;
  100998. private static _getPluginForFilename;
  100999. private static _getDirectLoad;
  101000. private static _loadData;
  101001. private static _getFileInfo;
  101002. /**
  101003. * Gets a plugin that can load the given extension
  101004. * @param extension defines the extension to load
  101005. * @returns a plugin or null if none works
  101006. */
  101007. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  101008. /**
  101009. * Gets a boolean indicating that the given extension can be loaded
  101010. * @param extension defines the extension to load
  101011. * @returns true if the extension is supported
  101012. */
  101013. static IsPluginForExtensionAvailable(extension: string): boolean;
  101014. /**
  101015. * Adds a new plugin to the list of registered plugins
  101016. * @param plugin defines the plugin to add
  101017. */
  101018. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  101019. /**
  101020. * Import meshes into a scene
  101021. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  101022. * @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)
  101023. * @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)
  101024. * @param scene the instance of BABYLON.Scene to append to
  101025. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  101026. * @param onProgress a callback with a progress event for each file being loaded
  101027. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  101028. * @param pluginExtension the extension used to determine the plugin
  101029. * @returns The loaded plugin
  101030. */
  101031. 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>;
  101032. /**
  101033. * Import meshes into a scene
  101034. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  101035. * @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)
  101036. * @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)
  101037. * @param scene the instance of BABYLON.Scene to append to
  101038. * @param onProgress a callback with a progress event for each file being loaded
  101039. * @param pluginExtension the extension used to determine the plugin
  101040. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  101041. */
  101042. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  101043. meshes: AbstractMesh[];
  101044. particleSystems: IParticleSystem[];
  101045. skeletons: Skeleton[];
  101046. animationGroups: AnimationGroup[];
  101047. }>;
  101048. /**
  101049. * Load a scene
  101050. * @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)
  101051. * @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)
  101052. * @param engine is the instance of BABYLON.Engine to use to create the scene
  101053. * @param onSuccess a callback with the scene when import succeeds
  101054. * @param onProgress a callback with a progress event for each file being loaded
  101055. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  101056. * @param pluginExtension the extension used to determine the plugin
  101057. * @returns The loaded plugin
  101058. */
  101059. 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>;
  101060. /**
  101061. * Load a scene
  101062. * @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)
  101063. * @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)
  101064. * @param engine is the instance of BABYLON.Engine to use to create the scene
  101065. * @param onProgress a callback with a progress event for each file being loaded
  101066. * @param pluginExtension the extension used to determine the plugin
  101067. * @returns The loaded scene
  101068. */
  101069. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  101070. /**
  101071. * Append a scene
  101072. * @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)
  101073. * @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)
  101074. * @param scene is the instance of BABYLON.Scene to append to
  101075. * @param onSuccess a callback with the scene when import succeeds
  101076. * @param onProgress a callback with a progress event for each file being loaded
  101077. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  101078. * @param pluginExtension the extension used to determine the plugin
  101079. * @returns The loaded plugin
  101080. */
  101081. 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>;
  101082. /**
  101083. * Append a scene
  101084. * @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)
  101085. * @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)
  101086. * @param scene is the instance of BABYLON.Scene to append to
  101087. * @param onProgress a callback with a progress event for each file being loaded
  101088. * @param pluginExtension the extension used to determine the plugin
  101089. * @returns The given scene
  101090. */
  101091. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  101092. /**
  101093. * Load a scene into an asset container
  101094. * @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)
  101095. * @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)
  101096. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  101097. * @param onSuccess a callback with the scene when import succeeds
  101098. * @param onProgress a callback with a progress event for each file being loaded
  101099. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  101100. * @param pluginExtension the extension used to determine the plugin
  101101. * @returns The loaded plugin
  101102. */
  101103. 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>;
  101104. /**
  101105. * Load a scene into an asset container
  101106. * @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)
  101107. * @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)
  101108. * @param scene is the instance of Scene to append to
  101109. * @param onProgress a callback with a progress event for each file being loaded
  101110. * @param pluginExtension the extension used to determine the plugin
  101111. * @returns The loaded asset container
  101112. */
  101113. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  101114. }
  101115. }
  101116. declare module BABYLON {
  101117. /**
  101118. * Google Daydream controller
  101119. */
  101120. export class DaydreamController extends WebVRController {
  101121. /**
  101122. * Base Url for the controller model.
  101123. */
  101124. static MODEL_BASE_URL: string;
  101125. /**
  101126. * File name for the controller model.
  101127. */
  101128. static MODEL_FILENAME: string;
  101129. /**
  101130. * Gamepad Id prefix used to identify Daydream Controller.
  101131. */
  101132. static readonly GAMEPAD_ID_PREFIX: string;
  101133. /**
  101134. * Creates a new DaydreamController from a gamepad
  101135. * @param vrGamepad the gamepad that the controller should be created from
  101136. */
  101137. constructor(vrGamepad: any);
  101138. /**
  101139. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  101140. * @param scene scene in which to add meshes
  101141. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  101142. */
  101143. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  101144. /**
  101145. * Called once for each button that changed state since the last frame
  101146. * @param buttonIdx Which button index changed
  101147. * @param state New state of the button
  101148. * @param changes Which properties on the state changed since last frame
  101149. */
  101150. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  101151. }
  101152. }
  101153. declare module BABYLON {
  101154. /**
  101155. * Gear VR Controller
  101156. */
  101157. export class GearVRController extends WebVRController {
  101158. /**
  101159. * Base Url for the controller model.
  101160. */
  101161. static MODEL_BASE_URL: string;
  101162. /**
  101163. * File name for the controller model.
  101164. */
  101165. static MODEL_FILENAME: string;
  101166. /**
  101167. * Gamepad Id prefix used to identify this controller.
  101168. */
  101169. static readonly GAMEPAD_ID_PREFIX: string;
  101170. private readonly _buttonIndexToObservableNameMap;
  101171. /**
  101172. * Creates a new GearVRController from a gamepad
  101173. * @param vrGamepad the gamepad that the controller should be created from
  101174. */
  101175. constructor(vrGamepad: any);
  101176. /**
  101177. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  101178. * @param scene scene in which to add meshes
  101179. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  101180. */
  101181. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  101182. /**
  101183. * Called once for each button that changed state since the last frame
  101184. * @param buttonIdx Which button index changed
  101185. * @param state New state of the button
  101186. * @param changes Which properties on the state changed since last frame
  101187. */
  101188. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  101189. }
  101190. }
  101191. declare module BABYLON {
  101192. /**
  101193. * Generic Controller
  101194. */
  101195. export class GenericController extends WebVRController {
  101196. /**
  101197. * Base Url for the controller model.
  101198. */
  101199. static readonly MODEL_BASE_URL: string;
  101200. /**
  101201. * File name for the controller model.
  101202. */
  101203. static readonly MODEL_FILENAME: string;
  101204. /**
  101205. * Creates a new GenericController from a gamepad
  101206. * @param vrGamepad the gamepad that the controller should be created from
  101207. */
  101208. constructor(vrGamepad: any);
  101209. /**
  101210. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  101211. * @param scene scene in which to add meshes
  101212. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  101213. */
  101214. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  101215. /**
  101216. * Called once for each button that changed state since the last frame
  101217. * @param buttonIdx Which button index changed
  101218. * @param state New state of the button
  101219. * @param changes Which properties on the state changed since last frame
  101220. */
  101221. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  101222. }
  101223. }
  101224. declare module BABYLON {
  101225. /**
  101226. * Oculus Touch Controller
  101227. */
  101228. export class OculusTouchController extends WebVRController {
  101229. /**
  101230. * Base Url for the controller model.
  101231. */
  101232. static MODEL_BASE_URL: string;
  101233. /**
  101234. * File name for the left controller model.
  101235. */
  101236. static MODEL_LEFT_FILENAME: string;
  101237. /**
  101238. * File name for the right controller model.
  101239. */
  101240. static MODEL_RIGHT_FILENAME: string;
  101241. /**
  101242. * Fired when the secondary trigger on this controller is modified
  101243. */
  101244. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  101245. /**
  101246. * Fired when the thumb rest on this controller is modified
  101247. */
  101248. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  101249. /**
  101250. * Creates a new OculusTouchController from a gamepad
  101251. * @param vrGamepad the gamepad that the controller should be created from
  101252. */
  101253. constructor(vrGamepad: any);
  101254. /**
  101255. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  101256. * @param scene scene in which to add meshes
  101257. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  101258. */
  101259. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  101260. /**
  101261. * Fired when the A button on this controller is modified
  101262. */
  101263. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  101264. /**
  101265. * Fired when the B button on this controller is modified
  101266. */
  101267. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  101268. /**
  101269. * Fired when the X button on this controller is modified
  101270. */
  101271. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  101272. /**
  101273. * Fired when the Y button on this controller is modified
  101274. */
  101275. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  101276. /**
  101277. * Called once for each button that changed state since the last frame
  101278. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  101279. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  101280. * 2) secondary trigger (same)
  101281. * 3) A (right) X (left), touch, pressed = value
  101282. * 4) B / Y
  101283. * 5) thumb rest
  101284. * @param buttonIdx Which button index changed
  101285. * @param state New state of the button
  101286. * @param changes Which properties on the state changed since last frame
  101287. */
  101288. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  101289. }
  101290. }
  101291. declare module BABYLON {
  101292. /**
  101293. * Vive Controller
  101294. */
  101295. export class ViveController extends WebVRController {
  101296. /**
  101297. * Base Url for the controller model.
  101298. */
  101299. static MODEL_BASE_URL: string;
  101300. /**
  101301. * File name for the controller model.
  101302. */
  101303. static MODEL_FILENAME: string;
  101304. /**
  101305. * Creates a new ViveController from a gamepad
  101306. * @param vrGamepad the gamepad that the controller should be created from
  101307. */
  101308. constructor(vrGamepad: any);
  101309. /**
  101310. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  101311. * @param scene scene in which to add meshes
  101312. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  101313. */
  101314. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  101315. /**
  101316. * Fired when the left button on this controller is modified
  101317. */
  101318. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  101319. /**
  101320. * Fired when the right button on this controller is modified
  101321. */
  101322. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  101323. /**
  101324. * Fired when the menu button on this controller is modified
  101325. */
  101326. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  101327. /**
  101328. * Called once for each button that changed state since the last frame
  101329. * Vive mapping:
  101330. * 0: touchpad
  101331. * 1: trigger
  101332. * 2: left AND right buttons
  101333. * 3: menu button
  101334. * @param buttonIdx Which button index changed
  101335. * @param state New state of the button
  101336. * @param changes Which properties on the state changed since last frame
  101337. */
  101338. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  101339. }
  101340. }
  101341. declare module BABYLON {
  101342. /**
  101343. * Defines the WindowsMotionController object that the state of the windows motion controller
  101344. */
  101345. export class WindowsMotionController extends WebVRController {
  101346. /**
  101347. * The base url used to load the left and right controller models
  101348. */
  101349. static MODEL_BASE_URL: string;
  101350. /**
  101351. * The name of the left controller model file
  101352. */
  101353. static MODEL_LEFT_FILENAME: string;
  101354. /**
  101355. * The name of the right controller model file
  101356. */
  101357. static MODEL_RIGHT_FILENAME: string;
  101358. /**
  101359. * The controller name prefix for this controller type
  101360. */
  101361. static readonly GAMEPAD_ID_PREFIX: string;
  101362. /**
  101363. * The controller id pattern for this controller type
  101364. */
  101365. private static readonly GAMEPAD_ID_PATTERN;
  101366. private _loadedMeshInfo;
  101367. private readonly _mapping;
  101368. /**
  101369. * Fired when the trackpad on this controller is clicked
  101370. */
  101371. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  101372. /**
  101373. * Fired when the trackpad on this controller is modified
  101374. */
  101375. onTrackpadValuesChangedObservable: Observable<StickValues>;
  101376. /**
  101377. * The current x and y values of this controller's trackpad
  101378. */
  101379. trackpad: StickValues;
  101380. /**
  101381. * Creates a new WindowsMotionController from a gamepad
  101382. * @param vrGamepad the gamepad that the controller should be created from
  101383. */
  101384. constructor(vrGamepad: any);
  101385. /**
  101386. * Fired when the trigger on this controller is modified
  101387. */
  101388. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  101389. /**
  101390. * Fired when the menu button on this controller is modified
  101391. */
  101392. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  101393. /**
  101394. * Fired when the grip button on this controller is modified
  101395. */
  101396. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  101397. /**
  101398. * Fired when the thumbstick button on this controller is modified
  101399. */
  101400. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  101401. /**
  101402. * Fired when the touchpad button on this controller is modified
  101403. */
  101404. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  101405. /**
  101406. * Fired when the touchpad values on this controller are modified
  101407. */
  101408. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  101409. private _updateTrackpad;
  101410. /**
  101411. * Called once per frame by the engine.
  101412. */
  101413. update(): void;
  101414. /**
  101415. * Called once for each button that changed state since the last frame
  101416. * @param buttonIdx Which button index changed
  101417. * @param state New state of the button
  101418. * @param changes Which properties on the state changed since last frame
  101419. */
  101420. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  101421. /**
  101422. * Moves the buttons on the controller mesh based on their current state
  101423. * @param buttonName the name of the button to move
  101424. * @param buttonValue the value of the button which determines the buttons new position
  101425. */
  101426. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  101427. /**
  101428. * Moves the axis on the controller mesh based on its current state
  101429. * @param axis the index of the axis
  101430. * @param axisValue the value of the axis which determines the meshes new position
  101431. * @hidden
  101432. */
  101433. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  101434. /**
  101435. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  101436. * @param scene scene in which to add meshes
  101437. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  101438. */
  101439. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  101440. /**
  101441. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  101442. * can be transformed by button presses and axes values, based on this._mapping.
  101443. *
  101444. * @param scene scene in which the meshes exist
  101445. * @param meshes list of meshes that make up the controller model to process
  101446. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  101447. */
  101448. private processModel;
  101449. private createMeshInfo;
  101450. /**
  101451. * Gets the ray of the controller in the direction the controller is pointing
  101452. * @param length the length the resulting ray should be
  101453. * @returns a ray in the direction the controller is pointing
  101454. */
  101455. getForwardRay(length?: number): Ray;
  101456. /**
  101457. * Disposes of the controller
  101458. */
  101459. dispose(): void;
  101460. }
  101461. }
  101462. declare module BABYLON {
  101463. /**
  101464. * Single axis scale gizmo
  101465. */
  101466. export class AxisScaleGizmo extends Gizmo {
  101467. private _coloredMaterial;
  101468. /**
  101469. * Drag behavior responsible for the gizmos dragging interactions
  101470. */
  101471. dragBehavior: PointerDragBehavior;
  101472. private _pointerObserver;
  101473. /**
  101474. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  101475. */
  101476. snapDistance: number;
  101477. /**
  101478. * Event that fires each time the gizmo snaps to a new location.
  101479. * * snapDistance is the the change in distance
  101480. */
  101481. onSnapObservable: Observable<{
  101482. snapDistance: number;
  101483. }>;
  101484. /**
  101485. * If the scaling operation should be done on all axis (default: false)
  101486. */
  101487. uniformScaling: boolean;
  101488. /**
  101489. * Creates an AxisScaleGizmo
  101490. * @param gizmoLayer The utility layer the gizmo will be added to
  101491. * @param dragAxis The axis which the gizmo will be able to scale on
  101492. * @param color The color of the gizmo
  101493. */
  101494. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  101495. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  101496. /**
  101497. * Disposes of the gizmo
  101498. */
  101499. dispose(): void;
  101500. /**
  101501. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  101502. * @param mesh The mesh to replace the default mesh of the gizmo
  101503. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  101504. */
  101505. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  101506. }
  101507. }
  101508. declare module BABYLON {
  101509. /**
  101510. * Bounding box gizmo
  101511. */
  101512. export class BoundingBoxGizmo extends Gizmo {
  101513. private _lineBoundingBox;
  101514. private _rotateSpheresParent;
  101515. private _scaleBoxesParent;
  101516. private _boundingDimensions;
  101517. private _renderObserver;
  101518. private _pointerObserver;
  101519. private _scaleDragSpeed;
  101520. private _tmpQuaternion;
  101521. private _tmpVector;
  101522. private _tmpRotationMatrix;
  101523. /**
  101524. * 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)
  101525. */
  101526. ignoreChildren: boolean;
  101527. /**
  101528. * 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)
  101529. */
  101530. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  101531. /**
  101532. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  101533. */
  101534. rotationSphereSize: number;
  101535. /**
  101536. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  101537. */
  101538. scaleBoxSize: number;
  101539. /**
  101540. * 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)
  101541. */
  101542. fixedDragMeshScreenSize: boolean;
  101543. /**
  101544. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  101545. */
  101546. fixedDragMeshScreenSizeDistanceFactor: number;
  101547. /**
  101548. * Fired when a rotation sphere or scale box is dragged
  101549. */
  101550. onDragStartObservable: Observable<{}>;
  101551. /**
  101552. * Fired when a scale box is dragged
  101553. */
  101554. onScaleBoxDragObservable: Observable<{}>;
  101555. /**
  101556. * Fired when a scale box drag is ended
  101557. */
  101558. onScaleBoxDragEndObservable: Observable<{}>;
  101559. /**
  101560. * Fired when a rotation sphere is dragged
  101561. */
  101562. onRotationSphereDragObservable: Observable<{}>;
  101563. /**
  101564. * Fired when a rotation sphere drag is ended
  101565. */
  101566. onRotationSphereDragEndObservable: Observable<{}>;
  101567. /**
  101568. * 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)
  101569. */
  101570. scalePivot: Nullable<Vector3>;
  101571. private _anchorMesh;
  101572. private _existingMeshScale;
  101573. private _dragMesh;
  101574. private pointerDragBehavior;
  101575. private coloredMaterial;
  101576. private hoverColoredMaterial;
  101577. /**
  101578. * Sets the color of the bounding box gizmo
  101579. * @param color the color to set
  101580. */
  101581. setColor(color: Color3): void;
  101582. /**
  101583. * Creates an BoundingBoxGizmo
  101584. * @param gizmoLayer The utility layer the gizmo will be added to
  101585. * @param color The color of the gizmo
  101586. */
  101587. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  101588. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  101589. private _selectNode;
  101590. /**
  101591. * Updates the bounding box information for the Gizmo
  101592. */
  101593. updateBoundingBox(): void;
  101594. private _updateRotationSpheres;
  101595. private _updateScaleBoxes;
  101596. /**
  101597. * Enables rotation on the specified axis and disables rotation on the others
  101598. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  101599. */
  101600. setEnabledRotationAxis(axis: string): void;
  101601. /**
  101602. * Enables/disables scaling
  101603. * @param enable if scaling should be enabled
  101604. */
  101605. setEnabledScaling(enable: boolean): void;
  101606. private _updateDummy;
  101607. /**
  101608. * Enables a pointer drag behavior on the bounding box of the gizmo
  101609. */
  101610. enableDragBehavior(): void;
  101611. /**
  101612. * Disposes of the gizmo
  101613. */
  101614. dispose(): void;
  101615. /**
  101616. * 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)
  101617. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  101618. * @returns the bounding box mesh with the passed in mesh as a child
  101619. */
  101620. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  101621. /**
  101622. * CustomMeshes are not supported by this gizmo
  101623. * @param mesh The mesh to replace the default mesh of the gizmo
  101624. */
  101625. setCustomMesh(mesh: Mesh): void;
  101626. }
  101627. }
  101628. declare module BABYLON {
  101629. /**
  101630. * Single plane rotation gizmo
  101631. */
  101632. export class PlaneRotationGizmo extends Gizmo {
  101633. /**
  101634. * Drag behavior responsible for the gizmos dragging interactions
  101635. */
  101636. dragBehavior: PointerDragBehavior;
  101637. private _pointerObserver;
  101638. /**
  101639. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  101640. */
  101641. snapDistance: number;
  101642. /**
  101643. * Event that fires each time the gizmo snaps to a new location.
  101644. * * snapDistance is the the change in distance
  101645. */
  101646. onSnapObservable: Observable<{
  101647. snapDistance: number;
  101648. }>;
  101649. /**
  101650. * Creates a PlaneRotationGizmo
  101651. * @param gizmoLayer The utility layer the gizmo will be added to
  101652. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  101653. * @param color The color of the gizmo
  101654. * @param tessellation Amount of tessellation to be used when creating rotation circles
  101655. */
  101656. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  101657. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  101658. /**
  101659. * Disposes of the gizmo
  101660. */
  101661. dispose(): void;
  101662. }
  101663. }
  101664. declare module BABYLON {
  101665. /**
  101666. * Gizmo that enables rotating a mesh along 3 axis
  101667. */
  101668. export class RotationGizmo extends Gizmo {
  101669. /**
  101670. * Internal gizmo used for interactions on the x axis
  101671. */
  101672. xGizmo: PlaneRotationGizmo;
  101673. /**
  101674. * Internal gizmo used for interactions on the y axis
  101675. */
  101676. yGizmo: PlaneRotationGizmo;
  101677. /**
  101678. * Internal gizmo used for interactions on the z axis
  101679. */
  101680. zGizmo: PlaneRotationGizmo;
  101681. /** Fires an event when any of it's sub gizmos are dragged */
  101682. onDragStartObservable: Observable<{}>;
  101683. /** Fires an event when any of it's sub gizmos are released from dragging */
  101684. onDragEndObservable: Observable<{}>;
  101685. attachedMesh: Nullable<AbstractMesh>;
  101686. /**
  101687. * Creates a RotationGizmo
  101688. * @param gizmoLayer The utility layer the gizmo will be added to
  101689. * @param tessellation Amount of tessellation to be used when creating rotation circles
  101690. */
  101691. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  101692. updateGizmoRotationToMatchAttachedMesh: boolean;
  101693. /**
  101694. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  101695. */
  101696. snapDistance: number;
  101697. /**
  101698. * Ratio for the scale of the gizmo (Default: 1)
  101699. */
  101700. scaleRatio: number;
  101701. /**
  101702. * Disposes of the gizmo
  101703. */
  101704. dispose(): void;
  101705. /**
  101706. * CustomMeshes are not supported by this gizmo
  101707. * @param mesh The mesh to replace the default mesh of the gizmo
  101708. */
  101709. setCustomMesh(mesh: Mesh): void;
  101710. }
  101711. }
  101712. declare module BABYLON {
  101713. /**
  101714. * Gizmo that enables dragging a mesh along 3 axis
  101715. */
  101716. export class PositionGizmo extends Gizmo {
  101717. /**
  101718. * Internal gizmo used for interactions on the x axis
  101719. */
  101720. xGizmo: AxisDragGizmo;
  101721. /**
  101722. * Internal gizmo used for interactions on the y axis
  101723. */
  101724. yGizmo: AxisDragGizmo;
  101725. /**
  101726. * Internal gizmo used for interactions on the z axis
  101727. */
  101728. zGizmo: AxisDragGizmo;
  101729. /** Fires an event when any of it's sub gizmos are dragged */
  101730. onDragStartObservable: Observable<{}>;
  101731. /** Fires an event when any of it's sub gizmos are released from dragging */
  101732. onDragEndObservable: Observable<{}>;
  101733. attachedMesh: Nullable<AbstractMesh>;
  101734. /**
  101735. * Creates a PositionGizmo
  101736. * @param gizmoLayer The utility layer the gizmo will be added to
  101737. */
  101738. constructor(gizmoLayer?: UtilityLayerRenderer);
  101739. updateGizmoRotationToMatchAttachedMesh: boolean;
  101740. /**
  101741. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  101742. */
  101743. snapDistance: number;
  101744. /**
  101745. * Ratio for the scale of the gizmo (Default: 1)
  101746. */
  101747. scaleRatio: number;
  101748. /**
  101749. * Disposes of the gizmo
  101750. */
  101751. dispose(): void;
  101752. /**
  101753. * CustomMeshes are not supported by this gizmo
  101754. * @param mesh The mesh to replace the default mesh of the gizmo
  101755. */
  101756. setCustomMesh(mesh: Mesh): void;
  101757. }
  101758. }
  101759. declare module BABYLON {
  101760. /**
  101761. * Class containing static functions to help procedurally build meshes
  101762. */
  101763. export class PolyhedronBuilder {
  101764. /**
  101765. * Creates a polyhedron mesh
  101766. * * 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
  101767. * * The parameter `size` (positive float, default 1) sets the polygon size
  101768. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  101769. * * 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`
  101770. * * 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
  101771. * * 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)`)
  101772. * * 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
  101773. * * 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
  101774. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  101775. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  101776. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  101777. * @param name defines the name of the mesh
  101778. * @param options defines the options used to create the mesh
  101779. * @param scene defines the hosting scene
  101780. * @returns the polyhedron mesh
  101781. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  101782. */
  101783. static CreatePolyhedron(name: string, options: {
  101784. type?: number;
  101785. size?: number;
  101786. sizeX?: number;
  101787. sizeY?: number;
  101788. sizeZ?: number;
  101789. custom?: any;
  101790. faceUV?: Vector4[];
  101791. faceColors?: Color4[];
  101792. flat?: boolean;
  101793. updatable?: boolean;
  101794. sideOrientation?: number;
  101795. frontUVs?: Vector4;
  101796. backUVs?: Vector4;
  101797. }, scene?: Nullable<Scene>): Mesh;
  101798. }
  101799. }
  101800. declare module BABYLON {
  101801. /**
  101802. * Gizmo that enables scaling a mesh along 3 axis
  101803. */
  101804. export class ScaleGizmo extends Gizmo {
  101805. /**
  101806. * Internal gizmo used for interactions on the x axis
  101807. */
  101808. xGizmo: AxisScaleGizmo;
  101809. /**
  101810. * Internal gizmo used for interactions on the y axis
  101811. */
  101812. yGizmo: AxisScaleGizmo;
  101813. /**
  101814. * Internal gizmo used for interactions on the z axis
  101815. */
  101816. zGizmo: AxisScaleGizmo;
  101817. /**
  101818. * Internal gizmo used to scale all axis equally
  101819. */
  101820. uniformScaleGizmo: AxisScaleGizmo;
  101821. /** Fires an event when any of it's sub gizmos are dragged */
  101822. onDragStartObservable: Observable<{}>;
  101823. /** Fires an event when any of it's sub gizmos are released from dragging */
  101824. onDragEndObservable: Observable<{}>;
  101825. attachedMesh: Nullable<AbstractMesh>;
  101826. /**
  101827. * Creates a ScaleGizmo
  101828. * @param gizmoLayer The utility layer the gizmo will be added to
  101829. */
  101830. constructor(gizmoLayer?: UtilityLayerRenderer);
  101831. updateGizmoRotationToMatchAttachedMesh: boolean;
  101832. /**
  101833. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  101834. */
  101835. snapDistance: number;
  101836. /**
  101837. * Ratio for the scale of the gizmo (Default: 1)
  101838. */
  101839. scaleRatio: number;
  101840. /**
  101841. * Disposes of the gizmo
  101842. */
  101843. dispose(): void;
  101844. }
  101845. }
  101846. declare module BABYLON {
  101847. /**
  101848. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  101849. */
  101850. export class GizmoManager implements IDisposable {
  101851. private scene;
  101852. /**
  101853. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  101854. */
  101855. gizmos: {
  101856. positionGizmo: Nullable<PositionGizmo>;
  101857. rotationGizmo: Nullable<RotationGizmo>;
  101858. scaleGizmo: Nullable<ScaleGizmo>;
  101859. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  101860. };
  101861. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  101862. clearGizmoOnEmptyPointerEvent: boolean;
  101863. /** Fires an event when the manager is attached to a mesh */
  101864. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  101865. private _gizmosEnabled;
  101866. private _pointerObserver;
  101867. private _attachedMesh;
  101868. private _boundingBoxColor;
  101869. private _defaultUtilityLayer;
  101870. private _defaultKeepDepthUtilityLayer;
  101871. /**
  101872. * When bounding box gizmo is enabled, this can be used to track drag/end events
  101873. */
  101874. boundingBoxDragBehavior: SixDofDragBehavior;
  101875. /**
  101876. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  101877. */
  101878. attachableMeshes: Nullable<Array<AbstractMesh>>;
  101879. /**
  101880. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  101881. */
  101882. usePointerToAttachGizmos: boolean;
  101883. /**
  101884. * Instatiates a gizmo manager
  101885. * @param scene the scene to overlay the gizmos on top of
  101886. */
  101887. constructor(scene: Scene);
  101888. /**
  101889. * Attaches a set of gizmos to the specified mesh
  101890. * @param mesh The mesh the gizmo's should be attached to
  101891. */
  101892. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  101893. /**
  101894. * If the position gizmo is enabled
  101895. */
  101896. positionGizmoEnabled: boolean;
  101897. /**
  101898. * If the rotation gizmo is enabled
  101899. */
  101900. rotationGizmoEnabled: boolean;
  101901. /**
  101902. * If the scale gizmo is enabled
  101903. */
  101904. scaleGizmoEnabled: boolean;
  101905. /**
  101906. * If the boundingBox gizmo is enabled
  101907. */
  101908. boundingBoxGizmoEnabled: boolean;
  101909. /**
  101910. * Disposes of the gizmo manager
  101911. */
  101912. dispose(): void;
  101913. }
  101914. }
  101915. declare module BABYLON {
  101916. /**
  101917. * A directional light is defined by a direction (what a surprise!).
  101918. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  101919. * 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.
  101920. * Documentation: https://doc.babylonjs.com/babylon101/lights
  101921. */
  101922. export class DirectionalLight extends ShadowLight {
  101923. private _shadowFrustumSize;
  101924. /**
  101925. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  101926. */
  101927. /**
  101928. * Specifies a fix frustum size for the shadow generation.
  101929. */
  101930. shadowFrustumSize: number;
  101931. private _shadowOrthoScale;
  101932. /**
  101933. * Gets the shadow projection scale against the optimal computed one.
  101934. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  101935. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  101936. */
  101937. /**
  101938. * Sets the shadow projection scale against the optimal computed one.
  101939. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  101940. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  101941. */
  101942. shadowOrthoScale: number;
  101943. /**
  101944. * Automatically compute the projection matrix to best fit (including all the casters)
  101945. * on each frame.
  101946. */
  101947. autoUpdateExtends: boolean;
  101948. private _orthoLeft;
  101949. private _orthoRight;
  101950. private _orthoTop;
  101951. private _orthoBottom;
  101952. /**
  101953. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  101954. * The directional light is emitted from everywhere in the given direction.
  101955. * It can cast shadows.
  101956. * Documentation : https://doc.babylonjs.com/babylon101/lights
  101957. * @param name The friendly name of the light
  101958. * @param direction The direction of the light
  101959. * @param scene The scene the light belongs to
  101960. */
  101961. constructor(name: string, direction: Vector3, scene: Scene);
  101962. /**
  101963. * Returns the string "DirectionalLight".
  101964. * @return The class name
  101965. */
  101966. getClassName(): string;
  101967. /**
  101968. * Returns the integer 1.
  101969. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  101970. */
  101971. getTypeID(): number;
  101972. /**
  101973. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  101974. * Returns the DirectionalLight Shadow projection matrix.
  101975. */
  101976. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  101977. /**
  101978. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  101979. * Returns the DirectionalLight Shadow projection matrix.
  101980. */
  101981. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  101982. /**
  101983. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  101984. * Returns the DirectionalLight Shadow projection matrix.
  101985. */
  101986. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  101987. protected _buildUniformLayout(): void;
  101988. /**
  101989. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  101990. * @param effect The effect to update
  101991. * @param lightIndex The index of the light in the effect to update
  101992. * @returns The directional light
  101993. */
  101994. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  101995. /**
  101996. * Gets the minZ used for shadow according to both the scene and the light.
  101997. *
  101998. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  101999. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  102000. * @param activeCamera The camera we are returning the min for
  102001. * @returns the depth min z
  102002. */
  102003. getDepthMinZ(activeCamera: Camera): number;
  102004. /**
  102005. * Gets the maxZ used for shadow according to both the scene and the light.
  102006. *
  102007. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  102008. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  102009. * @param activeCamera The camera we are returning the max for
  102010. * @returns the depth max z
  102011. */
  102012. getDepthMaxZ(activeCamera: Camera): number;
  102013. /**
  102014. * Prepares the list of defines specific to the light type.
  102015. * @param defines the list of defines
  102016. * @param lightIndex defines the index of the light for the effect
  102017. */
  102018. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  102019. }
  102020. }
  102021. declare module BABYLON {
  102022. /**
  102023. * Class containing static functions to help procedurally build meshes
  102024. */
  102025. export class HemisphereBuilder {
  102026. /**
  102027. * Creates a hemisphere mesh
  102028. * @param name defines the name of the mesh
  102029. * @param options defines the options used to create the mesh
  102030. * @param scene defines the hosting scene
  102031. * @returns the hemisphere mesh
  102032. */
  102033. static CreateHemisphere(name: string, options: {
  102034. segments?: number;
  102035. diameter?: number;
  102036. sideOrientation?: number;
  102037. }, scene: any): Mesh;
  102038. }
  102039. }
  102040. declare module BABYLON {
  102041. /**
  102042. * A spot light is defined by a position, a direction, an angle, and an exponent.
  102043. * These values define a cone of light starting from the position, emitting toward the direction.
  102044. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  102045. * and the exponent defines the speed of the decay of the light with distance (reach).
  102046. * Documentation: https://doc.babylonjs.com/babylon101/lights
  102047. */
  102048. export class SpotLight extends ShadowLight {
  102049. private _angle;
  102050. private _innerAngle;
  102051. private _cosHalfAngle;
  102052. private _lightAngleScale;
  102053. private _lightAngleOffset;
  102054. /**
  102055. * Gets the cone angle of the spot light in Radians.
  102056. */
  102057. /**
  102058. * Sets the cone angle of the spot light in Radians.
  102059. */
  102060. angle: number;
  102061. /**
  102062. * Only used in gltf falloff mode, this defines the angle where
  102063. * the directional falloff will start before cutting at angle which could be seen
  102064. * as outer angle.
  102065. */
  102066. /**
  102067. * Only used in gltf falloff mode, this defines the angle where
  102068. * the directional falloff will start before cutting at angle which could be seen
  102069. * as outer angle.
  102070. */
  102071. innerAngle: number;
  102072. private _shadowAngleScale;
  102073. /**
  102074. * Allows scaling the angle of the light for shadow generation only.
  102075. */
  102076. /**
  102077. * Allows scaling the angle of the light for shadow generation only.
  102078. */
  102079. shadowAngleScale: number;
  102080. /**
  102081. * The light decay speed with the distance from the emission spot.
  102082. */
  102083. exponent: number;
  102084. private _projectionTextureMatrix;
  102085. /**
  102086. * Allows reading the projecton texture
  102087. */
  102088. readonly projectionTextureMatrix: Matrix;
  102089. protected _projectionTextureLightNear: number;
  102090. /**
  102091. * Gets the near clip of the Spotlight for texture projection.
  102092. */
  102093. /**
  102094. * Sets the near clip of the Spotlight for texture projection.
  102095. */
  102096. projectionTextureLightNear: number;
  102097. protected _projectionTextureLightFar: number;
  102098. /**
  102099. * Gets the far clip of the Spotlight for texture projection.
  102100. */
  102101. /**
  102102. * Sets the far clip of the Spotlight for texture projection.
  102103. */
  102104. projectionTextureLightFar: number;
  102105. protected _projectionTextureUpDirection: Vector3;
  102106. /**
  102107. * Gets the Up vector of the Spotlight for texture projection.
  102108. */
  102109. /**
  102110. * Sets the Up vector of the Spotlight for texture projection.
  102111. */
  102112. projectionTextureUpDirection: Vector3;
  102113. private _projectionTexture;
  102114. /**
  102115. * Gets the projection texture of the light.
  102116. */
  102117. /**
  102118. * Sets the projection texture of the light.
  102119. */
  102120. projectionTexture: Nullable<BaseTexture>;
  102121. private _projectionTextureViewLightDirty;
  102122. private _projectionTextureProjectionLightDirty;
  102123. private _projectionTextureDirty;
  102124. private _projectionTextureViewTargetVector;
  102125. private _projectionTextureViewLightMatrix;
  102126. private _projectionTextureProjectionLightMatrix;
  102127. private _projectionTextureScalingMatrix;
  102128. /**
  102129. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  102130. * It can cast shadows.
  102131. * Documentation : https://doc.babylonjs.com/babylon101/lights
  102132. * @param name The light friendly name
  102133. * @param position The position of the spot light in the scene
  102134. * @param direction The direction of the light in the scene
  102135. * @param angle The cone angle of the light in Radians
  102136. * @param exponent The light decay speed with the distance from the emission spot
  102137. * @param scene The scene the lights belongs to
  102138. */
  102139. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  102140. /**
  102141. * Returns the string "SpotLight".
  102142. * @returns the class name
  102143. */
  102144. getClassName(): string;
  102145. /**
  102146. * Returns the integer 2.
  102147. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  102148. */
  102149. getTypeID(): number;
  102150. /**
  102151. * Overrides the direction setter to recompute the projection texture view light Matrix.
  102152. */
  102153. protected _setDirection(value: Vector3): void;
  102154. /**
  102155. * Overrides the position setter to recompute the projection texture view light Matrix.
  102156. */
  102157. protected _setPosition(value: Vector3): void;
  102158. /**
  102159. * 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.
  102160. * Returns the SpotLight.
  102161. */
  102162. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  102163. protected _computeProjectionTextureViewLightMatrix(): void;
  102164. protected _computeProjectionTextureProjectionLightMatrix(): void;
  102165. /**
  102166. * Main function for light texture projection matrix computing.
  102167. */
  102168. protected _computeProjectionTextureMatrix(): void;
  102169. protected _buildUniformLayout(): void;
  102170. private _computeAngleValues;
  102171. /**
  102172. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  102173. * @param effect The effect to update
  102174. * @param lightIndex The index of the light in the effect to update
  102175. * @returns The spot light
  102176. */
  102177. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  102178. /**
  102179. * Disposes the light and the associated resources.
  102180. */
  102181. dispose(): void;
  102182. /**
  102183. * Prepares the list of defines specific to the light type.
  102184. * @param defines the list of defines
  102185. * @param lightIndex defines the index of the light for the effect
  102186. */
  102187. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  102188. }
  102189. }
  102190. declare module BABYLON {
  102191. /**
  102192. * Gizmo that enables viewing a light
  102193. */
  102194. export class LightGizmo extends Gizmo {
  102195. private _lightMesh;
  102196. private _material;
  102197. /**
  102198. * Creates a LightGizmo
  102199. * @param gizmoLayer The utility layer the gizmo will be added to
  102200. */
  102201. constructor(gizmoLayer?: UtilityLayerRenderer);
  102202. private _light;
  102203. /**
  102204. * The light that the gizmo is attached to
  102205. */
  102206. light: Nullable<Light>;
  102207. /**
  102208. * @hidden
  102209. * Updates the gizmo to match the attached mesh's position/rotation
  102210. */
  102211. protected _update(): void;
  102212. private static _Scale;
  102213. /**
  102214. * Creates the lines for a light mesh
  102215. */
  102216. private static _createLightLines;
  102217. private static _CreateHemisphericLightMesh;
  102218. private static _CreatePointLightMesh;
  102219. private static _CreateSpotLightMesh;
  102220. private static _CreateDirectionalLightMesh;
  102221. }
  102222. }
  102223. declare module BABYLON {
  102224. /** @hidden */
  102225. export var backgroundFragmentDeclaration: {
  102226. name: string;
  102227. shader: string;
  102228. };
  102229. }
  102230. declare module BABYLON {
  102231. /** @hidden */
  102232. export var backgroundUboDeclaration: {
  102233. name: string;
  102234. shader: string;
  102235. };
  102236. }
  102237. declare module BABYLON {
  102238. /** @hidden */
  102239. export var backgroundPixelShader: {
  102240. name: string;
  102241. shader: string;
  102242. };
  102243. }
  102244. declare module BABYLON {
  102245. /** @hidden */
  102246. export var backgroundVertexDeclaration: {
  102247. name: string;
  102248. shader: string;
  102249. };
  102250. }
  102251. declare module BABYLON {
  102252. /** @hidden */
  102253. export var backgroundVertexShader: {
  102254. name: string;
  102255. shader: string;
  102256. };
  102257. }
  102258. declare module BABYLON {
  102259. /**
  102260. * Background material used to create an efficient environement around your scene.
  102261. */
  102262. export class BackgroundMaterial extends PushMaterial {
  102263. /**
  102264. * Standard reflectance value at parallel view angle.
  102265. */
  102266. static StandardReflectance0: number;
  102267. /**
  102268. * Standard reflectance value at grazing angle.
  102269. */
  102270. static StandardReflectance90: number;
  102271. protected _primaryColor: Color3;
  102272. /**
  102273. * Key light Color (multiply against the environement texture)
  102274. */
  102275. primaryColor: Color3;
  102276. protected __perceptualColor: Nullable<Color3>;
  102277. /**
  102278. * Experimental Internal Use Only.
  102279. *
  102280. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  102281. * This acts as a helper to set the primary color to a more "human friendly" value.
  102282. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  102283. * output color as close as possible from the chosen value.
  102284. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  102285. * part of lighting setup.)
  102286. */
  102287. _perceptualColor: Nullable<Color3>;
  102288. protected _primaryColorShadowLevel: float;
  102289. /**
  102290. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  102291. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  102292. */
  102293. primaryColorShadowLevel: float;
  102294. protected _primaryColorHighlightLevel: float;
  102295. /**
  102296. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  102297. * The primary color is used at the level chosen to define what the white area would look.
  102298. */
  102299. primaryColorHighlightLevel: float;
  102300. protected _reflectionTexture: Nullable<BaseTexture>;
  102301. /**
  102302. * Reflection Texture used in the material.
  102303. * Should be author in a specific way for the best result (refer to the documentation).
  102304. */
  102305. reflectionTexture: Nullable<BaseTexture>;
  102306. protected _reflectionBlur: float;
  102307. /**
  102308. * Reflection Texture level of blur.
  102309. *
  102310. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  102311. * texture twice.
  102312. */
  102313. reflectionBlur: float;
  102314. protected _diffuseTexture: Nullable<BaseTexture>;
  102315. /**
  102316. * Diffuse Texture used in the material.
  102317. * Should be author in a specific way for the best result (refer to the documentation).
  102318. */
  102319. diffuseTexture: Nullable<BaseTexture>;
  102320. protected _shadowLights: Nullable<IShadowLight[]>;
  102321. /**
  102322. * Specify the list of lights casting shadow on the material.
  102323. * All scene shadow lights will be included if null.
  102324. */
  102325. shadowLights: Nullable<IShadowLight[]>;
  102326. protected _shadowLevel: float;
  102327. /**
  102328. * Helps adjusting the shadow to a softer level if required.
  102329. * 0 means black shadows and 1 means no shadows.
  102330. */
  102331. shadowLevel: float;
  102332. protected _sceneCenter: Vector3;
  102333. /**
  102334. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  102335. * It is usually zero but might be interesting to modify according to your setup.
  102336. */
  102337. sceneCenter: Vector3;
  102338. protected _opacityFresnel: boolean;
  102339. /**
  102340. * This helps specifying that the material is falling off to the sky box at grazing angle.
  102341. * This helps ensuring a nice transition when the camera goes under the ground.
  102342. */
  102343. opacityFresnel: boolean;
  102344. protected _reflectionFresnel: boolean;
  102345. /**
  102346. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  102347. * This helps adding a mirror texture on the ground.
  102348. */
  102349. reflectionFresnel: boolean;
  102350. protected _reflectionFalloffDistance: number;
  102351. /**
  102352. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  102353. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  102354. */
  102355. reflectionFalloffDistance: number;
  102356. protected _reflectionAmount: number;
  102357. /**
  102358. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  102359. */
  102360. reflectionAmount: number;
  102361. protected _reflectionReflectance0: number;
  102362. /**
  102363. * This specifies the weight of the reflection at grazing angle.
  102364. */
  102365. reflectionReflectance0: number;
  102366. protected _reflectionReflectance90: number;
  102367. /**
  102368. * This specifies the weight of the reflection at a perpendicular point of view.
  102369. */
  102370. reflectionReflectance90: number;
  102371. /**
  102372. * Sets the reflection reflectance fresnel values according to the default standard
  102373. * empirically know to work well :-)
  102374. */
  102375. reflectionStandardFresnelWeight: number;
  102376. protected _useRGBColor: boolean;
  102377. /**
  102378. * Helps to directly use the maps channels instead of their level.
  102379. */
  102380. useRGBColor: boolean;
  102381. protected _enableNoise: boolean;
  102382. /**
  102383. * This helps reducing the banding effect that could occur on the background.
  102384. */
  102385. enableNoise: boolean;
  102386. /**
  102387. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  102388. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  102389. * Recommended to be keep at 1.0 except for special cases.
  102390. */
  102391. fovMultiplier: number;
  102392. private _fovMultiplier;
  102393. /**
  102394. * Enable the FOV adjustment feature controlled by fovMultiplier.
  102395. */
  102396. useEquirectangularFOV: boolean;
  102397. private _maxSimultaneousLights;
  102398. /**
  102399. * Number of Simultaneous lights allowed on the material.
  102400. */
  102401. maxSimultaneousLights: int;
  102402. /**
  102403. * Default configuration related to image processing available in the Background Material.
  102404. */
  102405. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  102406. /**
  102407. * Keep track of the image processing observer to allow dispose and replace.
  102408. */
  102409. private _imageProcessingObserver;
  102410. /**
  102411. * Attaches a new image processing configuration to the PBR Material.
  102412. * @param configuration (if null the scene configuration will be use)
  102413. */
  102414. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  102415. /**
  102416. * Gets the image processing configuration used either in this material.
  102417. */
  102418. /**
  102419. * Sets the Default image processing configuration used either in the this material.
  102420. *
  102421. * If sets to null, the scene one is in use.
  102422. */
  102423. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  102424. /**
  102425. * Gets wether the color curves effect is enabled.
  102426. */
  102427. /**
  102428. * Sets wether the color curves effect is enabled.
  102429. */
  102430. cameraColorCurvesEnabled: boolean;
  102431. /**
  102432. * Gets wether the color grading effect is enabled.
  102433. */
  102434. /**
  102435. * Gets wether the color grading effect is enabled.
  102436. */
  102437. cameraColorGradingEnabled: boolean;
  102438. /**
  102439. * Gets wether tonemapping is enabled or not.
  102440. */
  102441. /**
  102442. * Sets wether tonemapping is enabled or not
  102443. */
  102444. cameraToneMappingEnabled: boolean;
  102445. /**
  102446. * The camera exposure used on this material.
  102447. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  102448. * This corresponds to a photographic exposure.
  102449. */
  102450. /**
  102451. * The camera exposure used on this material.
  102452. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  102453. * This corresponds to a photographic exposure.
  102454. */
  102455. cameraExposure: float;
  102456. /**
  102457. * Gets The camera contrast used on this material.
  102458. */
  102459. /**
  102460. * Sets The camera contrast used on this material.
  102461. */
  102462. cameraContrast: float;
  102463. /**
  102464. * Gets the Color Grading 2D Lookup Texture.
  102465. */
  102466. /**
  102467. * Sets the Color Grading 2D Lookup Texture.
  102468. */
  102469. cameraColorGradingTexture: Nullable<BaseTexture>;
  102470. /**
  102471. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  102472. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  102473. * 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;
  102474. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  102475. */
  102476. /**
  102477. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  102478. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  102479. * 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;
  102480. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  102481. */
  102482. cameraColorCurves: Nullable<ColorCurves>;
  102483. /**
  102484. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  102485. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  102486. */
  102487. switchToBGR: boolean;
  102488. private _renderTargets;
  102489. private _reflectionControls;
  102490. private _white;
  102491. private _primaryShadowColor;
  102492. private _primaryHighlightColor;
  102493. /**
  102494. * Instantiates a Background Material in the given scene
  102495. * @param name The friendly name of the material
  102496. * @param scene The scene to add the material to
  102497. */
  102498. constructor(name: string, scene: Scene);
  102499. /**
  102500. * Gets a boolean indicating that current material needs to register RTT
  102501. */
  102502. readonly hasRenderTargetTextures: boolean;
  102503. /**
  102504. * The entire material has been created in order to prevent overdraw.
  102505. * @returns false
  102506. */
  102507. needAlphaTesting(): boolean;
  102508. /**
  102509. * The entire material has been created in order to prevent overdraw.
  102510. * @returns true if blending is enable
  102511. */
  102512. needAlphaBlending(): boolean;
  102513. /**
  102514. * Checks wether the material is ready to be rendered for a given mesh.
  102515. * @param mesh The mesh to render
  102516. * @param subMesh The submesh to check against
  102517. * @param useInstances Specify wether or not the material is used with instances
  102518. * @returns true if all the dependencies are ready (Textures, Effects...)
  102519. */
  102520. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  102521. /**
  102522. * Compute the primary color according to the chosen perceptual color.
  102523. */
  102524. private _computePrimaryColorFromPerceptualColor;
  102525. /**
  102526. * Compute the highlights and shadow colors according to their chosen levels.
  102527. */
  102528. private _computePrimaryColors;
  102529. /**
  102530. * Build the uniform buffer used in the material.
  102531. */
  102532. buildUniformLayout(): void;
  102533. /**
  102534. * Unbind the material.
  102535. */
  102536. unbind(): void;
  102537. /**
  102538. * Bind only the world matrix to the material.
  102539. * @param world The world matrix to bind.
  102540. */
  102541. bindOnlyWorldMatrix(world: Matrix): void;
  102542. /**
  102543. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  102544. * @param world The world matrix to bind.
  102545. * @param subMesh The submesh to bind for.
  102546. */
  102547. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  102548. /**
  102549. * Dispose the material.
  102550. * @param forceDisposeEffect Force disposal of the associated effect.
  102551. * @param forceDisposeTextures Force disposal of the associated textures.
  102552. */
  102553. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  102554. /**
  102555. * Clones the material.
  102556. * @param name The cloned name.
  102557. * @returns The cloned material.
  102558. */
  102559. clone(name: string): BackgroundMaterial;
  102560. /**
  102561. * Serializes the current material to its JSON representation.
  102562. * @returns The JSON representation.
  102563. */
  102564. serialize(): any;
  102565. /**
  102566. * Gets the class name of the material
  102567. * @returns "BackgroundMaterial"
  102568. */
  102569. getClassName(): string;
  102570. /**
  102571. * Parse a JSON input to create back a background material.
  102572. * @param source The JSON data to parse
  102573. * @param scene The scene to create the parsed material in
  102574. * @param rootUrl The root url of the assets the material depends upon
  102575. * @returns the instantiated BackgroundMaterial.
  102576. */
  102577. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  102578. }
  102579. }
  102580. declare module BABYLON {
  102581. /**
  102582. * Represents the different options available during the creation of
  102583. * a Environment helper.
  102584. *
  102585. * This can control the default ground, skybox and image processing setup of your scene.
  102586. */
  102587. export interface IEnvironmentHelperOptions {
  102588. /**
  102589. * Specifies wether or not to create a ground.
  102590. * True by default.
  102591. */
  102592. createGround: boolean;
  102593. /**
  102594. * Specifies the ground size.
  102595. * 15 by default.
  102596. */
  102597. groundSize: number;
  102598. /**
  102599. * The texture used on the ground for the main color.
  102600. * Comes from the BabylonJS CDN by default.
  102601. *
  102602. * Remarks: Can be either a texture or a url.
  102603. */
  102604. groundTexture: string | BaseTexture;
  102605. /**
  102606. * The color mixed in the ground texture by default.
  102607. * BabylonJS clearColor by default.
  102608. */
  102609. groundColor: Color3;
  102610. /**
  102611. * Specifies the ground opacity.
  102612. * 1 by default.
  102613. */
  102614. groundOpacity: number;
  102615. /**
  102616. * Enables the ground to receive shadows.
  102617. * True by default.
  102618. */
  102619. enableGroundShadow: boolean;
  102620. /**
  102621. * Helps preventing the shadow to be fully black on the ground.
  102622. * 0.5 by default.
  102623. */
  102624. groundShadowLevel: number;
  102625. /**
  102626. * Creates a mirror texture attach to the ground.
  102627. * false by default.
  102628. */
  102629. enableGroundMirror: boolean;
  102630. /**
  102631. * Specifies the ground mirror size ratio.
  102632. * 0.3 by default as the default kernel is 64.
  102633. */
  102634. groundMirrorSizeRatio: number;
  102635. /**
  102636. * Specifies the ground mirror blur kernel size.
  102637. * 64 by default.
  102638. */
  102639. groundMirrorBlurKernel: number;
  102640. /**
  102641. * Specifies the ground mirror visibility amount.
  102642. * 1 by default
  102643. */
  102644. groundMirrorAmount: number;
  102645. /**
  102646. * Specifies the ground mirror reflectance weight.
  102647. * This uses the standard weight of the background material to setup the fresnel effect
  102648. * of the mirror.
  102649. * 1 by default.
  102650. */
  102651. groundMirrorFresnelWeight: number;
  102652. /**
  102653. * Specifies the ground mirror Falloff distance.
  102654. * This can helps reducing the size of the reflection.
  102655. * 0 by Default.
  102656. */
  102657. groundMirrorFallOffDistance: number;
  102658. /**
  102659. * Specifies the ground mirror texture type.
  102660. * Unsigned Int by Default.
  102661. */
  102662. groundMirrorTextureType: number;
  102663. /**
  102664. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  102665. * the shown objects.
  102666. */
  102667. groundYBias: number;
  102668. /**
  102669. * Specifies wether or not to create a skybox.
  102670. * True by default.
  102671. */
  102672. createSkybox: boolean;
  102673. /**
  102674. * Specifies the skybox size.
  102675. * 20 by default.
  102676. */
  102677. skyboxSize: number;
  102678. /**
  102679. * The texture used on the skybox for the main color.
  102680. * Comes from the BabylonJS CDN by default.
  102681. *
  102682. * Remarks: Can be either a texture or a url.
  102683. */
  102684. skyboxTexture: string | BaseTexture;
  102685. /**
  102686. * The color mixed in the skybox texture by default.
  102687. * BabylonJS clearColor by default.
  102688. */
  102689. skyboxColor: Color3;
  102690. /**
  102691. * The background rotation around the Y axis of the scene.
  102692. * This helps aligning the key lights of your scene with the background.
  102693. * 0 by default.
  102694. */
  102695. backgroundYRotation: number;
  102696. /**
  102697. * Compute automatically the size of the elements to best fit with the scene.
  102698. */
  102699. sizeAuto: boolean;
  102700. /**
  102701. * Default position of the rootMesh if autoSize is not true.
  102702. */
  102703. rootPosition: Vector3;
  102704. /**
  102705. * Sets up the image processing in the scene.
  102706. * true by default.
  102707. */
  102708. setupImageProcessing: boolean;
  102709. /**
  102710. * The texture used as your environment texture in the scene.
  102711. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  102712. *
  102713. * Remarks: Can be either a texture or a url.
  102714. */
  102715. environmentTexture: string | BaseTexture;
  102716. /**
  102717. * The value of the exposure to apply to the scene.
  102718. * 0.6 by default if setupImageProcessing is true.
  102719. */
  102720. cameraExposure: number;
  102721. /**
  102722. * The value of the contrast to apply to the scene.
  102723. * 1.6 by default if setupImageProcessing is true.
  102724. */
  102725. cameraContrast: number;
  102726. /**
  102727. * Specifies wether or not tonemapping should be enabled in the scene.
  102728. * true by default if setupImageProcessing is true.
  102729. */
  102730. toneMappingEnabled: boolean;
  102731. }
  102732. /**
  102733. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  102734. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  102735. * It also helps with the default setup of your imageProcessing configuration.
  102736. */
  102737. export class EnvironmentHelper {
  102738. /**
  102739. * Default ground texture URL.
  102740. */
  102741. private static _groundTextureCDNUrl;
  102742. /**
  102743. * Default skybox texture URL.
  102744. */
  102745. private static _skyboxTextureCDNUrl;
  102746. /**
  102747. * Default environment texture URL.
  102748. */
  102749. private static _environmentTextureCDNUrl;
  102750. /**
  102751. * Creates the default options for the helper.
  102752. */
  102753. private static _getDefaultOptions;
  102754. private _rootMesh;
  102755. /**
  102756. * Gets the root mesh created by the helper.
  102757. */
  102758. readonly rootMesh: Mesh;
  102759. private _skybox;
  102760. /**
  102761. * Gets the skybox created by the helper.
  102762. */
  102763. readonly skybox: Nullable<Mesh>;
  102764. private _skyboxTexture;
  102765. /**
  102766. * Gets the skybox texture created by the helper.
  102767. */
  102768. readonly skyboxTexture: Nullable<BaseTexture>;
  102769. private _skyboxMaterial;
  102770. /**
  102771. * Gets the skybox material created by the helper.
  102772. */
  102773. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  102774. private _ground;
  102775. /**
  102776. * Gets the ground mesh created by the helper.
  102777. */
  102778. readonly ground: Nullable<Mesh>;
  102779. private _groundTexture;
  102780. /**
  102781. * Gets the ground texture created by the helper.
  102782. */
  102783. readonly groundTexture: Nullable<BaseTexture>;
  102784. private _groundMirror;
  102785. /**
  102786. * Gets the ground mirror created by the helper.
  102787. */
  102788. readonly groundMirror: Nullable<MirrorTexture>;
  102789. /**
  102790. * Gets the ground mirror render list to helps pushing the meshes
  102791. * you wish in the ground reflection.
  102792. */
  102793. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  102794. private _groundMaterial;
  102795. /**
  102796. * Gets the ground material created by the helper.
  102797. */
  102798. readonly groundMaterial: Nullable<BackgroundMaterial>;
  102799. /**
  102800. * Stores the creation options.
  102801. */
  102802. private readonly _scene;
  102803. private _options;
  102804. /**
  102805. * This observable will be notified with any error during the creation of the environment,
  102806. * mainly texture creation errors.
  102807. */
  102808. onErrorObservable: Observable<{
  102809. message?: string;
  102810. exception?: any;
  102811. }>;
  102812. /**
  102813. * constructor
  102814. * @param options Defines the options we want to customize the helper
  102815. * @param scene The scene to add the material to
  102816. */
  102817. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  102818. /**
  102819. * Updates the background according to the new options
  102820. * @param options
  102821. */
  102822. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  102823. /**
  102824. * Sets the primary color of all the available elements.
  102825. * @param color the main color to affect to the ground and the background
  102826. */
  102827. setMainColor(color: Color3): void;
  102828. /**
  102829. * Setup the image processing according to the specified options.
  102830. */
  102831. private _setupImageProcessing;
  102832. /**
  102833. * Setup the environment texture according to the specified options.
  102834. */
  102835. private _setupEnvironmentTexture;
  102836. /**
  102837. * Setup the background according to the specified options.
  102838. */
  102839. private _setupBackground;
  102840. /**
  102841. * Get the scene sizes according to the setup.
  102842. */
  102843. private _getSceneSize;
  102844. /**
  102845. * Setup the ground according to the specified options.
  102846. */
  102847. private _setupGround;
  102848. /**
  102849. * Setup the ground material according to the specified options.
  102850. */
  102851. private _setupGroundMaterial;
  102852. /**
  102853. * Setup the ground diffuse texture according to the specified options.
  102854. */
  102855. private _setupGroundDiffuseTexture;
  102856. /**
  102857. * Setup the ground mirror texture according to the specified options.
  102858. */
  102859. private _setupGroundMirrorTexture;
  102860. /**
  102861. * Setup the ground to receive the mirror texture.
  102862. */
  102863. private _setupMirrorInGroundMaterial;
  102864. /**
  102865. * Setup the skybox according to the specified options.
  102866. */
  102867. private _setupSkybox;
  102868. /**
  102869. * Setup the skybox material according to the specified options.
  102870. */
  102871. private _setupSkyboxMaterial;
  102872. /**
  102873. * Setup the skybox reflection texture according to the specified options.
  102874. */
  102875. private _setupSkyboxReflectionTexture;
  102876. private _errorHandler;
  102877. /**
  102878. * Dispose all the elements created by the Helper.
  102879. */
  102880. dispose(): void;
  102881. }
  102882. }
  102883. declare module BABYLON {
  102884. /**
  102885. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  102886. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  102887. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  102888. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  102889. */
  102890. export class PhotoDome extends TransformNode {
  102891. private _useDirectMapping;
  102892. /**
  102893. * The texture being displayed on the sphere
  102894. */
  102895. protected _photoTexture: Texture;
  102896. /**
  102897. * Gets or sets the texture being displayed on the sphere
  102898. */
  102899. photoTexture: Texture;
  102900. /**
  102901. * Observable raised when an error occured while loading the 360 image
  102902. */
  102903. onLoadErrorObservable: Observable<string>;
  102904. /**
  102905. * The skybox material
  102906. */
  102907. protected _material: BackgroundMaterial;
  102908. /**
  102909. * The surface used for the skybox
  102910. */
  102911. protected _mesh: Mesh;
  102912. /**
  102913. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  102914. * Also see the options.resolution property.
  102915. */
  102916. fovMultiplier: number;
  102917. /**
  102918. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  102919. * @param name Element's name, child elements will append suffixes for their own names.
  102920. * @param urlsOfPhoto defines the url of the photo to display
  102921. * @param options defines an object containing optional or exposed sub element properties
  102922. * @param onError defines a callback called when an error occured while loading the texture
  102923. */
  102924. constructor(name: string, urlOfPhoto: string, options: {
  102925. resolution?: number;
  102926. size?: number;
  102927. useDirectMapping?: boolean;
  102928. faceForward?: boolean;
  102929. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  102930. /**
  102931. * Releases resources associated with this node.
  102932. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  102933. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  102934. */
  102935. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  102936. }
  102937. }
  102938. declare module BABYLON {
  102939. /** @hidden */
  102940. export var rgbdDecodePixelShader: {
  102941. name: string;
  102942. shader: string;
  102943. };
  102944. }
  102945. declare module BABYLON {
  102946. /**
  102947. * Class used to host texture specific utilities
  102948. */
  102949. export class BRDFTextureTools {
  102950. /**
  102951. * Expand the BRDF Texture from RGBD to Half Float if necessary.
  102952. * @param texture the texture to expand.
  102953. */
  102954. private static _ExpandDefaultBRDFTexture;
  102955. /**
  102956. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  102957. * @param scene defines the hosting scene
  102958. * @returns the environment BRDF texture
  102959. */
  102960. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  102961. private static _environmentBRDFBase64Texture;
  102962. }
  102963. }
  102964. declare module BABYLON {
  102965. /**
  102966. * @hidden
  102967. */
  102968. export interface IMaterialClearCoatDefines {
  102969. CLEARCOAT: boolean;
  102970. CLEARCOAT_DEFAULTIOR: boolean;
  102971. CLEARCOAT_TEXTURE: boolean;
  102972. CLEARCOAT_TEXTUREDIRECTUV: number;
  102973. CLEARCOAT_BUMP: boolean;
  102974. CLEARCOAT_BUMPDIRECTUV: number;
  102975. CLEARCOAT_TINT: boolean;
  102976. CLEARCOAT_TINT_TEXTURE: boolean;
  102977. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  102978. /** @hidden */
  102979. _areTexturesDirty: boolean;
  102980. }
  102981. /**
  102982. * Define the code related to the clear coat parameters of the pbr material.
  102983. */
  102984. export class PBRClearCoatConfiguration {
  102985. /**
  102986. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  102987. * The default fits with a polyurethane material.
  102988. */
  102989. private static readonly _DefaultIndiceOfRefraction;
  102990. private _isEnabled;
  102991. /**
  102992. * Defines if the clear coat is enabled in the material.
  102993. */
  102994. isEnabled: boolean;
  102995. /**
  102996. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  102997. */
  102998. intensity: number;
  102999. /**
  103000. * Defines the clear coat layer roughness.
  103001. */
  103002. roughness: number;
  103003. private _indiceOfRefraction;
  103004. /**
  103005. * Defines the indice of refraction of the clear coat.
  103006. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  103007. * The default fits with a polyurethane material.
  103008. * Changing the default value is more performance intensive.
  103009. */
  103010. indiceOfRefraction: number;
  103011. private _texture;
  103012. /**
  103013. * Stores the clear coat values in a texture.
  103014. */
  103015. texture: Nullable<BaseTexture>;
  103016. private _bumpTexture;
  103017. /**
  103018. * Define the clear coat specific bump texture.
  103019. */
  103020. bumpTexture: Nullable<BaseTexture>;
  103021. private _isTintEnabled;
  103022. /**
  103023. * Defines if the clear coat tint is enabled in the material.
  103024. */
  103025. isTintEnabled: boolean;
  103026. /**
  103027. * Defines the clear coat tint of the material.
  103028. * This is only use if tint is enabled
  103029. */
  103030. tintColor: Color3;
  103031. /**
  103032. * Defines the distance at which the tint color should be found in the
  103033. * clear coat media.
  103034. * This is only use if tint is enabled
  103035. */
  103036. tintColorAtDistance: number;
  103037. /**
  103038. * Defines the clear coat layer thickness.
  103039. * This is only use if tint is enabled
  103040. */
  103041. tintThickness: number;
  103042. private _tintTexture;
  103043. /**
  103044. * Stores the clear tint values in a texture.
  103045. * rgb is tint
  103046. * a is a thickness factor
  103047. */
  103048. tintTexture: Nullable<BaseTexture>;
  103049. /** @hidden */
  103050. private _internalMarkAllSubMeshesAsTexturesDirty;
  103051. /** @hidden */
  103052. _markAllSubMeshesAsTexturesDirty(): void;
  103053. /**
  103054. * Instantiate a new istance of clear coat configuration.
  103055. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  103056. */
  103057. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  103058. /**
  103059. * Gets wehter the submesh is ready to be used or not.
  103060. * @param defines the list of "defines" to update.
  103061. * @param scene defines the scene the material belongs to.
  103062. * @param engine defines the engine the material belongs to.
  103063. * @param disableBumpMap defines wether the material disables bump or not.
  103064. * @returns - boolean indicating that the submesh is ready or not.
  103065. */
  103066. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  103067. /**
  103068. * Checks to see if a texture is used in the material.
  103069. * @param defines the list of "defines" to update.
  103070. * @param scene defines the scene to the material belongs to.
  103071. */
  103072. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  103073. /**
  103074. * Binds the material data.
  103075. * @param uniformBuffer defines the Uniform buffer to fill in.
  103076. * @param scene defines the scene the material belongs to.
  103077. * @param engine defines the engine the material belongs to.
  103078. * @param disableBumpMap defines wether the material disables bump or not.
  103079. * @param isFrozen defines wether the material is frozen or not.
  103080. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  103081. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  103082. */
  103083. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  103084. /**
  103085. * Checks to see if a texture is used in the material.
  103086. * @param texture - Base texture to use.
  103087. * @returns - Boolean specifying if a texture is used in the material.
  103088. */
  103089. hasTexture(texture: BaseTexture): boolean;
  103090. /**
  103091. * Returns an array of the actively used textures.
  103092. * @param activeTextures Array of BaseTextures
  103093. */
  103094. getActiveTextures(activeTextures: BaseTexture[]): void;
  103095. /**
  103096. * Returns the animatable textures.
  103097. * @param animatables Array of animatable textures.
  103098. */
  103099. getAnimatables(animatables: IAnimatable[]): void;
  103100. /**
  103101. * Disposes the resources of the material.
  103102. * @param forceDisposeTextures - Forces the disposal of all textures.
  103103. */
  103104. dispose(forceDisposeTextures?: boolean): void;
  103105. /**
  103106. * Get the current class name of the texture useful for serialization or dynamic coding.
  103107. * @returns "PBRClearCoatConfiguration"
  103108. */
  103109. getClassName(): string;
  103110. /**
  103111. * Add fallbacks to the effect fallbacks list.
  103112. * @param defines defines the Base texture to use.
  103113. * @param fallbacks defines the current fallback list.
  103114. * @param currentRank defines the current fallback rank.
  103115. * @returns the new fallback rank.
  103116. */
  103117. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  103118. /**
  103119. * Add the required uniforms to the current list.
  103120. * @param uniforms defines the current uniform list.
  103121. */
  103122. static AddUniforms(uniforms: string[]): void;
  103123. /**
  103124. * Add the required samplers to the current list.
  103125. * @param samplers defines the current sampler list.
  103126. */
  103127. static AddSamplers(samplers: string[]): void;
  103128. /**
  103129. * Add the required uniforms to the current buffer.
  103130. * @param uniformBuffer defines the current uniform buffer.
  103131. */
  103132. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  103133. /**
  103134. * Makes a duplicate of the current configuration into another one.
  103135. * @param clearCoatConfiguration define the config where to copy the info
  103136. */
  103137. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  103138. /**
  103139. * Serializes this clear coat configuration.
  103140. * @returns - An object with the serialized config.
  103141. */
  103142. serialize(): any;
  103143. /**
  103144. * Parses a Clear Coat Configuration from a serialized object.
  103145. * @param source - Serialized object.
  103146. */
  103147. parse(source: any): void;
  103148. }
  103149. }
  103150. declare module BABYLON {
  103151. /**
  103152. * @hidden
  103153. */
  103154. export interface IMaterialAnisotropicDefines {
  103155. ANISOTROPIC: boolean;
  103156. ANISOTROPIC_TEXTURE: boolean;
  103157. ANISOTROPIC_TEXTUREDIRECTUV: number;
  103158. MAINUV1: boolean;
  103159. _areTexturesDirty: boolean;
  103160. _needUVs: boolean;
  103161. }
  103162. /**
  103163. * Define the code related to the anisotropic parameters of the pbr material.
  103164. */
  103165. export class PBRAnisotropicConfiguration {
  103166. private _isEnabled;
  103167. /**
  103168. * Defines if the anisotropy is enabled in the material.
  103169. */
  103170. isEnabled: boolean;
  103171. /**
  103172. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  103173. */
  103174. intensity: number;
  103175. /**
  103176. * Defines if the effect is along the tangents, bitangents or in between.
  103177. * By default, the effect is "strectching" the highlights along the tangents.
  103178. */
  103179. direction: Vector2;
  103180. private _texture;
  103181. /**
  103182. * Stores the anisotropy values in a texture.
  103183. * rg is direction (like normal from -1 to 1)
  103184. * b is a intensity
  103185. */
  103186. texture: Nullable<BaseTexture>;
  103187. /** @hidden */
  103188. private _internalMarkAllSubMeshesAsTexturesDirty;
  103189. /** @hidden */
  103190. _markAllSubMeshesAsTexturesDirty(): void;
  103191. /**
  103192. * Instantiate a new istance of anisotropy configuration.
  103193. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  103194. */
  103195. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  103196. /**
  103197. * Specifies that the submesh is ready to be used.
  103198. * @param defines the list of "defines" to update.
  103199. * @param scene defines the scene the material belongs to.
  103200. * @returns - boolean indicating that the submesh is ready or not.
  103201. */
  103202. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  103203. /**
  103204. * Checks to see if a texture is used in the material.
  103205. * @param defines the list of "defines" to update.
  103206. * @param mesh the mesh we are preparing the defines for.
  103207. * @param scene defines the scene the material belongs to.
  103208. */
  103209. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  103210. /**
  103211. * Binds the material data.
  103212. * @param uniformBuffer defines the Uniform buffer to fill in.
  103213. * @param scene defines the scene the material belongs to.
  103214. * @param isFrozen defines wether the material is frozen or not.
  103215. */
  103216. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  103217. /**
  103218. * Checks to see if a texture is used in the material.
  103219. * @param texture - Base texture to use.
  103220. * @returns - Boolean specifying if a texture is used in the material.
  103221. */
  103222. hasTexture(texture: BaseTexture): boolean;
  103223. /**
  103224. * Returns an array of the actively used textures.
  103225. * @param activeTextures Array of BaseTextures
  103226. */
  103227. getActiveTextures(activeTextures: BaseTexture[]): void;
  103228. /**
  103229. * Returns the animatable textures.
  103230. * @param animatables Array of animatable textures.
  103231. */
  103232. getAnimatables(animatables: IAnimatable[]): void;
  103233. /**
  103234. * Disposes the resources of the material.
  103235. * @param forceDisposeTextures - Forces the disposal of all textures.
  103236. */
  103237. dispose(forceDisposeTextures?: boolean): void;
  103238. /**
  103239. * Get the current class name of the texture useful for serialization or dynamic coding.
  103240. * @returns "PBRAnisotropicConfiguration"
  103241. */
  103242. getClassName(): string;
  103243. /**
  103244. * Add fallbacks to the effect fallbacks list.
  103245. * @param defines defines the Base texture to use.
  103246. * @param fallbacks defines the current fallback list.
  103247. * @param currentRank defines the current fallback rank.
  103248. * @returns the new fallback rank.
  103249. */
  103250. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  103251. /**
  103252. * Add the required uniforms to the current list.
  103253. * @param uniforms defines the current uniform list.
  103254. */
  103255. static AddUniforms(uniforms: string[]): void;
  103256. /**
  103257. * Add the required uniforms to the current buffer.
  103258. * @param uniformBuffer defines the current uniform buffer.
  103259. */
  103260. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  103261. /**
  103262. * Add the required samplers to the current list.
  103263. * @param samplers defines the current sampler list.
  103264. */
  103265. static AddSamplers(samplers: string[]): void;
  103266. /**
  103267. * Makes a duplicate of the current configuration into another one.
  103268. * @param anisotropicConfiguration define the config where to copy the info
  103269. */
  103270. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  103271. /**
  103272. * Serializes this anisotropy configuration.
  103273. * @returns - An object with the serialized config.
  103274. */
  103275. serialize(): any;
  103276. /**
  103277. * Parses a anisotropy Configuration from a serialized object.
  103278. * @param source - Serialized object.
  103279. */
  103280. parse(source: any): void;
  103281. }
  103282. }
  103283. declare module BABYLON {
  103284. /**
  103285. * @hidden
  103286. */
  103287. export interface IMaterialBRDFDefines {
  103288. BRDF_V_HEIGHT_CORRELATED: boolean;
  103289. MS_BRDF_ENERGY_CONSERVATION: boolean;
  103290. /** @hidden */
  103291. _areMiscDirty: boolean;
  103292. }
  103293. /**
  103294. * Define the code related to the BRDF parameters of the pbr material.
  103295. */
  103296. export class PBRBRDFConfiguration {
  103297. /**
  103298. * Default value used for the energy conservation.
  103299. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  103300. */
  103301. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  103302. /**
  103303. * Default value used for the Smith Visibility Height Correlated mode.
  103304. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  103305. */
  103306. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  103307. private _useEnergyConservation;
  103308. /**
  103309. * Defines if the material uses energy conservation.
  103310. */
  103311. useEnergyConservation: boolean;
  103312. private _useSmithVisibilityHeightCorrelated;
  103313. /**
  103314. * LEGACY Mode set to false
  103315. * Defines if the material uses height smith correlated visibility term.
  103316. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  103317. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  103318. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  103319. * Not relying on height correlated will also disable energy conservation.
  103320. */
  103321. useSmithVisibilityHeightCorrelated: boolean;
  103322. /** @hidden */
  103323. private _internalMarkAllSubMeshesAsMiscDirty;
  103324. /** @hidden */
  103325. _markAllSubMeshesAsMiscDirty(): void;
  103326. /**
  103327. * Instantiate a new istance of clear coat configuration.
  103328. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  103329. */
  103330. constructor(markAllSubMeshesAsMiscDirty: () => void);
  103331. /**
  103332. * Checks to see if a texture is used in the material.
  103333. * @param defines the list of "defines" to update.
  103334. */
  103335. prepareDefines(defines: IMaterialBRDFDefines): void;
  103336. /**
  103337. * Get the current class name of the texture useful for serialization or dynamic coding.
  103338. * @returns "PBRClearCoatConfiguration"
  103339. */
  103340. getClassName(): string;
  103341. /**
  103342. * Makes a duplicate of the current configuration into another one.
  103343. * @param brdfConfiguration define the config where to copy the info
  103344. */
  103345. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  103346. /**
  103347. * Serializes this BRDF configuration.
  103348. * @returns - An object with the serialized config.
  103349. */
  103350. serialize(): any;
  103351. /**
  103352. * Parses a BRDF Configuration from a serialized object.
  103353. * @param source - Serialized object.
  103354. */
  103355. parse(source: any): void;
  103356. }
  103357. }
  103358. declare module BABYLON {
  103359. /**
  103360. * @hidden
  103361. */
  103362. export interface IMaterialSheenDefines {
  103363. SHEEN: boolean;
  103364. SHEEN_TEXTURE: boolean;
  103365. SHEEN_TEXTUREDIRECTUV: number;
  103366. SHEEN_LINKWITHALBEDO: boolean;
  103367. /** @hidden */
  103368. _areTexturesDirty: boolean;
  103369. }
  103370. /**
  103371. * Define the code related to the Sheen parameters of the pbr material.
  103372. */
  103373. export class PBRSheenConfiguration {
  103374. private _isEnabled;
  103375. /**
  103376. * Defines if the material uses sheen.
  103377. */
  103378. isEnabled: boolean;
  103379. private _linkSheenWithAlbedo;
  103380. /**
  103381. * Defines if the sheen is linked to the sheen color.
  103382. */
  103383. linkSheenWithAlbedo: boolean;
  103384. /**
  103385. * Defines the sheen intensity.
  103386. */
  103387. intensity: number;
  103388. /**
  103389. * Defines the sheen color.
  103390. */
  103391. color: Color3;
  103392. private _texture;
  103393. /**
  103394. * Stores the sheen tint values in a texture.
  103395. * rgb is tint
  103396. * a is a intensity
  103397. */
  103398. texture: Nullable<BaseTexture>;
  103399. /** @hidden */
  103400. private _internalMarkAllSubMeshesAsTexturesDirty;
  103401. /** @hidden */
  103402. _markAllSubMeshesAsTexturesDirty(): void;
  103403. /**
  103404. * Instantiate a new istance of clear coat configuration.
  103405. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  103406. */
  103407. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  103408. /**
  103409. * Specifies that the submesh is ready to be used.
  103410. * @param defines the list of "defines" to update.
  103411. * @param scene defines the scene the material belongs to.
  103412. * @returns - boolean indicating that the submesh is ready or not.
  103413. */
  103414. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  103415. /**
  103416. * Checks to see if a texture is used in the material.
  103417. * @param defines the list of "defines" to update.
  103418. * @param scene defines the scene the material belongs to.
  103419. */
  103420. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  103421. /**
  103422. * Binds the material data.
  103423. * @param uniformBuffer defines the Uniform buffer to fill in.
  103424. * @param scene defines the scene the material belongs to.
  103425. * @param isFrozen defines wether the material is frozen or not.
  103426. */
  103427. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  103428. /**
  103429. * Checks to see if a texture is used in the material.
  103430. * @param texture - Base texture to use.
  103431. * @returns - Boolean specifying if a texture is used in the material.
  103432. */
  103433. hasTexture(texture: BaseTexture): boolean;
  103434. /**
  103435. * Returns an array of the actively used textures.
  103436. * @param activeTextures Array of BaseTextures
  103437. */
  103438. getActiveTextures(activeTextures: BaseTexture[]): void;
  103439. /**
  103440. * Returns the animatable textures.
  103441. * @param animatables Array of animatable textures.
  103442. */
  103443. getAnimatables(animatables: IAnimatable[]): void;
  103444. /**
  103445. * Disposes the resources of the material.
  103446. * @param forceDisposeTextures - Forces the disposal of all textures.
  103447. */
  103448. dispose(forceDisposeTextures?: boolean): void;
  103449. /**
  103450. * Get the current class name of the texture useful for serialization or dynamic coding.
  103451. * @returns "PBRSheenConfiguration"
  103452. */
  103453. getClassName(): string;
  103454. /**
  103455. * Add fallbacks to the effect fallbacks list.
  103456. * @param defines defines the Base texture to use.
  103457. * @param fallbacks defines the current fallback list.
  103458. * @param currentRank defines the current fallback rank.
  103459. * @returns the new fallback rank.
  103460. */
  103461. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  103462. /**
  103463. * Add the required uniforms to the current list.
  103464. * @param uniforms defines the current uniform list.
  103465. */
  103466. static AddUniforms(uniforms: string[]): void;
  103467. /**
  103468. * Add the required uniforms to the current buffer.
  103469. * @param uniformBuffer defines the current uniform buffer.
  103470. */
  103471. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  103472. /**
  103473. * Add the required samplers to the current list.
  103474. * @param samplers defines the current sampler list.
  103475. */
  103476. static AddSamplers(samplers: string[]): void;
  103477. /**
  103478. * Makes a duplicate of the current configuration into another one.
  103479. * @param sheenConfiguration define the config where to copy the info
  103480. */
  103481. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  103482. /**
  103483. * Serializes this BRDF configuration.
  103484. * @returns - An object with the serialized config.
  103485. */
  103486. serialize(): any;
  103487. /**
  103488. * Parses a Sheen Configuration from a serialized object.
  103489. * @param source - Serialized object.
  103490. */
  103491. parse(source: any): void;
  103492. }
  103493. }
  103494. declare module BABYLON {
  103495. /**
  103496. * @hidden
  103497. */
  103498. export interface IMaterialSubSurfaceDefines {
  103499. SUBSURFACE: boolean;
  103500. SS_REFRACTION: boolean;
  103501. SS_TRANSLUCENCY: boolean;
  103502. SS_SCATERRING: boolean;
  103503. SS_THICKNESSANDMASK_TEXTURE: boolean;
  103504. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  103505. SS_REFRACTIONMAP_3D: boolean;
  103506. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  103507. SS_LODINREFRACTIONALPHA: boolean;
  103508. SS_GAMMAREFRACTION: boolean;
  103509. SS_RGBDREFRACTION: boolean;
  103510. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  103511. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  103512. /** @hidden */
  103513. _areTexturesDirty: boolean;
  103514. }
  103515. /**
  103516. * Define the code related to the sub surface parameters of the pbr material.
  103517. */
  103518. export class PBRSubSurfaceConfiguration {
  103519. private _isRefractionEnabled;
  103520. /**
  103521. * Defines if the refraction is enabled in the material.
  103522. */
  103523. isRefractionEnabled: boolean;
  103524. private _isTranslucencyEnabled;
  103525. /**
  103526. * Defines if the translucency is enabled in the material.
  103527. */
  103528. isTranslucencyEnabled: boolean;
  103529. private _isScatteringEnabled;
  103530. /**
  103531. * Defines the refraction intensity of the material.
  103532. * The refraction when enabled replaces the Diffuse part of the material.
  103533. * The intensity helps transitionning between diffuse and refraction.
  103534. */
  103535. refractionIntensity: number;
  103536. /**
  103537. * Defines the translucency intensity of the material.
  103538. * When translucency has been enabled, this defines how much of the "translucency"
  103539. * is addded to the diffuse part of the material.
  103540. */
  103541. translucencyIntensity: number;
  103542. /**
  103543. * Defines the scattering intensity of the material.
  103544. * When scattering has been enabled, this defines how much of the "scattered light"
  103545. * is addded to the diffuse part of the material.
  103546. */
  103547. scatteringIntensity: number;
  103548. private _thicknessTexture;
  103549. /**
  103550. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  103551. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  103552. * 0 would mean minimumThickness
  103553. * 1 would mean maximumThickness
  103554. * The other channels might be use as a mask to vary the different effects intensity.
  103555. */
  103556. thicknessTexture: Nullable<BaseTexture>;
  103557. private _refractionTexture;
  103558. /**
  103559. * Defines the texture to use for refraction.
  103560. */
  103561. refractionTexture: Nullable<BaseTexture>;
  103562. private _indexOfRefraction;
  103563. /**
  103564. * Defines the indice of refraction used in the material.
  103565. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  103566. */
  103567. indexOfRefraction: number;
  103568. private _invertRefractionY;
  103569. /**
  103570. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  103571. */
  103572. invertRefractionY: boolean;
  103573. private _linkRefractionWithTransparency;
  103574. /**
  103575. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  103576. * Materials half opaque for instance using refraction could benefit from this control.
  103577. */
  103578. linkRefractionWithTransparency: boolean;
  103579. /**
  103580. * Defines the minimum thickness stored in the thickness map.
  103581. * If no thickness map is defined, this value will be used to simulate thickness.
  103582. */
  103583. minimumThickness: number;
  103584. /**
  103585. * Defines the maximum thickness stored in the thickness map.
  103586. */
  103587. maximumThickness: number;
  103588. /**
  103589. * Defines the volume tint of the material.
  103590. * This is used for both translucency and scattering.
  103591. */
  103592. tintColor: Color3;
  103593. /**
  103594. * Defines the distance at which the tint color should be found in the media.
  103595. * This is used for refraction only.
  103596. */
  103597. tintColorAtDistance: number;
  103598. /**
  103599. * Defines how far each channel transmit through the media.
  103600. * It is defined as a color to simplify it selection.
  103601. */
  103602. diffusionDistance: Color3;
  103603. private _useMaskFromThicknessTexture;
  103604. /**
  103605. * Stores the intensity of the different subsurface effects in the thickness texture.
  103606. * * the green channel is the translucency intensity.
  103607. * * the blue channel is the scattering intensity.
  103608. * * the alpha channel is the refraction intensity.
  103609. */
  103610. useMaskFromThicknessTexture: boolean;
  103611. /** @hidden */
  103612. private _internalMarkAllSubMeshesAsTexturesDirty;
  103613. /** @hidden */
  103614. _markAllSubMeshesAsTexturesDirty(): void;
  103615. /**
  103616. * Instantiate a new istance of sub surface configuration.
  103617. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  103618. */
  103619. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  103620. /**
  103621. * Gets wehter the submesh is ready to be used or not.
  103622. * @param defines the list of "defines" to update.
  103623. * @param scene defines the scene the material belongs to.
  103624. * @returns - boolean indicating that the submesh is ready or not.
  103625. */
  103626. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  103627. /**
  103628. * Checks to see if a texture is used in the material.
  103629. * @param defines the list of "defines" to update.
  103630. * @param scene defines the scene to the material belongs to.
  103631. */
  103632. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  103633. /**
  103634. * Binds the material data.
  103635. * @param uniformBuffer defines the Uniform buffer to fill in.
  103636. * @param scene defines the scene the material belongs to.
  103637. * @param engine defines the engine the material belongs to.
  103638. * @param isFrozen defines wether the material is frozen or not.
  103639. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  103640. */
  103641. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  103642. /**
  103643. * Unbinds the material from the mesh.
  103644. * @param activeEffect defines the effect that should be unbound from.
  103645. * @returns true if unbound, otherwise false
  103646. */
  103647. unbind(activeEffect: Effect): boolean;
  103648. /**
  103649. * Returns the texture used for refraction or null if none is used.
  103650. * @param scene defines the scene the material belongs to.
  103651. * @returns - Refraction texture if present. If no refraction texture and refraction
  103652. * is linked with transparency, returns environment texture. Otherwise, returns null.
  103653. */
  103654. private _getRefractionTexture;
  103655. /**
  103656. * Returns true if alpha blending should be disabled.
  103657. */
  103658. readonly disableAlphaBlending: boolean;
  103659. /**
  103660. * Fills the list of render target textures.
  103661. * @param renderTargets the list of render targets to update
  103662. */
  103663. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  103664. /**
  103665. * Checks to see if a texture is used in the material.
  103666. * @param texture - Base texture to use.
  103667. * @returns - Boolean specifying if a texture is used in the material.
  103668. */
  103669. hasTexture(texture: BaseTexture): boolean;
  103670. /**
  103671. * Gets a boolean indicating that current material needs to register RTT
  103672. * @returns true if this uses a render target otherwise false.
  103673. */
  103674. hasRenderTargetTextures(): boolean;
  103675. /**
  103676. * Returns an array of the actively used textures.
  103677. * @param activeTextures Array of BaseTextures
  103678. */
  103679. getActiveTextures(activeTextures: BaseTexture[]): void;
  103680. /**
  103681. * Returns the animatable textures.
  103682. * @param animatables Array of animatable textures.
  103683. */
  103684. getAnimatables(animatables: IAnimatable[]): void;
  103685. /**
  103686. * Disposes the resources of the material.
  103687. * @param forceDisposeTextures - Forces the disposal of all textures.
  103688. */
  103689. dispose(forceDisposeTextures?: boolean): void;
  103690. /**
  103691. * Get the current class name of the texture useful for serialization or dynamic coding.
  103692. * @returns "PBRSubSurfaceConfiguration"
  103693. */
  103694. getClassName(): string;
  103695. /**
  103696. * Add fallbacks to the effect fallbacks list.
  103697. * @param defines defines the Base texture to use.
  103698. * @param fallbacks defines the current fallback list.
  103699. * @param currentRank defines the current fallback rank.
  103700. * @returns the new fallback rank.
  103701. */
  103702. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  103703. /**
  103704. * Add the required uniforms to the current list.
  103705. * @param uniforms defines the current uniform list.
  103706. */
  103707. static AddUniforms(uniforms: string[]): void;
  103708. /**
  103709. * Add the required samplers to the current list.
  103710. * @param samplers defines the current sampler list.
  103711. */
  103712. static AddSamplers(samplers: string[]): void;
  103713. /**
  103714. * Add the required uniforms to the current buffer.
  103715. * @param uniformBuffer defines the current uniform buffer.
  103716. */
  103717. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  103718. /**
  103719. * Makes a duplicate of the current configuration into another one.
  103720. * @param configuration define the config where to copy the info
  103721. */
  103722. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  103723. /**
  103724. * Serializes this Sub Surface configuration.
  103725. * @returns - An object with the serialized config.
  103726. */
  103727. serialize(): any;
  103728. /**
  103729. * Parses a Sub Surface Configuration from a serialized object.
  103730. * @param source - Serialized object.
  103731. */
  103732. parse(source: any): void;
  103733. }
  103734. }
  103735. declare module BABYLON {
  103736. /** @hidden */
  103737. export var pbrFragmentDeclaration: {
  103738. name: string;
  103739. shader: string;
  103740. };
  103741. }
  103742. declare module BABYLON {
  103743. /** @hidden */
  103744. export var pbrUboDeclaration: {
  103745. name: string;
  103746. shader: string;
  103747. };
  103748. }
  103749. declare module BABYLON {
  103750. /** @hidden */
  103751. export var pbrFragmentExtraDeclaration: {
  103752. name: string;
  103753. shader: string;
  103754. };
  103755. }
  103756. declare module BABYLON {
  103757. /** @hidden */
  103758. export var pbrFragmentSamplersDeclaration: {
  103759. name: string;
  103760. shader: string;
  103761. };
  103762. }
  103763. declare module BABYLON {
  103764. /** @hidden */
  103765. export var pbrHelperFunctions: {
  103766. name: string;
  103767. shader: string;
  103768. };
  103769. }
  103770. declare module BABYLON {
  103771. /** @hidden */
  103772. export var harmonicsFunctions: {
  103773. name: string;
  103774. shader: string;
  103775. };
  103776. }
  103777. declare module BABYLON {
  103778. /** @hidden */
  103779. export var pbrDirectLightingSetupFunctions: {
  103780. name: string;
  103781. shader: string;
  103782. };
  103783. }
  103784. declare module BABYLON {
  103785. /** @hidden */
  103786. export var pbrDirectLightingFalloffFunctions: {
  103787. name: string;
  103788. shader: string;
  103789. };
  103790. }
  103791. declare module BABYLON {
  103792. /** @hidden */
  103793. export var pbrBRDFFunctions: {
  103794. name: string;
  103795. shader: string;
  103796. };
  103797. }
  103798. declare module BABYLON {
  103799. /** @hidden */
  103800. export var pbrDirectLightingFunctions: {
  103801. name: string;
  103802. shader: string;
  103803. };
  103804. }
  103805. declare module BABYLON {
  103806. /** @hidden */
  103807. export var pbrIBLFunctions: {
  103808. name: string;
  103809. shader: string;
  103810. };
  103811. }
  103812. declare module BABYLON {
  103813. /** @hidden */
  103814. export var pbrDebug: {
  103815. name: string;
  103816. shader: string;
  103817. };
  103818. }
  103819. declare module BABYLON {
  103820. /** @hidden */
  103821. export var pbrPixelShader: {
  103822. name: string;
  103823. shader: string;
  103824. };
  103825. }
  103826. declare module BABYLON {
  103827. /** @hidden */
  103828. export var pbrVertexDeclaration: {
  103829. name: string;
  103830. shader: string;
  103831. };
  103832. }
  103833. declare module BABYLON {
  103834. /** @hidden */
  103835. export var pbrVertexShader: {
  103836. name: string;
  103837. shader: string;
  103838. };
  103839. }
  103840. declare module BABYLON {
  103841. /**
  103842. * Manages the defines for the PBR Material.
  103843. * @hidden
  103844. */
  103845. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  103846. PBR: boolean;
  103847. MAINUV1: boolean;
  103848. MAINUV2: boolean;
  103849. UV1: boolean;
  103850. UV2: boolean;
  103851. ALBEDO: boolean;
  103852. ALBEDODIRECTUV: number;
  103853. VERTEXCOLOR: boolean;
  103854. AMBIENT: boolean;
  103855. AMBIENTDIRECTUV: number;
  103856. AMBIENTINGRAYSCALE: boolean;
  103857. OPACITY: boolean;
  103858. VERTEXALPHA: boolean;
  103859. OPACITYDIRECTUV: number;
  103860. OPACITYRGB: boolean;
  103861. ALPHATEST: boolean;
  103862. DEPTHPREPASS: boolean;
  103863. ALPHABLEND: boolean;
  103864. ALPHAFROMALBEDO: boolean;
  103865. ALPHATESTVALUE: string;
  103866. SPECULAROVERALPHA: boolean;
  103867. RADIANCEOVERALPHA: boolean;
  103868. ALPHAFRESNEL: boolean;
  103869. LINEARALPHAFRESNEL: boolean;
  103870. PREMULTIPLYALPHA: boolean;
  103871. EMISSIVE: boolean;
  103872. EMISSIVEDIRECTUV: number;
  103873. REFLECTIVITY: boolean;
  103874. REFLECTIVITYDIRECTUV: number;
  103875. SPECULARTERM: boolean;
  103876. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  103877. MICROSURFACEAUTOMATIC: boolean;
  103878. LODBASEDMICROSFURACE: boolean;
  103879. MICROSURFACEMAP: boolean;
  103880. MICROSURFACEMAPDIRECTUV: number;
  103881. METALLICWORKFLOW: boolean;
  103882. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  103883. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  103884. METALLNESSSTOREINMETALMAPBLUE: boolean;
  103885. AOSTOREINMETALMAPRED: boolean;
  103886. ENVIRONMENTBRDF: boolean;
  103887. ENVIRONMENTBRDF_RGBD: boolean;
  103888. NORMAL: boolean;
  103889. TANGENT: boolean;
  103890. BUMP: boolean;
  103891. BUMPDIRECTUV: number;
  103892. OBJECTSPACE_NORMALMAP: boolean;
  103893. PARALLAX: boolean;
  103894. PARALLAXOCCLUSION: boolean;
  103895. NORMALXYSCALE: boolean;
  103896. LIGHTMAP: boolean;
  103897. LIGHTMAPDIRECTUV: number;
  103898. USELIGHTMAPASSHADOWMAP: boolean;
  103899. GAMMALIGHTMAP: boolean;
  103900. REFLECTION: boolean;
  103901. REFLECTIONMAP_3D: boolean;
  103902. REFLECTIONMAP_SPHERICAL: boolean;
  103903. REFLECTIONMAP_PLANAR: boolean;
  103904. REFLECTIONMAP_CUBIC: boolean;
  103905. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  103906. REFLECTIONMAP_PROJECTION: boolean;
  103907. REFLECTIONMAP_SKYBOX: boolean;
  103908. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  103909. REFLECTIONMAP_EXPLICIT: boolean;
  103910. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  103911. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  103912. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  103913. INVERTCUBICMAP: boolean;
  103914. USESPHERICALFROMREFLECTIONMAP: boolean;
  103915. USESPHERICALINVERTEX: boolean;
  103916. REFLECTIONMAP_OPPOSITEZ: boolean;
  103917. LODINREFLECTIONALPHA: boolean;
  103918. GAMMAREFLECTION: boolean;
  103919. RGBDREFLECTION: boolean;
  103920. RADIANCEOCCLUSION: boolean;
  103921. HORIZONOCCLUSION: boolean;
  103922. INSTANCES: boolean;
  103923. NUM_BONE_INFLUENCERS: number;
  103924. BonesPerMesh: number;
  103925. BONETEXTURE: boolean;
  103926. NONUNIFORMSCALING: boolean;
  103927. MORPHTARGETS: boolean;
  103928. MORPHTARGETS_NORMAL: boolean;
  103929. MORPHTARGETS_TANGENT: boolean;
  103930. NUM_MORPH_INFLUENCERS: number;
  103931. IMAGEPROCESSING: boolean;
  103932. VIGNETTE: boolean;
  103933. VIGNETTEBLENDMODEMULTIPLY: boolean;
  103934. VIGNETTEBLENDMODEOPAQUE: boolean;
  103935. TONEMAPPING: boolean;
  103936. TONEMAPPING_ACES: boolean;
  103937. CONTRAST: boolean;
  103938. COLORCURVES: boolean;
  103939. COLORGRADING: boolean;
  103940. COLORGRADING3D: boolean;
  103941. SAMPLER3DGREENDEPTH: boolean;
  103942. SAMPLER3DBGRMAP: boolean;
  103943. IMAGEPROCESSINGPOSTPROCESS: boolean;
  103944. EXPOSURE: boolean;
  103945. MULTIVIEW: boolean;
  103946. USEPHYSICALLIGHTFALLOFF: boolean;
  103947. USEGLTFLIGHTFALLOFF: boolean;
  103948. TWOSIDEDLIGHTING: boolean;
  103949. SHADOWFLOAT: boolean;
  103950. CLIPPLANE: boolean;
  103951. CLIPPLANE2: boolean;
  103952. CLIPPLANE3: boolean;
  103953. CLIPPLANE4: boolean;
  103954. POINTSIZE: boolean;
  103955. FOG: boolean;
  103956. LOGARITHMICDEPTH: boolean;
  103957. FORCENORMALFORWARD: boolean;
  103958. SPECULARAA: boolean;
  103959. CLEARCOAT: boolean;
  103960. CLEARCOAT_DEFAULTIOR: boolean;
  103961. CLEARCOAT_TEXTURE: boolean;
  103962. CLEARCOAT_TEXTUREDIRECTUV: number;
  103963. CLEARCOAT_BUMP: boolean;
  103964. CLEARCOAT_BUMPDIRECTUV: number;
  103965. CLEARCOAT_TINT: boolean;
  103966. CLEARCOAT_TINT_TEXTURE: boolean;
  103967. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  103968. ANISOTROPIC: boolean;
  103969. ANISOTROPIC_TEXTURE: boolean;
  103970. ANISOTROPIC_TEXTUREDIRECTUV: number;
  103971. BRDF_V_HEIGHT_CORRELATED: boolean;
  103972. MS_BRDF_ENERGY_CONSERVATION: boolean;
  103973. SHEEN: boolean;
  103974. SHEEN_TEXTURE: boolean;
  103975. SHEEN_TEXTUREDIRECTUV: number;
  103976. SHEEN_LINKWITHALBEDO: boolean;
  103977. SUBSURFACE: boolean;
  103978. SS_REFRACTION: boolean;
  103979. SS_TRANSLUCENCY: boolean;
  103980. SS_SCATERRING: boolean;
  103981. SS_THICKNESSANDMASK_TEXTURE: boolean;
  103982. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  103983. SS_REFRACTIONMAP_3D: boolean;
  103984. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  103985. SS_LODINREFRACTIONALPHA: boolean;
  103986. SS_GAMMAREFRACTION: boolean;
  103987. SS_RGBDREFRACTION: boolean;
  103988. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  103989. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  103990. UNLIT: boolean;
  103991. DEBUGMODE: number;
  103992. /**
  103993. * Initializes the PBR Material defines.
  103994. */
  103995. constructor();
  103996. /**
  103997. * Resets the PBR Material defines.
  103998. */
  103999. reset(): void;
  104000. }
  104001. /**
  104002. * The Physically based material base class of BJS.
  104003. *
  104004. * This offers the main features of a standard PBR material.
  104005. * For more information, please refer to the documentation :
  104006. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  104007. */
  104008. export abstract class PBRBaseMaterial extends PushMaterial {
  104009. /**
  104010. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  104011. */
  104012. static readonly PBRMATERIAL_OPAQUE: number;
  104013. /**
  104014. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  104015. */
  104016. static readonly PBRMATERIAL_ALPHATEST: number;
  104017. /**
  104018. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  104019. */
  104020. static readonly PBRMATERIAL_ALPHABLEND: number;
  104021. /**
  104022. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  104023. * They are also discarded below the alpha cutoff threshold to improve performances.
  104024. */
  104025. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  104026. /**
  104027. * Defines the default value of how much AO map is occluding the analytical lights
  104028. * (point spot...).
  104029. */
  104030. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  104031. /**
  104032. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  104033. */
  104034. static readonly LIGHTFALLOFF_PHYSICAL: number;
  104035. /**
  104036. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  104037. * to enhance interoperability with other engines.
  104038. */
  104039. static readonly LIGHTFALLOFF_GLTF: number;
  104040. /**
  104041. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  104042. * to enhance interoperability with other materials.
  104043. */
  104044. static readonly LIGHTFALLOFF_STANDARD: number;
  104045. /**
  104046. * Intensity of the direct lights e.g. the four lights available in your scene.
  104047. * This impacts both the direct diffuse and specular highlights.
  104048. */
  104049. protected _directIntensity: number;
  104050. /**
  104051. * Intensity of the emissive part of the material.
  104052. * This helps controlling the emissive effect without modifying the emissive color.
  104053. */
  104054. protected _emissiveIntensity: number;
  104055. /**
  104056. * Intensity of the environment e.g. how much the environment will light the object
  104057. * either through harmonics for rough material or through the refelction for shiny ones.
  104058. */
  104059. protected _environmentIntensity: number;
  104060. /**
  104061. * This is a special control allowing the reduction of the specular highlights coming from the
  104062. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  104063. */
  104064. protected _specularIntensity: number;
  104065. /**
  104066. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  104067. */
  104068. private _lightingInfos;
  104069. /**
  104070. * Debug Control allowing disabling the bump map on this material.
  104071. */
  104072. protected _disableBumpMap: boolean;
  104073. /**
  104074. * AKA Diffuse Texture in standard nomenclature.
  104075. */
  104076. protected _albedoTexture: BaseTexture;
  104077. /**
  104078. * AKA Occlusion Texture in other nomenclature.
  104079. */
  104080. protected _ambientTexture: BaseTexture;
  104081. /**
  104082. * AKA Occlusion Texture Intensity in other nomenclature.
  104083. */
  104084. protected _ambientTextureStrength: number;
  104085. /**
  104086. * Defines how much the AO map is occluding the analytical lights (point spot...).
  104087. * 1 means it completely occludes it
  104088. * 0 mean it has no impact
  104089. */
  104090. protected _ambientTextureImpactOnAnalyticalLights: number;
  104091. /**
  104092. * Stores the alpha values in a texture.
  104093. */
  104094. protected _opacityTexture: BaseTexture;
  104095. /**
  104096. * Stores the reflection values in a texture.
  104097. */
  104098. protected _reflectionTexture: BaseTexture;
  104099. /**
  104100. * Stores the emissive values in a texture.
  104101. */
  104102. protected _emissiveTexture: BaseTexture;
  104103. /**
  104104. * AKA Specular texture in other nomenclature.
  104105. */
  104106. protected _reflectivityTexture: BaseTexture;
  104107. /**
  104108. * Used to switch from specular/glossiness to metallic/roughness workflow.
  104109. */
  104110. protected _metallicTexture: BaseTexture;
  104111. /**
  104112. * Specifies the metallic scalar of the metallic/roughness workflow.
  104113. * Can also be used to scale the metalness values of the metallic texture.
  104114. */
  104115. protected _metallic: Nullable<number>;
  104116. /**
  104117. * Specifies the roughness scalar of the metallic/roughness workflow.
  104118. * Can also be used to scale the roughness values of the metallic texture.
  104119. */
  104120. protected _roughness: Nullable<number>;
  104121. /**
  104122. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  104123. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  104124. */
  104125. protected _microSurfaceTexture: BaseTexture;
  104126. /**
  104127. * Stores surface normal data used to displace a mesh in a texture.
  104128. */
  104129. protected _bumpTexture: BaseTexture;
  104130. /**
  104131. * Stores the pre-calculated light information of a mesh in a texture.
  104132. */
  104133. protected _lightmapTexture: BaseTexture;
  104134. /**
  104135. * The color of a material in ambient lighting.
  104136. */
  104137. protected _ambientColor: Color3;
  104138. /**
  104139. * AKA Diffuse Color in other nomenclature.
  104140. */
  104141. protected _albedoColor: Color3;
  104142. /**
  104143. * AKA Specular Color in other nomenclature.
  104144. */
  104145. protected _reflectivityColor: Color3;
  104146. /**
  104147. * The color applied when light is reflected from a material.
  104148. */
  104149. protected _reflectionColor: Color3;
  104150. /**
  104151. * The color applied when light is emitted from a material.
  104152. */
  104153. protected _emissiveColor: Color3;
  104154. /**
  104155. * AKA Glossiness in other nomenclature.
  104156. */
  104157. protected _microSurface: number;
  104158. /**
  104159. * Specifies that the material will use the light map as a show map.
  104160. */
  104161. protected _useLightmapAsShadowmap: boolean;
  104162. /**
  104163. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  104164. * makes the reflect vector face the model (under horizon).
  104165. */
  104166. protected _useHorizonOcclusion: boolean;
  104167. /**
  104168. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  104169. * too much the area relying on ambient texture to define their ambient occlusion.
  104170. */
  104171. protected _useRadianceOcclusion: boolean;
  104172. /**
  104173. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  104174. */
  104175. protected _useAlphaFromAlbedoTexture: boolean;
  104176. /**
  104177. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  104178. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  104179. */
  104180. protected _useSpecularOverAlpha: boolean;
  104181. /**
  104182. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  104183. */
  104184. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  104185. /**
  104186. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  104187. */
  104188. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  104189. /**
  104190. * Specifies if the metallic texture contains the roughness information in its green channel.
  104191. */
  104192. protected _useRoughnessFromMetallicTextureGreen: boolean;
  104193. /**
  104194. * Specifies if the metallic texture contains the metallness information in its blue channel.
  104195. */
  104196. protected _useMetallnessFromMetallicTextureBlue: boolean;
  104197. /**
  104198. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  104199. */
  104200. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  104201. /**
  104202. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  104203. */
  104204. protected _useAmbientInGrayScale: boolean;
  104205. /**
  104206. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  104207. * The material will try to infer what glossiness each pixel should be.
  104208. */
  104209. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  104210. /**
  104211. * Defines the falloff type used in this material.
  104212. * It by default is Physical.
  104213. */
  104214. protected _lightFalloff: number;
  104215. /**
  104216. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  104217. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  104218. */
  104219. protected _useRadianceOverAlpha: boolean;
  104220. /**
  104221. * Allows using an object space normal map (instead of tangent space).
  104222. */
  104223. protected _useObjectSpaceNormalMap: boolean;
  104224. /**
  104225. * Allows using the bump map in parallax mode.
  104226. */
  104227. protected _useParallax: boolean;
  104228. /**
  104229. * Allows using the bump map in parallax occlusion mode.
  104230. */
  104231. protected _useParallaxOcclusion: boolean;
  104232. /**
  104233. * Controls the scale bias of the parallax mode.
  104234. */
  104235. protected _parallaxScaleBias: number;
  104236. /**
  104237. * If sets to true, disables all the lights affecting the material.
  104238. */
  104239. protected _disableLighting: boolean;
  104240. /**
  104241. * Number of Simultaneous lights allowed on the material.
  104242. */
  104243. protected _maxSimultaneousLights: number;
  104244. /**
  104245. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  104246. */
  104247. protected _invertNormalMapX: boolean;
  104248. /**
  104249. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  104250. */
  104251. protected _invertNormalMapY: boolean;
  104252. /**
  104253. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  104254. */
  104255. protected _twoSidedLighting: boolean;
  104256. /**
  104257. * Defines the alpha limits in alpha test mode.
  104258. */
  104259. protected _alphaCutOff: number;
  104260. /**
  104261. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  104262. */
  104263. protected _forceAlphaTest: boolean;
  104264. /**
  104265. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  104266. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  104267. */
  104268. protected _useAlphaFresnel: boolean;
  104269. /**
  104270. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  104271. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  104272. */
  104273. protected _useLinearAlphaFresnel: boolean;
  104274. /**
  104275. * The transparency mode of the material.
  104276. */
  104277. protected _transparencyMode: Nullable<number>;
  104278. /**
  104279. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  104280. * from cos thetav and roughness:
  104281. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  104282. */
  104283. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  104284. /**
  104285. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  104286. */
  104287. protected _forceIrradianceInFragment: boolean;
  104288. /**
  104289. * Force normal to face away from face.
  104290. */
  104291. protected _forceNormalForward: boolean;
  104292. /**
  104293. * Enables specular anti aliasing in the PBR shader.
  104294. * It will both interacts on the Geometry for analytical and IBL lighting.
  104295. * It also prefilter the roughness map based on the bump values.
  104296. */
  104297. protected _enableSpecularAntiAliasing: boolean;
  104298. /**
  104299. * Default configuration related to image processing available in the PBR Material.
  104300. */
  104301. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  104302. /**
  104303. * Keep track of the image processing observer to allow dispose and replace.
  104304. */
  104305. private _imageProcessingObserver;
  104306. /**
  104307. * Attaches a new image processing configuration to the PBR Material.
  104308. * @param configuration
  104309. */
  104310. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  104311. /**
  104312. * Stores the available render targets.
  104313. */
  104314. private _renderTargets;
  104315. /**
  104316. * Sets the global ambient color for the material used in lighting calculations.
  104317. */
  104318. private _globalAmbientColor;
  104319. /**
  104320. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  104321. */
  104322. private _useLogarithmicDepth;
  104323. /**
  104324. * If set to true, no lighting calculations will be applied.
  104325. */
  104326. private _unlit;
  104327. private _debugMode;
  104328. /**
  104329. * @hidden
  104330. * This is reserved for the inspector.
  104331. * Defines the material debug mode.
  104332. * It helps seeing only some components of the material while troubleshooting.
  104333. */
  104334. debugMode: number;
  104335. /**
  104336. * @hidden
  104337. * This is reserved for the inspector.
  104338. * Specify from where on screen the debug mode should start.
  104339. * The value goes from -1 (full screen) to 1 (not visible)
  104340. * It helps with side by side comparison against the final render
  104341. * This defaults to -1
  104342. */
  104343. private debugLimit;
  104344. /**
  104345. * @hidden
  104346. * This is reserved for the inspector.
  104347. * As the default viewing range might not be enough (if the ambient is really small for instance)
  104348. * You can use the factor to better multiply the final value.
  104349. */
  104350. private debugFactor;
  104351. /**
  104352. * Defines the clear coat layer parameters for the material.
  104353. */
  104354. readonly clearCoat: PBRClearCoatConfiguration;
  104355. /**
  104356. * Defines the anisotropic parameters for the material.
  104357. */
  104358. readonly anisotropy: PBRAnisotropicConfiguration;
  104359. /**
  104360. * Defines the BRDF parameters for the material.
  104361. */
  104362. readonly brdf: PBRBRDFConfiguration;
  104363. /**
  104364. * Defines the Sheen parameters for the material.
  104365. */
  104366. readonly sheen: PBRSheenConfiguration;
  104367. /**
  104368. * Defines the SubSurface parameters for the material.
  104369. */
  104370. readonly subSurface: PBRSubSurfaceConfiguration;
  104371. /**
  104372. * Custom callback helping to override the default shader used in the material.
  104373. */
  104374. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  104375. /**
  104376. * Instantiates a new PBRMaterial instance.
  104377. *
  104378. * @param name The material name
  104379. * @param scene The scene the material will be use in.
  104380. */
  104381. constructor(name: string, scene: Scene);
  104382. /**
  104383. * Gets a boolean indicating that current material needs to register RTT
  104384. */
  104385. readonly hasRenderTargetTextures: boolean;
  104386. /**
  104387. * Gets the name of the material class.
  104388. */
  104389. getClassName(): string;
  104390. /**
  104391. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  104392. */
  104393. /**
  104394. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  104395. */
  104396. useLogarithmicDepth: boolean;
  104397. /**
  104398. * Gets the current transparency mode.
  104399. */
  104400. /**
  104401. * Sets the transparency mode of the material.
  104402. *
  104403. * | Value | Type | Description |
  104404. * | ----- | ----------------------------------- | ----------- |
  104405. * | 0 | OPAQUE | |
  104406. * | 1 | ALPHATEST | |
  104407. * | 2 | ALPHABLEND | |
  104408. * | 3 | ALPHATESTANDBLEND | |
  104409. *
  104410. */
  104411. transparencyMode: Nullable<number>;
  104412. /**
  104413. * Returns true if alpha blending should be disabled.
  104414. */
  104415. private readonly _disableAlphaBlending;
  104416. /**
  104417. * Specifies whether or not this material should be rendered in alpha blend mode.
  104418. */
  104419. needAlphaBlending(): boolean;
  104420. /**
  104421. * Specifies if the mesh will require alpha blending.
  104422. * @param mesh - BJS mesh.
  104423. */
  104424. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  104425. /**
  104426. * Specifies whether or not this material should be rendered in alpha test mode.
  104427. */
  104428. needAlphaTesting(): boolean;
  104429. /**
  104430. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  104431. */
  104432. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  104433. /**
  104434. * Gets the texture used for the alpha test.
  104435. */
  104436. getAlphaTestTexture(): BaseTexture;
  104437. /**
  104438. * Specifies that the submesh is ready to be used.
  104439. * @param mesh - BJS mesh.
  104440. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  104441. * @param useInstances - Specifies that instances should be used.
  104442. * @returns - boolean indicating that the submesh is ready or not.
  104443. */
  104444. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  104445. /**
  104446. * Specifies if the material uses metallic roughness workflow.
  104447. * @returns boolean specifiying if the material uses metallic roughness workflow.
  104448. */
  104449. isMetallicWorkflow(): boolean;
  104450. private _prepareEffect;
  104451. private _prepareDefines;
  104452. /**
  104453. * Force shader compilation
  104454. */
  104455. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  104456. clipPlane: boolean;
  104457. }>): void;
  104458. /**
  104459. * Initializes the uniform buffer layout for the shader.
  104460. */
  104461. buildUniformLayout(): void;
  104462. /**
  104463. * Unbinds the material from the mesh
  104464. */
  104465. unbind(): void;
  104466. /**
  104467. * Binds the submesh data.
  104468. * @param world - The world matrix.
  104469. * @param mesh - The BJS mesh.
  104470. * @param subMesh - A submesh of the BJS mesh.
  104471. */
  104472. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  104473. /**
  104474. * Returns the animatable textures.
  104475. * @returns - Array of animatable textures.
  104476. */
  104477. getAnimatables(): IAnimatable[];
  104478. /**
  104479. * Returns the texture used for reflections.
  104480. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  104481. */
  104482. private _getReflectionTexture;
  104483. /**
  104484. * Returns an array of the actively used textures.
  104485. * @returns - Array of BaseTextures
  104486. */
  104487. getActiveTextures(): BaseTexture[];
  104488. /**
  104489. * Checks to see if a texture is used in the material.
  104490. * @param texture - Base texture to use.
  104491. * @returns - Boolean specifying if a texture is used in the material.
  104492. */
  104493. hasTexture(texture: BaseTexture): boolean;
  104494. /**
  104495. * Disposes the resources of the material.
  104496. * @param forceDisposeEffect - Forces the disposal of effects.
  104497. * @param forceDisposeTextures - Forces the disposal of all textures.
  104498. */
  104499. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  104500. }
  104501. }
  104502. declare module BABYLON {
  104503. /**
  104504. * The Physically based material of BJS.
  104505. *
  104506. * This offers the main features of a standard PBR material.
  104507. * For more information, please refer to the documentation :
  104508. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  104509. */
  104510. export class PBRMaterial extends PBRBaseMaterial {
  104511. /**
  104512. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  104513. */
  104514. static readonly PBRMATERIAL_OPAQUE: number;
  104515. /**
  104516. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  104517. */
  104518. static readonly PBRMATERIAL_ALPHATEST: number;
  104519. /**
  104520. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  104521. */
  104522. static readonly PBRMATERIAL_ALPHABLEND: number;
  104523. /**
  104524. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  104525. * They are also discarded below the alpha cutoff threshold to improve performances.
  104526. */
  104527. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  104528. /**
  104529. * Defines the default value of how much AO map is occluding the analytical lights
  104530. * (point spot...).
  104531. */
  104532. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  104533. /**
  104534. * Intensity of the direct lights e.g. the four lights available in your scene.
  104535. * This impacts both the direct diffuse and specular highlights.
  104536. */
  104537. directIntensity: number;
  104538. /**
  104539. * Intensity of the emissive part of the material.
  104540. * This helps controlling the emissive effect without modifying the emissive color.
  104541. */
  104542. emissiveIntensity: number;
  104543. /**
  104544. * Intensity of the environment e.g. how much the environment will light the object
  104545. * either through harmonics for rough material or through the refelction for shiny ones.
  104546. */
  104547. environmentIntensity: number;
  104548. /**
  104549. * This is a special control allowing the reduction of the specular highlights coming from the
  104550. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  104551. */
  104552. specularIntensity: number;
  104553. /**
  104554. * Debug Control allowing disabling the bump map on this material.
  104555. */
  104556. disableBumpMap: boolean;
  104557. /**
  104558. * AKA Diffuse Texture in standard nomenclature.
  104559. */
  104560. albedoTexture: BaseTexture;
  104561. /**
  104562. * AKA Occlusion Texture in other nomenclature.
  104563. */
  104564. ambientTexture: BaseTexture;
  104565. /**
  104566. * AKA Occlusion Texture Intensity in other nomenclature.
  104567. */
  104568. ambientTextureStrength: number;
  104569. /**
  104570. * Defines how much the AO map is occluding the analytical lights (point spot...).
  104571. * 1 means it completely occludes it
  104572. * 0 mean it has no impact
  104573. */
  104574. ambientTextureImpactOnAnalyticalLights: number;
  104575. /**
  104576. * Stores the alpha values in a texture.
  104577. */
  104578. opacityTexture: BaseTexture;
  104579. /**
  104580. * Stores the reflection values in a texture.
  104581. */
  104582. reflectionTexture: Nullable<BaseTexture>;
  104583. /**
  104584. * Stores the emissive values in a texture.
  104585. */
  104586. emissiveTexture: BaseTexture;
  104587. /**
  104588. * AKA Specular texture in other nomenclature.
  104589. */
  104590. reflectivityTexture: BaseTexture;
  104591. /**
  104592. * Used to switch from specular/glossiness to metallic/roughness workflow.
  104593. */
  104594. metallicTexture: BaseTexture;
  104595. /**
  104596. * Specifies the metallic scalar of the metallic/roughness workflow.
  104597. * Can also be used to scale the metalness values of the metallic texture.
  104598. */
  104599. metallic: Nullable<number>;
  104600. /**
  104601. * Specifies the roughness scalar of the metallic/roughness workflow.
  104602. * Can also be used to scale the roughness values of the metallic texture.
  104603. */
  104604. roughness: Nullable<number>;
  104605. /**
  104606. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  104607. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  104608. */
  104609. microSurfaceTexture: BaseTexture;
  104610. /**
  104611. * Stores surface normal data used to displace a mesh in a texture.
  104612. */
  104613. bumpTexture: BaseTexture;
  104614. /**
  104615. * Stores the pre-calculated light information of a mesh in a texture.
  104616. */
  104617. lightmapTexture: BaseTexture;
  104618. /**
  104619. * Stores the refracted light information in a texture.
  104620. */
  104621. refractionTexture: Nullable<BaseTexture>;
  104622. /**
  104623. * The color of a material in ambient lighting.
  104624. */
  104625. ambientColor: Color3;
  104626. /**
  104627. * AKA Diffuse Color in other nomenclature.
  104628. */
  104629. albedoColor: Color3;
  104630. /**
  104631. * AKA Specular Color in other nomenclature.
  104632. */
  104633. reflectivityColor: Color3;
  104634. /**
  104635. * The color reflected from the material.
  104636. */
  104637. reflectionColor: Color3;
  104638. /**
  104639. * The color emitted from the material.
  104640. */
  104641. emissiveColor: Color3;
  104642. /**
  104643. * AKA Glossiness in other nomenclature.
  104644. */
  104645. microSurface: number;
  104646. /**
  104647. * source material index of refraction (IOR)' / 'destination material IOR.
  104648. */
  104649. indexOfRefraction: number;
  104650. /**
  104651. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  104652. */
  104653. invertRefractionY: boolean;
  104654. /**
  104655. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  104656. * Materials half opaque for instance using refraction could benefit from this control.
  104657. */
  104658. linkRefractionWithTransparency: boolean;
  104659. /**
  104660. * If true, the light map contains occlusion information instead of lighting info.
  104661. */
  104662. useLightmapAsShadowmap: boolean;
  104663. /**
  104664. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  104665. */
  104666. useAlphaFromAlbedoTexture: boolean;
  104667. /**
  104668. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  104669. */
  104670. forceAlphaTest: boolean;
  104671. /**
  104672. * Defines the alpha limits in alpha test mode.
  104673. */
  104674. alphaCutOff: number;
  104675. /**
  104676. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  104677. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  104678. */
  104679. useSpecularOverAlpha: boolean;
  104680. /**
  104681. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  104682. */
  104683. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  104684. /**
  104685. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  104686. */
  104687. useRoughnessFromMetallicTextureAlpha: boolean;
  104688. /**
  104689. * Specifies if the metallic texture contains the roughness information in its green channel.
  104690. */
  104691. useRoughnessFromMetallicTextureGreen: boolean;
  104692. /**
  104693. * Specifies if the metallic texture contains the metallness information in its blue channel.
  104694. */
  104695. useMetallnessFromMetallicTextureBlue: boolean;
  104696. /**
  104697. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  104698. */
  104699. useAmbientOcclusionFromMetallicTextureRed: boolean;
  104700. /**
  104701. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  104702. */
  104703. useAmbientInGrayScale: boolean;
  104704. /**
  104705. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  104706. * The material will try to infer what glossiness each pixel should be.
  104707. */
  104708. useAutoMicroSurfaceFromReflectivityMap: boolean;
  104709. /**
  104710. * BJS is using an harcoded light falloff based on a manually sets up range.
  104711. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  104712. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  104713. */
  104714. /**
  104715. * BJS is using an harcoded light falloff based on a manually sets up range.
  104716. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  104717. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  104718. */
  104719. usePhysicalLightFalloff: boolean;
  104720. /**
  104721. * In order to support the falloff compatibility with gltf, a special mode has been added
  104722. * to reproduce the gltf light falloff.
  104723. */
  104724. /**
  104725. * In order to support the falloff compatibility with gltf, a special mode has been added
  104726. * to reproduce the gltf light falloff.
  104727. */
  104728. useGLTFLightFalloff: boolean;
  104729. /**
  104730. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  104731. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  104732. */
  104733. useRadianceOverAlpha: boolean;
  104734. /**
  104735. * Allows using an object space normal map (instead of tangent space).
  104736. */
  104737. useObjectSpaceNormalMap: boolean;
  104738. /**
  104739. * Allows using the bump map in parallax mode.
  104740. */
  104741. useParallax: boolean;
  104742. /**
  104743. * Allows using the bump map in parallax occlusion mode.
  104744. */
  104745. useParallaxOcclusion: boolean;
  104746. /**
  104747. * Controls the scale bias of the parallax mode.
  104748. */
  104749. parallaxScaleBias: number;
  104750. /**
  104751. * If sets to true, disables all the lights affecting the material.
  104752. */
  104753. disableLighting: boolean;
  104754. /**
  104755. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  104756. */
  104757. forceIrradianceInFragment: boolean;
  104758. /**
  104759. * Number of Simultaneous lights allowed on the material.
  104760. */
  104761. maxSimultaneousLights: number;
  104762. /**
  104763. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  104764. */
  104765. invertNormalMapX: boolean;
  104766. /**
  104767. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  104768. */
  104769. invertNormalMapY: boolean;
  104770. /**
  104771. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  104772. */
  104773. twoSidedLighting: boolean;
  104774. /**
  104775. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  104776. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  104777. */
  104778. useAlphaFresnel: boolean;
  104779. /**
  104780. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  104781. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  104782. */
  104783. useLinearAlphaFresnel: boolean;
  104784. /**
  104785. * Let user defines the brdf lookup texture used for IBL.
  104786. * A default 8bit version is embedded but you could point at :
  104787. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.png
  104788. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  104789. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  104790. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  104791. */
  104792. environmentBRDFTexture: Nullable<BaseTexture>;
  104793. /**
  104794. * Force normal to face away from face.
  104795. */
  104796. forceNormalForward: boolean;
  104797. /**
  104798. * Enables specular anti aliasing in the PBR shader.
  104799. * It will both interacts on the Geometry for analytical and IBL lighting.
  104800. * It also prefilter the roughness map based on the bump values.
  104801. */
  104802. enableSpecularAntiAliasing: boolean;
  104803. /**
  104804. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  104805. * makes the reflect vector face the model (under horizon).
  104806. */
  104807. useHorizonOcclusion: boolean;
  104808. /**
  104809. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  104810. * too much the area relying on ambient texture to define their ambient occlusion.
  104811. */
  104812. useRadianceOcclusion: boolean;
  104813. /**
  104814. * If set to true, no lighting calculations will be applied.
  104815. */
  104816. unlit: boolean;
  104817. /**
  104818. * Gets the image processing configuration used either in this material.
  104819. */
  104820. /**
  104821. * Sets the Default image processing configuration used either in the this material.
  104822. *
  104823. * If sets to null, the scene one is in use.
  104824. */
  104825. imageProcessingConfiguration: ImageProcessingConfiguration;
  104826. /**
  104827. * Gets wether the color curves effect is enabled.
  104828. */
  104829. /**
  104830. * Sets wether the color curves effect is enabled.
  104831. */
  104832. cameraColorCurvesEnabled: boolean;
  104833. /**
  104834. * Gets wether the color grading effect is enabled.
  104835. */
  104836. /**
  104837. * Gets wether the color grading effect is enabled.
  104838. */
  104839. cameraColorGradingEnabled: boolean;
  104840. /**
  104841. * Gets wether tonemapping is enabled or not.
  104842. */
  104843. /**
  104844. * Sets wether tonemapping is enabled or not
  104845. */
  104846. cameraToneMappingEnabled: boolean;
  104847. /**
  104848. * The camera exposure used on this material.
  104849. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  104850. * This corresponds to a photographic exposure.
  104851. */
  104852. /**
  104853. * The camera exposure used on this material.
  104854. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  104855. * This corresponds to a photographic exposure.
  104856. */
  104857. cameraExposure: number;
  104858. /**
  104859. * Gets The camera contrast used on this material.
  104860. */
  104861. /**
  104862. * Sets The camera contrast used on this material.
  104863. */
  104864. cameraContrast: number;
  104865. /**
  104866. * Gets the Color Grading 2D Lookup Texture.
  104867. */
  104868. /**
  104869. * Sets the Color Grading 2D Lookup Texture.
  104870. */
  104871. cameraColorGradingTexture: Nullable<BaseTexture>;
  104872. /**
  104873. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  104874. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  104875. * 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;
  104876. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  104877. */
  104878. /**
  104879. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  104880. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  104881. * 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;
  104882. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  104883. */
  104884. cameraColorCurves: Nullable<ColorCurves>;
  104885. /**
  104886. * Instantiates a new PBRMaterial instance.
  104887. *
  104888. * @param name The material name
  104889. * @param scene The scene the material will be use in.
  104890. */
  104891. constructor(name: string, scene: Scene);
  104892. /**
  104893. * Returns the name of this material class.
  104894. */
  104895. getClassName(): string;
  104896. /**
  104897. * Makes a duplicate of the current material.
  104898. * @param name - name to use for the new material.
  104899. */
  104900. clone(name: string): PBRMaterial;
  104901. /**
  104902. * Serializes this PBR Material.
  104903. * @returns - An object with the serialized material.
  104904. */
  104905. serialize(): any;
  104906. /**
  104907. * Parses a PBR Material from a serialized object.
  104908. * @param source - Serialized object.
  104909. * @param scene - BJS scene instance.
  104910. * @param rootUrl - url for the scene object
  104911. * @returns - PBRMaterial
  104912. */
  104913. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  104914. }
  104915. }
  104916. declare module BABYLON {
  104917. /**
  104918. * Direct draw surface info
  104919. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  104920. */
  104921. export interface DDSInfo {
  104922. /**
  104923. * Width of the texture
  104924. */
  104925. width: number;
  104926. /**
  104927. * Width of the texture
  104928. */
  104929. height: number;
  104930. /**
  104931. * Number of Mipmaps for the texture
  104932. * @see https://en.wikipedia.org/wiki/Mipmap
  104933. */
  104934. mipmapCount: number;
  104935. /**
  104936. * If the textures format is a known fourCC format
  104937. * @see https://www.fourcc.org/
  104938. */
  104939. isFourCC: boolean;
  104940. /**
  104941. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  104942. */
  104943. isRGB: boolean;
  104944. /**
  104945. * If the texture is a lumincance format
  104946. */
  104947. isLuminance: boolean;
  104948. /**
  104949. * If this is a cube texture
  104950. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  104951. */
  104952. isCube: boolean;
  104953. /**
  104954. * If the texture is a compressed format eg. FOURCC_DXT1
  104955. */
  104956. isCompressed: boolean;
  104957. /**
  104958. * The dxgiFormat of the texture
  104959. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  104960. */
  104961. dxgiFormat: number;
  104962. /**
  104963. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  104964. */
  104965. textureType: number;
  104966. /**
  104967. * Sphericle polynomial created for the dds texture
  104968. */
  104969. sphericalPolynomial?: SphericalPolynomial;
  104970. }
  104971. /**
  104972. * Class used to provide DDS decompression tools
  104973. */
  104974. export class DDSTools {
  104975. /**
  104976. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  104977. */
  104978. static StoreLODInAlphaChannel: boolean;
  104979. /**
  104980. * Gets DDS information from an array buffer
  104981. * @param arrayBuffer defines the array buffer to read data from
  104982. * @returns the DDS information
  104983. */
  104984. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  104985. private static _FloatView;
  104986. private static _Int32View;
  104987. private static _ToHalfFloat;
  104988. private static _FromHalfFloat;
  104989. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  104990. private static _GetHalfFloatRGBAArrayBuffer;
  104991. private static _GetFloatRGBAArrayBuffer;
  104992. private static _GetFloatAsUIntRGBAArrayBuffer;
  104993. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  104994. private static _GetRGBAArrayBuffer;
  104995. private static _ExtractLongWordOrder;
  104996. private static _GetRGBArrayBuffer;
  104997. private static _GetLuminanceArrayBuffer;
  104998. /**
  104999. * Uploads DDS Levels to a Babylon Texture
  105000. * @hidden
  105001. */
  105002. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  105003. }
  105004. interface Engine {
  105005. /**
  105006. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  105007. * @param rootUrl defines the url where the file to load is located
  105008. * @param scene defines the current scene
  105009. * @param lodScale defines scale to apply to the mip map selection
  105010. * @param lodOffset defines offset to apply to the mip map selection
  105011. * @param onLoad defines an optional callback raised when the texture is loaded
  105012. * @param onError defines an optional callback raised if there is an issue to load the texture
  105013. * @param format defines the format of the data
  105014. * @param forcedExtension defines the extension to use to pick the right loader
  105015. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  105016. * @returns the cube texture as an InternalTexture
  105017. */
  105018. 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;
  105019. }
  105020. }
  105021. declare module BABYLON {
  105022. /**
  105023. * Implementation of the DDS Texture Loader.
  105024. * @hidden
  105025. */
  105026. export class _DDSTextureLoader implements IInternalTextureLoader {
  105027. /**
  105028. * Defines wether the loader supports cascade loading the different faces.
  105029. */
  105030. readonly supportCascades: boolean;
  105031. /**
  105032. * This returns if the loader support the current file information.
  105033. * @param extension defines the file extension of the file being loaded
  105034. * @param textureFormatInUse defines the current compressed format in use iun the engine
  105035. * @param fallback defines the fallback internal texture if any
  105036. * @param isBase64 defines whether the texture is encoded as a base64
  105037. * @param isBuffer defines whether the texture data are stored as a buffer
  105038. * @returns true if the loader can load the specified file
  105039. */
  105040. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  105041. /**
  105042. * Transform the url before loading if required.
  105043. * @param rootUrl the url of the texture
  105044. * @param textureFormatInUse defines the current compressed format in use iun the engine
  105045. * @returns the transformed texture
  105046. */
  105047. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  105048. /**
  105049. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  105050. * @param rootUrl the url of the texture
  105051. * @param textureFormatInUse defines the current compressed format in use iun the engine
  105052. * @returns the fallback texture
  105053. */
  105054. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  105055. /**
  105056. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  105057. * @param data contains the texture data
  105058. * @param texture defines the BabylonJS internal texture
  105059. * @param createPolynomials will be true if polynomials have been requested
  105060. * @param onLoad defines the callback to trigger once the texture is ready
  105061. * @param onError defines the callback to trigger in case of error
  105062. */
  105063. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  105064. /**
  105065. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  105066. * @param data contains the texture data
  105067. * @param texture defines the BabylonJS internal texture
  105068. * @param callback defines the method to call once ready to upload
  105069. */
  105070. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  105071. }
  105072. }
  105073. declare module BABYLON {
  105074. /** @hidden */
  105075. export var rgbdEncodePixelShader: {
  105076. name: string;
  105077. shader: string;
  105078. };
  105079. }
  105080. declare module BABYLON {
  105081. /**
  105082. * Raw texture data and descriptor sufficient for WebGL texture upload
  105083. */
  105084. export interface EnvironmentTextureInfo {
  105085. /**
  105086. * Version of the environment map
  105087. */
  105088. version: number;
  105089. /**
  105090. * Width of image
  105091. */
  105092. width: number;
  105093. /**
  105094. * Irradiance information stored in the file.
  105095. */
  105096. irradiance: any;
  105097. /**
  105098. * Specular information stored in the file.
  105099. */
  105100. specular: any;
  105101. }
  105102. /**
  105103. * Sets of helpers addressing the serialization and deserialization of environment texture
  105104. * stored in a BabylonJS env file.
  105105. * Those files are usually stored as .env files.
  105106. */
  105107. export class EnvironmentTextureTools {
  105108. /**
  105109. * Magic number identifying the env file.
  105110. */
  105111. private static _MagicBytes;
  105112. /**
  105113. * Gets the environment info from an env file.
  105114. * @param data The array buffer containing the .env bytes.
  105115. * @returns the environment file info (the json header) if successfully parsed.
  105116. */
  105117. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  105118. /**
  105119. * Creates an environment texture from a loaded cube texture.
  105120. * @param texture defines the cube texture to convert in env file
  105121. * @return a promise containing the environment data if succesfull.
  105122. */
  105123. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  105124. /**
  105125. * Creates a JSON representation of the spherical data.
  105126. * @param texture defines the texture containing the polynomials
  105127. * @return the JSON representation of the spherical info
  105128. */
  105129. private static _CreateEnvTextureIrradiance;
  105130. /**
  105131. * Uploads the texture info contained in the env file to the GPU.
  105132. * @param texture defines the internal texture to upload to
  105133. * @param arrayBuffer defines the buffer cotaining the data to load
  105134. * @param info defines the texture info retrieved through the GetEnvInfo method
  105135. * @returns a promise
  105136. */
  105137. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  105138. /**
  105139. * Uploads the levels of image data to the GPU.
  105140. * @param texture defines the internal texture to upload to
  105141. * @param imageData defines the array buffer views of image data [mipmap][face]
  105142. * @returns a promise
  105143. */
  105144. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  105145. /**
  105146. * Uploads spherical polynomials information to the texture.
  105147. * @param texture defines the texture we are trying to upload the information to
  105148. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  105149. */
  105150. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  105151. /** @hidden */
  105152. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  105153. }
  105154. }
  105155. declare module BABYLON {
  105156. /**
  105157. * Implementation of the ENV Texture Loader.
  105158. * @hidden
  105159. */
  105160. export class _ENVTextureLoader implements IInternalTextureLoader {
  105161. /**
  105162. * Defines wether the loader supports cascade loading the different faces.
  105163. */
  105164. readonly supportCascades: boolean;
  105165. /**
  105166. * This returns if the loader support the current file information.
  105167. * @param extension defines the file extension of the file being loaded
  105168. * @param textureFormatInUse defines the current compressed format in use iun the engine
  105169. * @param fallback defines the fallback internal texture if any
  105170. * @param isBase64 defines whether the texture is encoded as a base64
  105171. * @param isBuffer defines whether the texture data are stored as a buffer
  105172. * @returns true if the loader can load the specified file
  105173. */
  105174. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  105175. /**
  105176. * Transform the url before loading if required.
  105177. * @param rootUrl the url of the texture
  105178. * @param textureFormatInUse defines the current compressed format in use iun the engine
  105179. * @returns the transformed texture
  105180. */
  105181. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  105182. /**
  105183. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  105184. * @param rootUrl the url of the texture
  105185. * @param textureFormatInUse defines the current compressed format in use iun the engine
  105186. * @returns the fallback texture
  105187. */
  105188. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  105189. /**
  105190. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  105191. * @param data contains the texture data
  105192. * @param texture defines the BabylonJS internal texture
  105193. * @param createPolynomials will be true if polynomials have been requested
  105194. * @param onLoad defines the callback to trigger once the texture is ready
  105195. * @param onError defines the callback to trigger in case of error
  105196. */
  105197. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  105198. /**
  105199. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  105200. * @param data contains the texture data
  105201. * @param texture defines the BabylonJS internal texture
  105202. * @param callback defines the method to call once ready to upload
  105203. */
  105204. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  105205. }
  105206. }
  105207. declare module BABYLON {
  105208. /**
  105209. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  105210. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  105211. */
  105212. export class KhronosTextureContainer {
  105213. /** contents of the KTX container file */
  105214. arrayBuffer: any;
  105215. private static HEADER_LEN;
  105216. private static COMPRESSED_2D;
  105217. private static COMPRESSED_3D;
  105218. private static TEX_2D;
  105219. private static TEX_3D;
  105220. /**
  105221. * Gets the openGL type
  105222. */
  105223. glType: number;
  105224. /**
  105225. * Gets the openGL type size
  105226. */
  105227. glTypeSize: number;
  105228. /**
  105229. * Gets the openGL format
  105230. */
  105231. glFormat: number;
  105232. /**
  105233. * Gets the openGL internal format
  105234. */
  105235. glInternalFormat: number;
  105236. /**
  105237. * Gets the base internal format
  105238. */
  105239. glBaseInternalFormat: number;
  105240. /**
  105241. * Gets image width in pixel
  105242. */
  105243. pixelWidth: number;
  105244. /**
  105245. * Gets image height in pixel
  105246. */
  105247. pixelHeight: number;
  105248. /**
  105249. * Gets image depth in pixels
  105250. */
  105251. pixelDepth: number;
  105252. /**
  105253. * Gets the number of array elements
  105254. */
  105255. numberOfArrayElements: number;
  105256. /**
  105257. * Gets the number of faces
  105258. */
  105259. numberOfFaces: number;
  105260. /**
  105261. * Gets the number of mipmap levels
  105262. */
  105263. numberOfMipmapLevels: number;
  105264. /**
  105265. * Gets the bytes of key value data
  105266. */
  105267. bytesOfKeyValueData: number;
  105268. /**
  105269. * Gets the load type
  105270. */
  105271. loadType: number;
  105272. /**
  105273. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  105274. */
  105275. isInvalid: boolean;
  105276. /**
  105277. * Creates a new KhronosTextureContainer
  105278. * @param arrayBuffer contents of the KTX container file
  105279. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  105280. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  105281. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  105282. */
  105283. constructor(
  105284. /** contents of the KTX container file */
  105285. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  105286. /**
  105287. * Uploads KTX content to a Babylon Texture.
  105288. * It is assumed that the texture has already been created & is currently bound
  105289. * @hidden
  105290. */
  105291. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  105292. private _upload2DCompressedLevels;
  105293. }
  105294. }
  105295. declare module BABYLON {
  105296. /**
  105297. * Implementation of the KTX Texture Loader.
  105298. * @hidden
  105299. */
  105300. export class _KTXTextureLoader implements IInternalTextureLoader {
  105301. /**
  105302. * Defines wether the loader supports cascade loading the different faces.
  105303. */
  105304. readonly supportCascades: boolean;
  105305. /**
  105306. * This returns if the loader support the current file information.
  105307. * @param extension defines the file extension of the file being loaded
  105308. * @param textureFormatInUse defines the current compressed format in use iun the engine
  105309. * @param fallback defines the fallback internal texture if any
  105310. * @param isBase64 defines whether the texture is encoded as a base64
  105311. * @param isBuffer defines whether the texture data are stored as a buffer
  105312. * @returns true if the loader can load the specified file
  105313. */
  105314. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  105315. /**
  105316. * Transform the url before loading if required.
  105317. * @param rootUrl the url of the texture
  105318. * @param textureFormatInUse defines the current compressed format in use iun the engine
  105319. * @returns the transformed texture
  105320. */
  105321. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  105322. /**
  105323. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  105324. * @param rootUrl the url of the texture
  105325. * @param textureFormatInUse defines the current compressed format in use iun the engine
  105326. * @returns the fallback texture
  105327. */
  105328. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  105329. /**
  105330. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  105331. * @param data contains the texture data
  105332. * @param texture defines the BabylonJS internal texture
  105333. * @param createPolynomials will be true if polynomials have been requested
  105334. * @param onLoad defines the callback to trigger once the texture is ready
  105335. * @param onError defines the callback to trigger in case of error
  105336. */
  105337. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  105338. /**
  105339. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  105340. * @param data contains the texture data
  105341. * @param texture defines the BabylonJS internal texture
  105342. * @param callback defines the method to call once ready to upload
  105343. */
  105344. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  105345. }
  105346. }
  105347. declare module BABYLON {
  105348. /** @hidden */
  105349. export var _forceSceneHelpersToBundle: boolean;
  105350. interface Scene {
  105351. /**
  105352. * Creates a default light for the scene.
  105353. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  105354. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  105355. */
  105356. createDefaultLight(replace?: boolean): void;
  105357. /**
  105358. * Creates a default camera for the scene.
  105359. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  105360. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  105361. * @param replace has default false, when true replaces the active camera in the scene
  105362. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  105363. */
  105364. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  105365. /**
  105366. * Creates a default camera and a default light.
  105367. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  105368. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  105369. * @param replace has the default false, when true replaces the active camera/light in the scene
  105370. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  105371. */
  105372. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  105373. /**
  105374. * Creates a new sky box
  105375. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  105376. * @param environmentTexture defines the texture to use as environment texture
  105377. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  105378. * @param scale defines the overall scale of the skybox
  105379. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  105380. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  105381. * @returns a new mesh holding the sky box
  105382. */
  105383. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  105384. /**
  105385. * Creates a new environment
  105386. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  105387. * @param options defines the options you can use to configure the environment
  105388. * @returns the new EnvironmentHelper
  105389. */
  105390. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  105391. /**
  105392. * Creates a new VREXperienceHelper
  105393. * @see http://doc.babylonjs.com/how_to/webvr_helper
  105394. * @param webVROptions defines the options used to create the new VREXperienceHelper
  105395. * @returns a new VREXperienceHelper
  105396. */
  105397. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  105398. /**
  105399. * Creates a new XREXperienceHelper
  105400. * @see http://doc.babylonjs.com/how_to/webxr
  105401. * @returns a promise for a new XREXperienceHelper
  105402. */
  105403. createDefaultXRExperienceAsync(): Promise<WebXRExperienceHelper>;
  105404. }
  105405. }
  105406. declare module BABYLON {
  105407. /**
  105408. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  105409. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  105410. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  105411. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  105412. */
  105413. export class VideoDome extends TransformNode {
  105414. /**
  105415. * Define the video source as a Monoscopic panoramic 360 video.
  105416. */
  105417. static readonly MODE_MONOSCOPIC: number;
  105418. /**
  105419. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  105420. */
  105421. static readonly MODE_TOPBOTTOM: number;
  105422. /**
  105423. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  105424. */
  105425. static readonly MODE_SIDEBYSIDE: number;
  105426. private _useDirectMapping;
  105427. /**
  105428. * The video texture being displayed on the sphere
  105429. */
  105430. protected _videoTexture: VideoTexture;
  105431. /**
  105432. * Gets the video texture being displayed on the sphere
  105433. */
  105434. readonly videoTexture: VideoTexture;
  105435. /**
  105436. * The skybox material
  105437. */
  105438. protected _material: BackgroundMaterial;
  105439. /**
  105440. * The surface used for the skybox
  105441. */
  105442. protected _mesh: Mesh;
  105443. /**
  105444. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  105445. * Also see the options.resolution property.
  105446. */
  105447. fovMultiplier: number;
  105448. private _videoMode;
  105449. /**
  105450. * Gets or set the current video mode for the video. It can be:
  105451. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  105452. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  105453. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  105454. */
  105455. videoMode: number;
  105456. /**
  105457. * Oberserver used in Stereoscopic VR Mode.
  105458. */
  105459. private _onBeforeCameraRenderObserver;
  105460. /**
  105461. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  105462. * @param name Element's name, child elements will append suffixes for their own names.
  105463. * @param urlsOrVideo defines the url(s) or the video element to use
  105464. * @param options An object containing optional or exposed sub element properties
  105465. */
  105466. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  105467. resolution?: number;
  105468. clickToPlay?: boolean;
  105469. autoPlay?: boolean;
  105470. loop?: boolean;
  105471. size?: number;
  105472. poster?: string;
  105473. faceForward?: boolean;
  105474. useDirectMapping?: boolean;
  105475. }, scene: Scene);
  105476. private _changeVideoMode;
  105477. /**
  105478. * Releases resources associated with this node.
  105479. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  105480. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  105481. */
  105482. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  105483. }
  105484. }
  105485. declare module BABYLON {
  105486. /**
  105487. * This class can be used to get instrumentation data from a Babylon engine
  105488. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  105489. */
  105490. export class EngineInstrumentation implements IDisposable {
  105491. /**
  105492. * Define the instrumented engine.
  105493. */
  105494. engine: Engine;
  105495. private _captureGPUFrameTime;
  105496. private _gpuFrameTimeToken;
  105497. private _gpuFrameTime;
  105498. private _captureShaderCompilationTime;
  105499. private _shaderCompilationTime;
  105500. private _onBeginFrameObserver;
  105501. private _onEndFrameObserver;
  105502. private _onBeforeShaderCompilationObserver;
  105503. private _onAfterShaderCompilationObserver;
  105504. /**
  105505. * Gets the perf counter used for GPU frame time
  105506. */
  105507. readonly gpuFrameTimeCounter: PerfCounter;
  105508. /**
  105509. * Gets the GPU frame time capture status
  105510. */
  105511. /**
  105512. * Enable or disable the GPU frame time capture
  105513. */
  105514. captureGPUFrameTime: boolean;
  105515. /**
  105516. * Gets the perf counter used for shader compilation time
  105517. */
  105518. readonly shaderCompilationTimeCounter: PerfCounter;
  105519. /**
  105520. * Gets the shader compilation time capture status
  105521. */
  105522. /**
  105523. * Enable or disable the shader compilation time capture
  105524. */
  105525. captureShaderCompilationTime: boolean;
  105526. /**
  105527. * Instantiates a new engine instrumentation.
  105528. * This class can be used to get instrumentation data from a Babylon engine
  105529. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  105530. * @param engine Defines the engine to instrument
  105531. */
  105532. constructor(
  105533. /**
  105534. * Define the instrumented engine.
  105535. */
  105536. engine: Engine);
  105537. /**
  105538. * Dispose and release associated resources.
  105539. */
  105540. dispose(): void;
  105541. }
  105542. }
  105543. declare module BABYLON {
  105544. /**
  105545. * This class can be used to get instrumentation data from a Babylon engine
  105546. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  105547. */
  105548. export class SceneInstrumentation implements IDisposable {
  105549. /**
  105550. * Defines the scene to instrument
  105551. */
  105552. scene: Scene;
  105553. private _captureActiveMeshesEvaluationTime;
  105554. private _activeMeshesEvaluationTime;
  105555. private _captureRenderTargetsRenderTime;
  105556. private _renderTargetsRenderTime;
  105557. private _captureFrameTime;
  105558. private _frameTime;
  105559. private _captureRenderTime;
  105560. private _renderTime;
  105561. private _captureInterFrameTime;
  105562. private _interFrameTime;
  105563. private _captureParticlesRenderTime;
  105564. private _particlesRenderTime;
  105565. private _captureSpritesRenderTime;
  105566. private _spritesRenderTime;
  105567. private _capturePhysicsTime;
  105568. private _physicsTime;
  105569. private _captureAnimationsTime;
  105570. private _animationsTime;
  105571. private _captureCameraRenderTime;
  105572. private _cameraRenderTime;
  105573. private _onBeforeActiveMeshesEvaluationObserver;
  105574. private _onAfterActiveMeshesEvaluationObserver;
  105575. private _onBeforeRenderTargetsRenderObserver;
  105576. private _onAfterRenderTargetsRenderObserver;
  105577. private _onAfterRenderObserver;
  105578. private _onBeforeDrawPhaseObserver;
  105579. private _onAfterDrawPhaseObserver;
  105580. private _onBeforeAnimationsObserver;
  105581. private _onBeforeParticlesRenderingObserver;
  105582. private _onAfterParticlesRenderingObserver;
  105583. private _onBeforeSpritesRenderingObserver;
  105584. private _onAfterSpritesRenderingObserver;
  105585. private _onBeforePhysicsObserver;
  105586. private _onAfterPhysicsObserver;
  105587. private _onAfterAnimationsObserver;
  105588. private _onBeforeCameraRenderObserver;
  105589. private _onAfterCameraRenderObserver;
  105590. /**
  105591. * Gets the perf counter used for active meshes evaluation time
  105592. */
  105593. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  105594. /**
  105595. * Gets the active meshes evaluation time capture status
  105596. */
  105597. /**
  105598. * Enable or disable the active meshes evaluation time capture
  105599. */
  105600. captureActiveMeshesEvaluationTime: boolean;
  105601. /**
  105602. * Gets the perf counter used for render targets render time
  105603. */
  105604. readonly renderTargetsRenderTimeCounter: PerfCounter;
  105605. /**
  105606. * Gets the render targets render time capture status
  105607. */
  105608. /**
  105609. * Enable or disable the render targets render time capture
  105610. */
  105611. captureRenderTargetsRenderTime: boolean;
  105612. /**
  105613. * Gets the perf counter used for particles render time
  105614. */
  105615. readonly particlesRenderTimeCounter: PerfCounter;
  105616. /**
  105617. * Gets the particles render time capture status
  105618. */
  105619. /**
  105620. * Enable or disable the particles render time capture
  105621. */
  105622. captureParticlesRenderTime: boolean;
  105623. /**
  105624. * Gets the perf counter used for sprites render time
  105625. */
  105626. readonly spritesRenderTimeCounter: PerfCounter;
  105627. /**
  105628. * Gets the sprites render time capture status
  105629. */
  105630. /**
  105631. * Enable or disable the sprites render time capture
  105632. */
  105633. captureSpritesRenderTime: boolean;
  105634. /**
  105635. * Gets the perf counter used for physics time
  105636. */
  105637. readonly physicsTimeCounter: PerfCounter;
  105638. /**
  105639. * Gets the physics time capture status
  105640. */
  105641. /**
  105642. * Enable or disable the physics time capture
  105643. */
  105644. capturePhysicsTime: boolean;
  105645. /**
  105646. * Gets the perf counter used for animations time
  105647. */
  105648. readonly animationsTimeCounter: PerfCounter;
  105649. /**
  105650. * Gets the animations time capture status
  105651. */
  105652. /**
  105653. * Enable or disable the animations time capture
  105654. */
  105655. captureAnimationsTime: boolean;
  105656. /**
  105657. * Gets the perf counter used for frame time capture
  105658. */
  105659. readonly frameTimeCounter: PerfCounter;
  105660. /**
  105661. * Gets the frame time capture status
  105662. */
  105663. /**
  105664. * Enable or disable the frame time capture
  105665. */
  105666. captureFrameTime: boolean;
  105667. /**
  105668. * Gets the perf counter used for inter-frames time capture
  105669. */
  105670. readonly interFrameTimeCounter: PerfCounter;
  105671. /**
  105672. * Gets the inter-frames time capture status
  105673. */
  105674. /**
  105675. * Enable or disable the inter-frames time capture
  105676. */
  105677. captureInterFrameTime: boolean;
  105678. /**
  105679. * Gets the perf counter used for render time capture
  105680. */
  105681. readonly renderTimeCounter: PerfCounter;
  105682. /**
  105683. * Gets the render time capture status
  105684. */
  105685. /**
  105686. * Enable or disable the render time capture
  105687. */
  105688. captureRenderTime: boolean;
  105689. /**
  105690. * Gets the perf counter used for camera render time capture
  105691. */
  105692. readonly cameraRenderTimeCounter: PerfCounter;
  105693. /**
  105694. * Gets the camera render time capture status
  105695. */
  105696. /**
  105697. * Enable or disable the camera render time capture
  105698. */
  105699. captureCameraRenderTime: boolean;
  105700. /**
  105701. * Gets the perf counter used for draw calls
  105702. */
  105703. readonly drawCallsCounter: PerfCounter;
  105704. /**
  105705. * Instantiates a new scene instrumentation.
  105706. * This class can be used to get instrumentation data from a Babylon engine
  105707. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  105708. * @param scene Defines the scene to instrument
  105709. */
  105710. constructor(
  105711. /**
  105712. * Defines the scene to instrument
  105713. */
  105714. scene: Scene);
  105715. /**
  105716. * Dispose and release associated resources.
  105717. */
  105718. dispose(): void;
  105719. }
  105720. }
  105721. declare module BABYLON {
  105722. /** @hidden */
  105723. export var glowMapGenerationPixelShader: {
  105724. name: string;
  105725. shader: string;
  105726. };
  105727. }
  105728. declare module BABYLON {
  105729. /** @hidden */
  105730. export var glowMapGenerationVertexShader: {
  105731. name: string;
  105732. shader: string;
  105733. };
  105734. }
  105735. declare module BABYLON {
  105736. /**
  105737. * Effect layer options. This helps customizing the behaviour
  105738. * of the effect layer.
  105739. */
  105740. export interface IEffectLayerOptions {
  105741. /**
  105742. * Multiplication factor apply to the canvas size to compute the render target size
  105743. * used to generated the objects (the smaller the faster).
  105744. */
  105745. mainTextureRatio: number;
  105746. /**
  105747. * Enforces a fixed size texture to ensure effect stability across devices.
  105748. */
  105749. mainTextureFixedSize?: number;
  105750. /**
  105751. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  105752. */
  105753. alphaBlendingMode: number;
  105754. /**
  105755. * The camera attached to the layer.
  105756. */
  105757. camera: Nullable<Camera>;
  105758. /**
  105759. * The rendering group to draw the layer in.
  105760. */
  105761. renderingGroupId: number;
  105762. }
  105763. /**
  105764. * The effect layer Helps adding post process effect blended with the main pass.
  105765. *
  105766. * This can be for instance use to generate glow or higlight effects on the scene.
  105767. *
  105768. * The effect layer class can not be used directly and is intented to inherited from to be
  105769. * customized per effects.
  105770. */
  105771. export abstract class EffectLayer {
  105772. private _vertexBuffers;
  105773. private _indexBuffer;
  105774. private _cachedDefines;
  105775. private _effectLayerMapGenerationEffect;
  105776. private _effectLayerOptions;
  105777. private _mergeEffect;
  105778. protected _scene: Scene;
  105779. protected _engine: Engine;
  105780. protected _maxSize: number;
  105781. protected _mainTextureDesiredSize: ISize;
  105782. protected _mainTexture: RenderTargetTexture;
  105783. protected _shouldRender: boolean;
  105784. protected _postProcesses: PostProcess[];
  105785. protected _textures: BaseTexture[];
  105786. protected _emissiveTextureAndColor: {
  105787. texture: Nullable<BaseTexture>;
  105788. color: Color4;
  105789. };
  105790. /**
  105791. * The name of the layer
  105792. */
  105793. name: string;
  105794. /**
  105795. * The clear color of the texture used to generate the glow map.
  105796. */
  105797. neutralColor: Color4;
  105798. /**
  105799. * Specifies wether the highlight layer is enabled or not.
  105800. */
  105801. isEnabled: boolean;
  105802. /**
  105803. * Gets the camera attached to the layer.
  105804. */
  105805. readonly camera: Nullable<Camera>;
  105806. /**
  105807. * Gets the rendering group id the layer should render in.
  105808. */
  105809. readonly renderingGroupId: number;
  105810. /**
  105811. * An event triggered when the effect layer has been disposed.
  105812. */
  105813. onDisposeObservable: Observable<EffectLayer>;
  105814. /**
  105815. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  105816. */
  105817. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  105818. /**
  105819. * An event triggered when the generated texture is being merged in the scene.
  105820. */
  105821. onBeforeComposeObservable: Observable<EffectLayer>;
  105822. /**
  105823. * An event triggered when the generated texture has been merged in the scene.
  105824. */
  105825. onAfterComposeObservable: Observable<EffectLayer>;
  105826. /**
  105827. * An event triggered when the efffect layer changes its size.
  105828. */
  105829. onSizeChangedObservable: Observable<EffectLayer>;
  105830. /** @hidden */
  105831. static _SceneComponentInitialization: (scene: Scene) => void;
  105832. /**
  105833. * Instantiates a new effect Layer and references it in the scene.
  105834. * @param name The name of the layer
  105835. * @param scene The scene to use the layer in
  105836. */
  105837. constructor(
  105838. /** The Friendly of the effect in the scene */
  105839. name: string, scene: Scene);
  105840. /**
  105841. * Get the effect name of the layer.
  105842. * @return The effect name
  105843. */
  105844. abstract getEffectName(): string;
  105845. /**
  105846. * Checks for the readiness of the element composing the layer.
  105847. * @param subMesh the mesh to check for
  105848. * @param useInstances specify wether or not to use instances to render the mesh
  105849. * @return true if ready otherwise, false
  105850. */
  105851. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  105852. /**
  105853. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  105854. * @returns true if the effect requires stencil during the main canvas render pass.
  105855. */
  105856. abstract needStencil(): boolean;
  105857. /**
  105858. * Create the merge effect. This is the shader use to blit the information back
  105859. * to the main canvas at the end of the scene rendering.
  105860. * @returns The effect containing the shader used to merge the effect on the main canvas
  105861. */
  105862. protected abstract _createMergeEffect(): Effect;
  105863. /**
  105864. * Creates the render target textures and post processes used in the effect layer.
  105865. */
  105866. protected abstract _createTextureAndPostProcesses(): void;
  105867. /**
  105868. * Implementation specific of rendering the generating effect on the main canvas.
  105869. * @param effect The effect used to render through
  105870. */
  105871. protected abstract _internalRender(effect: Effect): void;
  105872. /**
  105873. * Sets the required values for both the emissive texture and and the main color.
  105874. */
  105875. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  105876. /**
  105877. * Free any resources and references associated to a mesh.
  105878. * Internal use
  105879. * @param mesh The mesh to free.
  105880. */
  105881. abstract _disposeMesh(mesh: Mesh): void;
  105882. /**
  105883. * Serializes this layer (Glow or Highlight for example)
  105884. * @returns a serialized layer object
  105885. */
  105886. abstract serialize?(): any;
  105887. /**
  105888. * Initializes the effect layer with the required options.
  105889. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  105890. */
  105891. protected _init(options: Partial<IEffectLayerOptions>): void;
  105892. /**
  105893. * Generates the index buffer of the full screen quad blending to the main canvas.
  105894. */
  105895. private _generateIndexBuffer;
  105896. /**
  105897. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  105898. */
  105899. private _genrateVertexBuffer;
  105900. /**
  105901. * Sets the main texture desired size which is the closest power of two
  105902. * of the engine canvas size.
  105903. */
  105904. private _setMainTextureSize;
  105905. /**
  105906. * Creates the main texture for the effect layer.
  105907. */
  105908. protected _createMainTexture(): void;
  105909. /**
  105910. * Adds specific effects defines.
  105911. * @param defines The defines to add specifics to.
  105912. */
  105913. protected _addCustomEffectDefines(defines: string[]): void;
  105914. /**
  105915. * Checks for the readiness of the element composing the layer.
  105916. * @param subMesh the mesh to check for
  105917. * @param useInstances specify wether or not to use instances to render the mesh
  105918. * @param emissiveTexture the associated emissive texture used to generate the glow
  105919. * @return true if ready otherwise, false
  105920. */
  105921. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  105922. /**
  105923. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  105924. */
  105925. render(): void;
  105926. /**
  105927. * Determine if a given mesh will be used in the current effect.
  105928. * @param mesh mesh to test
  105929. * @returns true if the mesh will be used
  105930. */
  105931. hasMesh(mesh: AbstractMesh): boolean;
  105932. /**
  105933. * Returns true if the layer contains information to display, otherwise false.
  105934. * @returns true if the glow layer should be rendered
  105935. */
  105936. shouldRender(): boolean;
  105937. /**
  105938. * Returns true if the mesh should render, otherwise false.
  105939. * @param mesh The mesh to render
  105940. * @returns true if it should render otherwise false
  105941. */
  105942. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  105943. /**
  105944. * Returns true if the mesh can be rendered, otherwise false.
  105945. * @param mesh The mesh to render
  105946. * @param material The material used on the mesh
  105947. * @returns true if it can be rendered otherwise false
  105948. */
  105949. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  105950. /**
  105951. * Returns true if the mesh should render, otherwise false.
  105952. * @param mesh The mesh to render
  105953. * @returns true if it should render otherwise false
  105954. */
  105955. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  105956. /**
  105957. * Renders the submesh passed in parameter to the generation map.
  105958. */
  105959. protected _renderSubMesh(subMesh: SubMesh): void;
  105960. /**
  105961. * Rebuild the required buffers.
  105962. * @hidden Internal use only.
  105963. */
  105964. _rebuild(): void;
  105965. /**
  105966. * Dispose only the render target textures and post process.
  105967. */
  105968. private _disposeTextureAndPostProcesses;
  105969. /**
  105970. * Dispose the highlight layer and free resources.
  105971. */
  105972. dispose(): void;
  105973. /**
  105974. * Gets the class name of the effect layer
  105975. * @returns the string with the class name of the effect layer
  105976. */
  105977. getClassName(): string;
  105978. /**
  105979. * Creates an effect layer from parsed effect layer data
  105980. * @param parsedEffectLayer defines effect layer data
  105981. * @param scene defines the current scene
  105982. * @param rootUrl defines the root URL containing the effect layer information
  105983. * @returns a parsed effect Layer
  105984. */
  105985. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  105986. }
  105987. }
  105988. declare module BABYLON {
  105989. interface AbstractScene {
  105990. /**
  105991. * The list of effect layers (highlights/glow) added to the scene
  105992. * @see http://doc.babylonjs.com/how_to/highlight_layer
  105993. * @see http://doc.babylonjs.com/how_to/glow_layer
  105994. */
  105995. effectLayers: Array<EffectLayer>;
  105996. /**
  105997. * Removes the given effect layer from this scene.
  105998. * @param toRemove defines the effect layer to remove
  105999. * @returns the index of the removed effect layer
  106000. */
  106001. removeEffectLayer(toRemove: EffectLayer): number;
  106002. /**
  106003. * Adds the given effect layer to this scene
  106004. * @param newEffectLayer defines the effect layer to add
  106005. */
  106006. addEffectLayer(newEffectLayer: EffectLayer): void;
  106007. }
  106008. /**
  106009. * Defines the layer scene component responsible to manage any effect layers
  106010. * in a given scene.
  106011. */
  106012. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  106013. /**
  106014. * The component name helpfull to identify the component in the list of scene components.
  106015. */
  106016. readonly name: string;
  106017. /**
  106018. * The scene the component belongs to.
  106019. */
  106020. scene: Scene;
  106021. private _engine;
  106022. private _renderEffects;
  106023. private _needStencil;
  106024. private _previousStencilState;
  106025. /**
  106026. * Creates a new instance of the component for the given scene
  106027. * @param scene Defines the scene to register the component in
  106028. */
  106029. constructor(scene: Scene);
  106030. /**
  106031. * Registers the component in a given scene
  106032. */
  106033. register(): void;
  106034. /**
  106035. * Rebuilds the elements related to this component in case of
  106036. * context lost for instance.
  106037. */
  106038. rebuild(): void;
  106039. /**
  106040. * Serializes the component data to the specified json object
  106041. * @param serializationObject The object to serialize to
  106042. */
  106043. serialize(serializationObject: any): void;
  106044. /**
  106045. * Adds all the element from the container to the scene
  106046. * @param container the container holding the elements
  106047. */
  106048. addFromContainer(container: AbstractScene): void;
  106049. /**
  106050. * Removes all the elements in the container from the scene
  106051. * @param container contains the elements to remove
  106052. * @param dispose if the removed element should be disposed (default: false)
  106053. */
  106054. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  106055. /**
  106056. * Disposes the component and the associated ressources.
  106057. */
  106058. dispose(): void;
  106059. private _isReadyForMesh;
  106060. private _renderMainTexture;
  106061. private _setStencil;
  106062. private _setStencilBack;
  106063. private _draw;
  106064. private _drawCamera;
  106065. private _drawRenderingGroup;
  106066. }
  106067. }
  106068. declare module BABYLON {
  106069. /** @hidden */
  106070. export var glowMapMergePixelShader: {
  106071. name: string;
  106072. shader: string;
  106073. };
  106074. }
  106075. declare module BABYLON {
  106076. /** @hidden */
  106077. export var glowMapMergeVertexShader: {
  106078. name: string;
  106079. shader: string;
  106080. };
  106081. }
  106082. declare module BABYLON {
  106083. interface AbstractScene {
  106084. /**
  106085. * Return a the first highlight layer of the scene with a given name.
  106086. * @param name The name of the highlight layer to look for.
  106087. * @return The highlight layer if found otherwise null.
  106088. */
  106089. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  106090. }
  106091. /**
  106092. * Glow layer options. This helps customizing the behaviour
  106093. * of the glow layer.
  106094. */
  106095. export interface IGlowLayerOptions {
  106096. /**
  106097. * Multiplication factor apply to the canvas size to compute the render target size
  106098. * used to generated the glowing objects (the smaller the faster).
  106099. */
  106100. mainTextureRatio: number;
  106101. /**
  106102. * Enforces a fixed size texture to ensure resize independant blur.
  106103. */
  106104. mainTextureFixedSize?: number;
  106105. /**
  106106. * How big is the kernel of the blur texture.
  106107. */
  106108. blurKernelSize: number;
  106109. /**
  106110. * The camera attached to the layer.
  106111. */
  106112. camera: Nullable<Camera>;
  106113. /**
  106114. * Enable MSAA by chosing the number of samples.
  106115. */
  106116. mainTextureSamples?: number;
  106117. /**
  106118. * The rendering group to draw the layer in.
  106119. */
  106120. renderingGroupId: number;
  106121. }
  106122. /**
  106123. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  106124. *
  106125. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  106126. * glowy meshes to your scene.
  106127. *
  106128. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  106129. */
  106130. export class GlowLayer extends EffectLayer {
  106131. /**
  106132. * Effect Name of the layer.
  106133. */
  106134. static readonly EffectName: string;
  106135. /**
  106136. * The default blur kernel size used for the glow.
  106137. */
  106138. static DefaultBlurKernelSize: number;
  106139. /**
  106140. * The default texture size ratio used for the glow.
  106141. */
  106142. static DefaultTextureRatio: number;
  106143. /**
  106144. * Sets the kernel size of the blur.
  106145. */
  106146. /**
  106147. * Gets the kernel size of the blur.
  106148. */
  106149. blurKernelSize: number;
  106150. /**
  106151. * Sets the glow intensity.
  106152. */
  106153. /**
  106154. * Gets the glow intensity.
  106155. */
  106156. intensity: number;
  106157. private _options;
  106158. private _intensity;
  106159. private _horizontalBlurPostprocess1;
  106160. private _verticalBlurPostprocess1;
  106161. private _horizontalBlurPostprocess2;
  106162. private _verticalBlurPostprocess2;
  106163. private _blurTexture1;
  106164. private _blurTexture2;
  106165. private _postProcesses1;
  106166. private _postProcesses2;
  106167. private _includedOnlyMeshes;
  106168. private _excludedMeshes;
  106169. /**
  106170. * Callback used to let the user override the color selection on a per mesh basis
  106171. */
  106172. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  106173. /**
  106174. * Callback used to let the user override the texture selection on a per mesh basis
  106175. */
  106176. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  106177. /**
  106178. * Instantiates a new glow Layer and references it to the scene.
  106179. * @param name The name of the layer
  106180. * @param scene The scene to use the layer in
  106181. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  106182. */
  106183. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  106184. /**
  106185. * Get the effect name of the layer.
  106186. * @return The effect name
  106187. */
  106188. getEffectName(): string;
  106189. /**
  106190. * Create the merge effect. This is the shader use to blit the information back
  106191. * to the main canvas at the end of the scene rendering.
  106192. */
  106193. protected _createMergeEffect(): Effect;
  106194. /**
  106195. * Creates the render target textures and post processes used in the glow layer.
  106196. */
  106197. protected _createTextureAndPostProcesses(): void;
  106198. /**
  106199. * Checks for the readiness of the element composing the layer.
  106200. * @param subMesh the mesh to check for
  106201. * @param useInstances specify wether or not to use instances to render the mesh
  106202. * @param emissiveTexture the associated emissive texture used to generate the glow
  106203. * @return true if ready otherwise, false
  106204. */
  106205. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  106206. /**
  106207. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  106208. */
  106209. needStencil(): boolean;
  106210. /**
  106211. * Returns true if the mesh can be rendered, otherwise false.
  106212. * @param mesh The mesh to render
  106213. * @param material The material used on the mesh
  106214. * @returns true if it can be rendered otherwise false
  106215. */
  106216. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  106217. /**
  106218. * Implementation specific of rendering the generating effect on the main canvas.
  106219. * @param effect The effect used to render through
  106220. */
  106221. protected _internalRender(effect: Effect): void;
  106222. /**
  106223. * Sets the required values for both the emissive texture and and the main color.
  106224. */
  106225. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  106226. /**
  106227. * Returns true if the mesh should render, otherwise false.
  106228. * @param mesh The mesh to render
  106229. * @returns true if it should render otherwise false
  106230. */
  106231. protected _shouldRenderMesh(mesh: Mesh): boolean;
  106232. /**
  106233. * Adds specific effects defines.
  106234. * @param defines The defines to add specifics to.
  106235. */
  106236. protected _addCustomEffectDefines(defines: string[]): void;
  106237. /**
  106238. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  106239. * @param mesh The mesh to exclude from the glow layer
  106240. */
  106241. addExcludedMesh(mesh: Mesh): void;
  106242. /**
  106243. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  106244. * @param mesh The mesh to remove
  106245. */
  106246. removeExcludedMesh(mesh: Mesh): void;
  106247. /**
  106248. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  106249. * @param mesh The mesh to include in the glow layer
  106250. */
  106251. addIncludedOnlyMesh(mesh: Mesh): void;
  106252. /**
  106253. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  106254. * @param mesh The mesh to remove
  106255. */
  106256. removeIncludedOnlyMesh(mesh: Mesh): void;
  106257. /**
  106258. * Determine if a given mesh will be used in the glow layer
  106259. * @param mesh The mesh to test
  106260. * @returns true if the mesh will be highlighted by the current glow layer
  106261. */
  106262. hasMesh(mesh: AbstractMesh): boolean;
  106263. /**
  106264. * Free any resources and references associated to a mesh.
  106265. * Internal use
  106266. * @param mesh The mesh to free.
  106267. * @hidden
  106268. */
  106269. _disposeMesh(mesh: Mesh): void;
  106270. /**
  106271. * Gets the class name of the effect layer
  106272. * @returns the string with the class name of the effect layer
  106273. */
  106274. getClassName(): string;
  106275. /**
  106276. * Serializes this glow layer
  106277. * @returns a serialized glow layer object
  106278. */
  106279. serialize(): any;
  106280. /**
  106281. * Creates a Glow Layer from parsed glow layer data
  106282. * @param parsedGlowLayer defines glow layer data
  106283. * @param scene defines the current scene
  106284. * @param rootUrl defines the root URL containing the glow layer information
  106285. * @returns a parsed Glow Layer
  106286. */
  106287. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  106288. }
  106289. }
  106290. declare module BABYLON {
  106291. /** @hidden */
  106292. export var glowBlurPostProcessPixelShader: {
  106293. name: string;
  106294. shader: string;
  106295. };
  106296. }
  106297. declare module BABYLON {
  106298. interface AbstractScene {
  106299. /**
  106300. * Return a the first highlight layer of the scene with a given name.
  106301. * @param name The name of the highlight layer to look for.
  106302. * @return The highlight layer if found otherwise null.
  106303. */
  106304. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  106305. }
  106306. /**
  106307. * Highlight layer options. This helps customizing the behaviour
  106308. * of the highlight layer.
  106309. */
  106310. export interface IHighlightLayerOptions {
  106311. /**
  106312. * Multiplication factor apply to the canvas size to compute the render target size
  106313. * used to generated the glowing objects (the smaller the faster).
  106314. */
  106315. mainTextureRatio: number;
  106316. /**
  106317. * Enforces a fixed size texture to ensure resize independant blur.
  106318. */
  106319. mainTextureFixedSize?: number;
  106320. /**
  106321. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  106322. * of the picture to blur (the smaller the faster).
  106323. */
  106324. blurTextureSizeRatio: number;
  106325. /**
  106326. * How big in texel of the blur texture is the vertical blur.
  106327. */
  106328. blurVerticalSize: number;
  106329. /**
  106330. * How big in texel of the blur texture is the horizontal blur.
  106331. */
  106332. blurHorizontalSize: number;
  106333. /**
  106334. * Alpha blending mode used to apply the blur. Default is combine.
  106335. */
  106336. alphaBlendingMode: number;
  106337. /**
  106338. * The camera attached to the layer.
  106339. */
  106340. camera: Nullable<Camera>;
  106341. /**
  106342. * Should we display highlight as a solid stroke?
  106343. */
  106344. isStroke?: boolean;
  106345. /**
  106346. * The rendering group to draw the layer in.
  106347. */
  106348. renderingGroupId: number;
  106349. }
  106350. /**
  106351. * The highlight layer Helps adding a glow effect around a mesh.
  106352. *
  106353. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  106354. * glowy meshes to your scene.
  106355. *
  106356. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  106357. */
  106358. export class HighlightLayer extends EffectLayer {
  106359. name: string;
  106360. /**
  106361. * Effect Name of the highlight layer.
  106362. */
  106363. static readonly EffectName: string;
  106364. /**
  106365. * The neutral color used during the preparation of the glow effect.
  106366. * This is black by default as the blend operation is a blend operation.
  106367. */
  106368. static NeutralColor: Color4;
  106369. /**
  106370. * Stencil value used for glowing meshes.
  106371. */
  106372. static GlowingMeshStencilReference: number;
  106373. /**
  106374. * Stencil value used for the other meshes in the scene.
  106375. */
  106376. static NormalMeshStencilReference: number;
  106377. /**
  106378. * Specifies whether or not the inner glow is ACTIVE in the layer.
  106379. */
  106380. innerGlow: boolean;
  106381. /**
  106382. * Specifies whether or not the outer glow is ACTIVE in the layer.
  106383. */
  106384. outerGlow: boolean;
  106385. /**
  106386. * Specifies the horizontal size of the blur.
  106387. */
  106388. /**
  106389. * Gets the horizontal size of the blur.
  106390. */
  106391. blurHorizontalSize: number;
  106392. /**
  106393. * Specifies the vertical size of the blur.
  106394. */
  106395. /**
  106396. * Gets the vertical size of the blur.
  106397. */
  106398. blurVerticalSize: number;
  106399. /**
  106400. * An event triggered when the highlight layer is being blurred.
  106401. */
  106402. onBeforeBlurObservable: Observable<HighlightLayer>;
  106403. /**
  106404. * An event triggered when the highlight layer has been blurred.
  106405. */
  106406. onAfterBlurObservable: Observable<HighlightLayer>;
  106407. private _instanceGlowingMeshStencilReference;
  106408. private _options;
  106409. private _downSamplePostprocess;
  106410. private _horizontalBlurPostprocess;
  106411. private _verticalBlurPostprocess;
  106412. private _blurTexture;
  106413. private _meshes;
  106414. private _excludedMeshes;
  106415. /**
  106416. * Instantiates a new highlight Layer and references it to the scene..
  106417. * @param name The name of the layer
  106418. * @param scene The scene to use the layer in
  106419. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  106420. */
  106421. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  106422. /**
  106423. * Get the effect name of the layer.
  106424. * @return The effect name
  106425. */
  106426. getEffectName(): string;
  106427. /**
  106428. * Create the merge effect. This is the shader use to blit the information back
  106429. * to the main canvas at the end of the scene rendering.
  106430. */
  106431. protected _createMergeEffect(): Effect;
  106432. /**
  106433. * Creates the render target textures and post processes used in the highlight layer.
  106434. */
  106435. protected _createTextureAndPostProcesses(): void;
  106436. /**
  106437. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  106438. */
  106439. needStencil(): boolean;
  106440. /**
  106441. * Checks for the readiness of the element composing the layer.
  106442. * @param subMesh the mesh to check for
  106443. * @param useInstances specify wether or not to use instances to render the mesh
  106444. * @param emissiveTexture the associated emissive texture used to generate the glow
  106445. * @return true if ready otherwise, false
  106446. */
  106447. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  106448. /**
  106449. * Implementation specific of rendering the generating effect on the main canvas.
  106450. * @param effect The effect used to render through
  106451. */
  106452. protected _internalRender(effect: Effect): void;
  106453. /**
  106454. * Returns true if the layer contains information to display, otherwise false.
  106455. */
  106456. shouldRender(): boolean;
  106457. /**
  106458. * Returns true if the mesh should render, otherwise false.
  106459. * @param mesh The mesh to render
  106460. * @returns true if it should render otherwise false
  106461. */
  106462. protected _shouldRenderMesh(mesh: Mesh): boolean;
  106463. /**
  106464. * Sets the required values for both the emissive texture and and the main color.
  106465. */
  106466. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  106467. /**
  106468. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  106469. * @param mesh The mesh to exclude from the highlight layer
  106470. */
  106471. addExcludedMesh(mesh: Mesh): void;
  106472. /**
  106473. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  106474. * @param mesh The mesh to highlight
  106475. */
  106476. removeExcludedMesh(mesh: Mesh): void;
  106477. /**
  106478. * Determine if a given mesh will be highlighted by the current HighlightLayer
  106479. * @param mesh mesh to test
  106480. * @returns true if the mesh will be highlighted by the current HighlightLayer
  106481. */
  106482. hasMesh(mesh: AbstractMesh): boolean;
  106483. /**
  106484. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  106485. * @param mesh The mesh to highlight
  106486. * @param color The color of the highlight
  106487. * @param glowEmissiveOnly Extract the glow from the emissive texture
  106488. */
  106489. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  106490. /**
  106491. * Remove a mesh from the highlight layer in order to make it stop glowing.
  106492. * @param mesh The mesh to highlight
  106493. */
  106494. removeMesh(mesh: Mesh): void;
  106495. /**
  106496. * Force the stencil to the normal expected value for none glowing parts
  106497. */
  106498. private _defaultStencilReference;
  106499. /**
  106500. * Free any resources and references associated to a mesh.
  106501. * Internal use
  106502. * @param mesh The mesh to free.
  106503. * @hidden
  106504. */
  106505. _disposeMesh(mesh: Mesh): void;
  106506. /**
  106507. * Dispose the highlight layer and free resources.
  106508. */
  106509. dispose(): void;
  106510. /**
  106511. * Gets the class name of the effect layer
  106512. * @returns the string with the class name of the effect layer
  106513. */
  106514. getClassName(): string;
  106515. /**
  106516. * Serializes this Highlight layer
  106517. * @returns a serialized Highlight layer object
  106518. */
  106519. serialize(): any;
  106520. /**
  106521. * Creates a Highlight layer from parsed Highlight layer data
  106522. * @param parsedHightlightLayer defines the Highlight layer data
  106523. * @param scene defines the current scene
  106524. * @param rootUrl defines the root URL containing the Highlight layer information
  106525. * @returns a parsed Highlight layer
  106526. */
  106527. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  106528. }
  106529. }
  106530. declare module BABYLON {
  106531. /** @hidden */
  106532. export var lensFlarePixelShader: {
  106533. name: string;
  106534. shader: string;
  106535. };
  106536. }
  106537. declare module BABYLON {
  106538. /** @hidden */
  106539. export var lensFlareVertexShader: {
  106540. name: string;
  106541. shader: string;
  106542. };
  106543. }
  106544. declare module BABYLON {
  106545. /**
  106546. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  106547. * It is usually composed of several `lensFlare`.
  106548. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  106549. */
  106550. export class LensFlareSystem {
  106551. /**
  106552. * Define the name of the lens flare system
  106553. */
  106554. name: string;
  106555. /**
  106556. * List of lens flares used in this system.
  106557. */
  106558. lensFlares: LensFlare[];
  106559. /**
  106560. * Define a limit from the border the lens flare can be visible.
  106561. */
  106562. borderLimit: number;
  106563. /**
  106564. * Define a viewport border we do not want to see the lens flare in.
  106565. */
  106566. viewportBorder: number;
  106567. /**
  106568. * Define a predicate which could limit the list of meshes able to occlude the effect.
  106569. */
  106570. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  106571. /**
  106572. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  106573. */
  106574. layerMask: number;
  106575. /**
  106576. * Define the id of the lens flare system in the scene.
  106577. * (equal to name by default)
  106578. */
  106579. id: string;
  106580. private _scene;
  106581. private _emitter;
  106582. private _vertexBuffers;
  106583. private _indexBuffer;
  106584. private _effect;
  106585. private _positionX;
  106586. private _positionY;
  106587. private _isEnabled;
  106588. /** @hidden */
  106589. static _SceneComponentInitialization: (scene: Scene) => void;
  106590. /**
  106591. * Instantiates a lens flare system.
  106592. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  106593. * It is usually composed of several `lensFlare`.
  106594. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  106595. * @param name Define the name of the lens flare system in the scene
  106596. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  106597. * @param scene Define the scene the lens flare system belongs to
  106598. */
  106599. constructor(
  106600. /**
  106601. * Define the name of the lens flare system
  106602. */
  106603. name: string, emitter: any, scene: Scene);
  106604. /**
  106605. * Define if the lens flare system is enabled.
  106606. */
  106607. isEnabled: boolean;
  106608. /**
  106609. * Get the scene the effects belongs to.
  106610. * @returns the scene holding the lens flare system
  106611. */
  106612. getScene(): Scene;
  106613. /**
  106614. * Get the emitter of the lens flare system.
  106615. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  106616. * @returns the emitter of the lens flare system
  106617. */
  106618. getEmitter(): any;
  106619. /**
  106620. * Set the emitter of the lens flare system.
  106621. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  106622. * @param newEmitter Define the new emitter of the system
  106623. */
  106624. setEmitter(newEmitter: any): void;
  106625. /**
  106626. * Get the lens flare system emitter position.
  106627. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  106628. * @returns the position
  106629. */
  106630. getEmitterPosition(): Vector3;
  106631. /**
  106632. * @hidden
  106633. */
  106634. computeEffectivePosition(globalViewport: Viewport): boolean;
  106635. /** @hidden */
  106636. _isVisible(): boolean;
  106637. /**
  106638. * @hidden
  106639. */
  106640. render(): boolean;
  106641. /**
  106642. * Dispose and release the lens flare with its associated resources.
  106643. */
  106644. dispose(): void;
  106645. /**
  106646. * Parse a lens flare system from a JSON repressentation
  106647. * @param parsedLensFlareSystem Define the JSON to parse
  106648. * @param scene Define the scene the parsed system should be instantiated in
  106649. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  106650. * @returns the parsed system
  106651. */
  106652. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  106653. /**
  106654. * Serialize the current Lens Flare System into a JSON representation.
  106655. * @returns the serialized JSON
  106656. */
  106657. serialize(): any;
  106658. }
  106659. }
  106660. declare module BABYLON {
  106661. /**
  106662. * This represents one of the lens effect in a `lensFlareSystem`.
  106663. * It controls one of the indiviual texture used in the effect.
  106664. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  106665. */
  106666. export class LensFlare {
  106667. /**
  106668. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  106669. */
  106670. size: number;
  106671. /**
  106672. * 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.
  106673. */
  106674. position: number;
  106675. /**
  106676. * Define the lens color.
  106677. */
  106678. color: Color3;
  106679. /**
  106680. * Define the lens texture.
  106681. */
  106682. texture: Nullable<Texture>;
  106683. /**
  106684. * Define the alpha mode to render this particular lens.
  106685. */
  106686. alphaMode: number;
  106687. private _system;
  106688. /**
  106689. * Creates a new Lens Flare.
  106690. * This represents one of the lens effect in a `lensFlareSystem`.
  106691. * It controls one of the indiviual texture used in the effect.
  106692. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  106693. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  106694. * @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.
  106695. * @param color Define the lens color
  106696. * @param imgUrl Define the lens texture url
  106697. * @param system Define the `lensFlareSystem` this flare is part of
  106698. * @returns The newly created Lens Flare
  106699. */
  106700. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  106701. /**
  106702. * Instantiates a new Lens Flare.
  106703. * This represents one of the lens effect in a `lensFlareSystem`.
  106704. * It controls one of the indiviual texture used in the effect.
  106705. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  106706. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  106707. * @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.
  106708. * @param color Define the lens color
  106709. * @param imgUrl Define the lens texture url
  106710. * @param system Define the `lensFlareSystem` this flare is part of
  106711. */
  106712. constructor(
  106713. /**
  106714. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  106715. */
  106716. size: number,
  106717. /**
  106718. * 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.
  106719. */
  106720. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  106721. /**
  106722. * Dispose and release the lens flare with its associated resources.
  106723. */
  106724. dispose(): void;
  106725. }
  106726. }
  106727. declare module BABYLON {
  106728. interface AbstractScene {
  106729. /**
  106730. * The list of lens flare system added to the scene
  106731. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  106732. */
  106733. lensFlareSystems: Array<LensFlareSystem>;
  106734. /**
  106735. * Removes the given lens flare system from this scene.
  106736. * @param toRemove The lens flare system to remove
  106737. * @returns The index of the removed lens flare system
  106738. */
  106739. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  106740. /**
  106741. * Adds the given lens flare system to this scene
  106742. * @param newLensFlareSystem The lens flare system to add
  106743. */
  106744. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  106745. /**
  106746. * Gets a lens flare system using its name
  106747. * @param name defines the name to look for
  106748. * @returns the lens flare system or null if not found
  106749. */
  106750. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  106751. /**
  106752. * Gets a lens flare system using its id
  106753. * @param id defines the id to look for
  106754. * @returns the lens flare system or null if not found
  106755. */
  106756. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  106757. }
  106758. /**
  106759. * Defines the lens flare scene component responsible to manage any lens flares
  106760. * in a given scene.
  106761. */
  106762. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  106763. /**
  106764. * The component name helpfull to identify the component in the list of scene components.
  106765. */
  106766. readonly name: string;
  106767. /**
  106768. * The scene the component belongs to.
  106769. */
  106770. scene: Scene;
  106771. /**
  106772. * Creates a new instance of the component for the given scene
  106773. * @param scene Defines the scene to register the component in
  106774. */
  106775. constructor(scene: Scene);
  106776. /**
  106777. * Registers the component in a given scene
  106778. */
  106779. register(): void;
  106780. /**
  106781. * Rebuilds the elements related to this component in case of
  106782. * context lost for instance.
  106783. */
  106784. rebuild(): void;
  106785. /**
  106786. * Adds all the element from the container to the scene
  106787. * @param container the container holding the elements
  106788. */
  106789. addFromContainer(container: AbstractScene): void;
  106790. /**
  106791. * Removes all the elements in the container from the scene
  106792. * @param container contains the elements to remove
  106793. * @param dispose if the removed element should be disposed (default: false)
  106794. */
  106795. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  106796. /**
  106797. * Serializes the component data to the specified json object
  106798. * @param serializationObject The object to serialize to
  106799. */
  106800. serialize(serializationObject: any): void;
  106801. /**
  106802. * Disposes the component and the associated ressources.
  106803. */
  106804. dispose(): void;
  106805. private _draw;
  106806. }
  106807. }
  106808. declare module BABYLON {
  106809. /**
  106810. * Defines the shadow generator component responsible to manage any shadow generators
  106811. * in a given scene.
  106812. */
  106813. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  106814. /**
  106815. * The component name helpfull to identify the component in the list of scene components.
  106816. */
  106817. readonly name: string;
  106818. /**
  106819. * The scene the component belongs to.
  106820. */
  106821. scene: Scene;
  106822. /**
  106823. * Creates a new instance of the component for the given scene
  106824. * @param scene Defines the scene to register the component in
  106825. */
  106826. constructor(scene: Scene);
  106827. /**
  106828. * Registers the component in a given scene
  106829. */
  106830. register(): void;
  106831. /**
  106832. * Rebuilds the elements related to this component in case of
  106833. * context lost for instance.
  106834. */
  106835. rebuild(): void;
  106836. /**
  106837. * Serializes the component data to the specified json object
  106838. * @param serializationObject The object to serialize to
  106839. */
  106840. serialize(serializationObject: any): void;
  106841. /**
  106842. * Adds all the element from the container to the scene
  106843. * @param container the container holding the elements
  106844. */
  106845. addFromContainer(container: AbstractScene): void;
  106846. /**
  106847. * Removes all the elements in the container from the scene
  106848. * @param container contains the elements to remove
  106849. * @param dispose if the removed element should be disposed (default: false)
  106850. */
  106851. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  106852. /**
  106853. * Rebuilds the elements related to this component in case of
  106854. * context lost for instance.
  106855. */
  106856. dispose(): void;
  106857. private _gatherRenderTargets;
  106858. }
  106859. }
  106860. declare module BABYLON {
  106861. /**
  106862. * A point light is a light defined by an unique point in world space.
  106863. * The light is emitted in every direction from this point.
  106864. * A good example of a point light is a standard light bulb.
  106865. * Documentation: https://doc.babylonjs.com/babylon101/lights
  106866. */
  106867. export class PointLight extends ShadowLight {
  106868. private _shadowAngle;
  106869. /**
  106870. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  106871. * This specifies what angle the shadow will use to be created.
  106872. *
  106873. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  106874. */
  106875. /**
  106876. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  106877. * This specifies what angle the shadow will use to be created.
  106878. *
  106879. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  106880. */
  106881. shadowAngle: number;
  106882. /**
  106883. * Gets the direction if it has been set.
  106884. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  106885. */
  106886. /**
  106887. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  106888. */
  106889. direction: Vector3;
  106890. /**
  106891. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  106892. * A PointLight emits the light in every direction.
  106893. * It can cast shadows.
  106894. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  106895. * ```javascript
  106896. * var pointLight = new PointLight("pl", camera.position, scene);
  106897. * ```
  106898. * Documentation : https://doc.babylonjs.com/babylon101/lights
  106899. * @param name The light friendly name
  106900. * @param position The position of the point light in the scene
  106901. * @param scene The scene the lights belongs to
  106902. */
  106903. constructor(name: string, position: Vector3, scene: Scene);
  106904. /**
  106905. * Returns the string "PointLight"
  106906. * @returns the class name
  106907. */
  106908. getClassName(): string;
  106909. /**
  106910. * Returns the integer 0.
  106911. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  106912. */
  106913. getTypeID(): number;
  106914. /**
  106915. * Specifies wether or not the shadowmap should be a cube texture.
  106916. * @returns true if the shadowmap needs to be a cube texture.
  106917. */
  106918. needCube(): boolean;
  106919. /**
  106920. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  106921. * @param faceIndex The index of the face we are computed the direction to generate shadow
  106922. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  106923. */
  106924. getShadowDirection(faceIndex?: number): Vector3;
  106925. /**
  106926. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  106927. * - fov = PI / 2
  106928. * - aspect ratio : 1.0
  106929. * - z-near and far equal to the active camera minZ and maxZ.
  106930. * Returns the PointLight.
  106931. */
  106932. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  106933. protected _buildUniformLayout(): void;
  106934. /**
  106935. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  106936. * @param effect The effect to update
  106937. * @param lightIndex The index of the light in the effect to update
  106938. * @returns The point light
  106939. */
  106940. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  106941. /**
  106942. * Prepares the list of defines specific to the light type.
  106943. * @param defines the list of defines
  106944. * @param lightIndex defines the index of the light for the effect
  106945. */
  106946. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  106947. }
  106948. }
  106949. declare module BABYLON {
  106950. /**
  106951. * Header information of HDR texture files.
  106952. */
  106953. export interface HDRInfo {
  106954. /**
  106955. * The height of the texture in pixels.
  106956. */
  106957. height: number;
  106958. /**
  106959. * The width of the texture in pixels.
  106960. */
  106961. width: number;
  106962. /**
  106963. * The index of the beginning of the data in the binary file.
  106964. */
  106965. dataPosition: number;
  106966. }
  106967. /**
  106968. * This groups tools to convert HDR texture to native colors array.
  106969. */
  106970. export class HDRTools {
  106971. private static Ldexp;
  106972. private static Rgbe2float;
  106973. private static readStringLine;
  106974. /**
  106975. * Reads header information from an RGBE texture stored in a native array.
  106976. * More information on this format are available here:
  106977. * https://en.wikipedia.org/wiki/RGBE_image_format
  106978. *
  106979. * @param uint8array The binary file stored in native array.
  106980. * @return The header information.
  106981. */
  106982. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  106983. /**
  106984. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  106985. * This RGBE texture needs to store the information as a panorama.
  106986. *
  106987. * More information on this format are available here:
  106988. * https://en.wikipedia.org/wiki/RGBE_image_format
  106989. *
  106990. * @param buffer The binary file stored in an array buffer.
  106991. * @param size The expected size of the extracted cubemap.
  106992. * @return The Cube Map information.
  106993. */
  106994. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  106995. /**
  106996. * Returns the pixels data extracted from an RGBE texture.
  106997. * This pixels will be stored left to right up to down in the R G B order in one array.
  106998. *
  106999. * More information on this format are available here:
  107000. * https://en.wikipedia.org/wiki/RGBE_image_format
  107001. *
  107002. * @param uint8array The binary file stored in an array buffer.
  107003. * @param hdrInfo The header information of the file.
  107004. * @return The pixels data in RGB right to left up to down order.
  107005. */
  107006. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  107007. private static RGBE_ReadPixels_RLE;
  107008. }
  107009. }
  107010. declare module BABYLON {
  107011. /**
  107012. * This represents a texture coming from an HDR input.
  107013. *
  107014. * The only supported format is currently panorama picture stored in RGBE format.
  107015. * Example of such files can be found on HDRLib: http://hdrlib.com/
  107016. */
  107017. export class HDRCubeTexture extends BaseTexture {
  107018. private static _facesMapping;
  107019. private _generateHarmonics;
  107020. private _noMipmap;
  107021. private _textureMatrix;
  107022. private _size;
  107023. private _onLoad;
  107024. private _onError;
  107025. /**
  107026. * The texture URL.
  107027. */
  107028. url: string;
  107029. /**
  107030. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  107031. */
  107032. coordinatesMode: number;
  107033. protected _isBlocking: boolean;
  107034. /**
  107035. * Sets wether or not the texture is blocking during loading.
  107036. */
  107037. /**
  107038. * Gets wether or not the texture is blocking during loading.
  107039. */
  107040. isBlocking: boolean;
  107041. protected _rotationY: number;
  107042. /**
  107043. * Sets texture matrix rotation angle around Y axis in radians.
  107044. */
  107045. /**
  107046. * Gets texture matrix rotation angle around Y axis radians.
  107047. */
  107048. rotationY: number;
  107049. /**
  107050. * Gets or sets the center of the bounding box associated with the cube texture
  107051. * It must define where the camera used to render the texture was set
  107052. */
  107053. boundingBoxPosition: Vector3;
  107054. private _boundingBoxSize;
  107055. /**
  107056. * Gets or sets the size of the bounding box associated with the cube texture
  107057. * When defined, the cubemap will switch to local mode
  107058. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  107059. * @example https://www.babylonjs-playground.com/#RNASML
  107060. */
  107061. boundingBoxSize: Vector3;
  107062. /**
  107063. * Instantiates an HDRTexture from the following parameters.
  107064. *
  107065. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  107066. * @param scene The scene the texture will be used in
  107067. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  107068. * @param noMipmap Forces to not generate the mipmap if true
  107069. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  107070. * @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)
  107071. * @param reserved Reserved flag for internal use.
  107072. */
  107073. 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>);
  107074. /**
  107075. * Get the current class name of the texture useful for serialization or dynamic coding.
  107076. * @returns "HDRCubeTexture"
  107077. */
  107078. getClassName(): string;
  107079. /**
  107080. * Occurs when the file is raw .hdr file.
  107081. */
  107082. private loadTexture;
  107083. clone(): HDRCubeTexture;
  107084. delayLoad(): void;
  107085. /**
  107086. * Get the texture reflection matrix used to rotate/transform the reflection.
  107087. * @returns the reflection matrix
  107088. */
  107089. getReflectionTextureMatrix(): Matrix;
  107090. /**
  107091. * Set the texture reflection matrix used to rotate/transform the reflection.
  107092. * @param value Define the reflection matrix to set
  107093. */
  107094. setReflectionTextureMatrix(value: Matrix): void;
  107095. /**
  107096. * Parses a JSON representation of an HDR Texture in order to create the texture
  107097. * @param parsedTexture Define the JSON representation
  107098. * @param scene Define the scene the texture should be created in
  107099. * @param rootUrl Define the root url in case we need to load relative dependencies
  107100. * @returns the newly created texture after parsing
  107101. */
  107102. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  107103. serialize(): any;
  107104. }
  107105. }
  107106. declare module BABYLON {
  107107. /**
  107108. * Class used to control physics engine
  107109. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  107110. */
  107111. export class PhysicsEngine implements IPhysicsEngine {
  107112. private _physicsPlugin;
  107113. /**
  107114. * Global value used to control the smallest number supported by the simulation
  107115. */
  107116. static Epsilon: number;
  107117. private _impostors;
  107118. private _joints;
  107119. /**
  107120. * Gets the gravity vector used by the simulation
  107121. */
  107122. gravity: Vector3;
  107123. /**
  107124. * Factory used to create the default physics plugin.
  107125. * @returns The default physics plugin
  107126. */
  107127. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  107128. /**
  107129. * Creates a new Physics Engine
  107130. * @param gravity defines the gravity vector used by the simulation
  107131. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  107132. */
  107133. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  107134. /**
  107135. * Sets the gravity vector used by the simulation
  107136. * @param gravity defines the gravity vector to use
  107137. */
  107138. setGravity(gravity: Vector3): void;
  107139. /**
  107140. * Set the time step of the physics engine.
  107141. * Default is 1/60.
  107142. * To slow it down, enter 1/600 for example.
  107143. * To speed it up, 1/30
  107144. * @param newTimeStep defines the new timestep to apply to this world.
  107145. */
  107146. setTimeStep(newTimeStep?: number): void;
  107147. /**
  107148. * Get the time step of the physics engine.
  107149. * @returns the current time step
  107150. */
  107151. getTimeStep(): number;
  107152. /**
  107153. * Release all resources
  107154. */
  107155. dispose(): void;
  107156. /**
  107157. * Gets the name of the current physics plugin
  107158. * @returns the name of the plugin
  107159. */
  107160. getPhysicsPluginName(): string;
  107161. /**
  107162. * Adding a new impostor for the impostor tracking.
  107163. * This will be done by the impostor itself.
  107164. * @param impostor the impostor to add
  107165. */
  107166. addImpostor(impostor: PhysicsImpostor): void;
  107167. /**
  107168. * Remove an impostor from the engine.
  107169. * This impostor and its mesh will not longer be updated by the physics engine.
  107170. * @param impostor the impostor to remove
  107171. */
  107172. removeImpostor(impostor: PhysicsImpostor): void;
  107173. /**
  107174. * Add a joint to the physics engine
  107175. * @param mainImpostor defines the main impostor to which the joint is added.
  107176. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  107177. * @param joint defines the joint that will connect both impostors.
  107178. */
  107179. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  107180. /**
  107181. * Removes a joint from the simulation
  107182. * @param mainImpostor defines the impostor used with the joint
  107183. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  107184. * @param joint defines the joint to remove
  107185. */
  107186. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  107187. /**
  107188. * Called by the scene. No need to call it.
  107189. * @param delta defines the timespam between frames
  107190. */
  107191. _step(delta: number): void;
  107192. /**
  107193. * Gets the current plugin used to run the simulation
  107194. * @returns current plugin
  107195. */
  107196. getPhysicsPlugin(): IPhysicsEnginePlugin;
  107197. /**
  107198. * Gets the list of physic impostors
  107199. * @returns an array of PhysicsImpostor
  107200. */
  107201. getImpostors(): Array<PhysicsImpostor>;
  107202. /**
  107203. * Gets the impostor for a physics enabled object
  107204. * @param object defines the object impersonated by the impostor
  107205. * @returns the PhysicsImpostor or null if not found
  107206. */
  107207. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  107208. /**
  107209. * Gets the impostor for a physics body object
  107210. * @param body defines physics body used by the impostor
  107211. * @returns the PhysicsImpostor or null if not found
  107212. */
  107213. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  107214. /**
  107215. * Does a raycast in the physics world
  107216. * @param from when should the ray start?
  107217. * @param to when should the ray end?
  107218. * @returns PhysicsRaycastResult
  107219. */
  107220. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  107221. }
  107222. }
  107223. declare module BABYLON {
  107224. /** @hidden */
  107225. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  107226. private _useDeltaForWorldStep;
  107227. world: any;
  107228. name: string;
  107229. private _physicsMaterials;
  107230. private _fixedTimeStep;
  107231. private _cannonRaycastResult;
  107232. private _raycastResult;
  107233. private _removeAfterStep;
  107234. BJSCANNON: any;
  107235. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  107236. setGravity(gravity: Vector3): void;
  107237. setTimeStep(timeStep: number): void;
  107238. getTimeStep(): number;
  107239. executeStep(delta: number): void;
  107240. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  107241. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  107242. generatePhysicsBody(impostor: PhysicsImpostor): void;
  107243. private _processChildMeshes;
  107244. removePhysicsBody(impostor: PhysicsImpostor): void;
  107245. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  107246. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  107247. private _addMaterial;
  107248. private _checkWithEpsilon;
  107249. private _createShape;
  107250. private _createHeightmap;
  107251. private _minus90X;
  107252. private _plus90X;
  107253. private _tmpPosition;
  107254. private _tmpDeltaPosition;
  107255. private _tmpUnityRotation;
  107256. private _updatePhysicsBodyTransformation;
  107257. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  107258. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  107259. isSupported(): boolean;
  107260. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  107261. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  107262. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  107263. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  107264. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  107265. getBodyMass(impostor: PhysicsImpostor): number;
  107266. getBodyFriction(impostor: PhysicsImpostor): number;
  107267. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  107268. getBodyRestitution(impostor: PhysicsImpostor): number;
  107269. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  107270. sleepBody(impostor: PhysicsImpostor): void;
  107271. wakeUpBody(impostor: PhysicsImpostor): void;
  107272. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  107273. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  107274. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  107275. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  107276. getRadius(impostor: PhysicsImpostor): number;
  107277. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  107278. dispose(): void;
  107279. private _extendNamespace;
  107280. /**
  107281. * Does a raycast in the physics world
  107282. * @param from when should the ray start?
  107283. * @param to when should the ray end?
  107284. * @returns PhysicsRaycastResult
  107285. */
  107286. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  107287. }
  107288. }
  107289. declare module BABYLON {
  107290. /** @hidden */
  107291. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  107292. world: any;
  107293. name: string;
  107294. BJSOIMO: any;
  107295. private _raycastResult;
  107296. constructor(iterations?: number, oimoInjection?: any);
  107297. setGravity(gravity: Vector3): void;
  107298. setTimeStep(timeStep: number): void;
  107299. getTimeStep(): number;
  107300. private _tmpImpostorsArray;
  107301. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  107302. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  107303. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  107304. generatePhysicsBody(impostor: PhysicsImpostor): void;
  107305. private _tmpPositionVector;
  107306. removePhysicsBody(impostor: PhysicsImpostor): void;
  107307. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  107308. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  107309. isSupported(): boolean;
  107310. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  107311. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  107312. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  107313. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  107314. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  107315. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  107316. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  107317. getBodyMass(impostor: PhysicsImpostor): number;
  107318. getBodyFriction(impostor: PhysicsImpostor): number;
  107319. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  107320. getBodyRestitution(impostor: PhysicsImpostor): number;
  107321. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  107322. sleepBody(impostor: PhysicsImpostor): void;
  107323. wakeUpBody(impostor: PhysicsImpostor): void;
  107324. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  107325. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  107326. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  107327. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  107328. getRadius(impostor: PhysicsImpostor): number;
  107329. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  107330. dispose(): void;
  107331. /**
  107332. * Does a raycast in the physics world
  107333. * @param from when should the ray start?
  107334. * @param to when should the ray end?
  107335. * @returns PhysicsRaycastResult
  107336. */
  107337. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  107338. }
  107339. }
  107340. declare module BABYLON {
  107341. /**
  107342. * Class containing static functions to help procedurally build meshes
  107343. */
  107344. export class RibbonBuilder {
  107345. /**
  107346. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  107347. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  107348. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  107349. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  107350. * * 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
  107351. * * 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
  107352. * * 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
  107353. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  107354. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  107355. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  107356. * * 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
  107357. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  107358. * * 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
  107359. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  107360. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  107361. * @param name defines the name of the mesh
  107362. * @param options defines the options used to create the mesh
  107363. * @param scene defines the hosting scene
  107364. * @returns the ribbon mesh
  107365. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  107366. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  107367. */
  107368. static CreateRibbon(name: string, options: {
  107369. pathArray: Vector3[][];
  107370. closeArray?: boolean;
  107371. closePath?: boolean;
  107372. offset?: number;
  107373. updatable?: boolean;
  107374. sideOrientation?: number;
  107375. frontUVs?: Vector4;
  107376. backUVs?: Vector4;
  107377. instance?: Mesh;
  107378. invertUV?: boolean;
  107379. uvs?: Vector2[];
  107380. colors?: Color4[];
  107381. }, scene?: Nullable<Scene>): Mesh;
  107382. }
  107383. }
  107384. declare module BABYLON {
  107385. /**
  107386. * Class containing static functions to help procedurally build meshes
  107387. */
  107388. export class ShapeBuilder {
  107389. /**
  107390. * 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.
  107391. * * 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.
  107392. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  107393. * * 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.
  107394. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  107395. * * 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
  107396. * * 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
  107397. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  107398. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  107399. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  107400. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  107401. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  107402. * @param name defines the name of the mesh
  107403. * @param options defines the options used to create the mesh
  107404. * @param scene defines the hosting scene
  107405. * @returns the extruded shape mesh
  107406. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  107407. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  107408. */
  107409. static ExtrudeShape(name: string, options: {
  107410. shape: Vector3[];
  107411. path: Vector3[];
  107412. scale?: number;
  107413. rotation?: number;
  107414. cap?: number;
  107415. updatable?: boolean;
  107416. sideOrientation?: number;
  107417. frontUVs?: Vector4;
  107418. backUVs?: Vector4;
  107419. instance?: Mesh;
  107420. invertUV?: boolean;
  107421. }, scene?: Nullable<Scene>): Mesh;
  107422. /**
  107423. * Creates an custom extruded shape mesh.
  107424. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  107425. * * 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.
  107426. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  107427. * * 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
  107428. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  107429. * * 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
  107430. * * It must returns a float value that will be the scale value applied to the shape on each path point
  107431. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  107432. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  107433. * * 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
  107434. * * 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
  107435. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  107436. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  107437. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  107438. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  107439. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  107440. * @param name defines the name of the mesh
  107441. * @param options defines the options used to create the mesh
  107442. * @param scene defines the hosting scene
  107443. * @returns the custom extruded shape mesh
  107444. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  107445. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  107446. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  107447. */
  107448. static ExtrudeShapeCustom(name: string, options: {
  107449. shape: Vector3[];
  107450. path: Vector3[];
  107451. scaleFunction?: any;
  107452. rotationFunction?: any;
  107453. ribbonCloseArray?: boolean;
  107454. ribbonClosePath?: boolean;
  107455. cap?: number;
  107456. updatable?: boolean;
  107457. sideOrientation?: number;
  107458. frontUVs?: Vector4;
  107459. backUVs?: Vector4;
  107460. instance?: Mesh;
  107461. invertUV?: boolean;
  107462. }, scene?: Nullable<Scene>): Mesh;
  107463. private static _ExtrudeShapeGeneric;
  107464. }
  107465. }
  107466. declare module BABYLON {
  107467. /**
  107468. * AmmoJS Physics plugin
  107469. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107470. * @see https://github.com/kripken/ammo.js/
  107471. */
  107472. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  107473. private _useDeltaForWorldStep;
  107474. /**
  107475. * Reference to the Ammo library
  107476. */
  107477. bjsAMMO: any;
  107478. /**
  107479. * Created ammoJS world which physics bodies are added to
  107480. */
  107481. world: any;
  107482. /**
  107483. * Name of the plugin
  107484. */
  107485. name: string;
  107486. private _timeStep;
  107487. private _fixedTimeStep;
  107488. private _maxSteps;
  107489. private _tmpQuaternion;
  107490. private _tmpAmmoTransform;
  107491. private _tmpAmmoQuaternion;
  107492. private _tmpAmmoConcreteContactResultCallback;
  107493. private _collisionConfiguration;
  107494. private _dispatcher;
  107495. private _overlappingPairCache;
  107496. private _solver;
  107497. private _softBodySolver;
  107498. private _tmpAmmoVectorA;
  107499. private _tmpAmmoVectorB;
  107500. private _tmpAmmoVectorC;
  107501. private _tmpAmmoVectorD;
  107502. private _tmpContactCallbackResult;
  107503. private _tmpAmmoVectorRCA;
  107504. private _tmpAmmoVectorRCB;
  107505. private _raycastResult;
  107506. private static readonly DISABLE_COLLISION_FLAG;
  107507. private static readonly KINEMATIC_FLAG;
  107508. private static readonly DISABLE_DEACTIVATION_FLAG;
  107509. /**
  107510. * Initializes the ammoJS plugin
  107511. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  107512. * @param ammoInjection can be used to inject your own ammo reference
  107513. */
  107514. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any);
  107515. /**
  107516. * Sets the gravity of the physics world (m/(s^2))
  107517. * @param gravity Gravity to set
  107518. */
  107519. setGravity(gravity: Vector3): void;
  107520. /**
  107521. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  107522. * @param timeStep timestep to use in seconds
  107523. */
  107524. setTimeStep(timeStep: number): void;
  107525. /**
  107526. * 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)
  107527. * @param fixedTimeStep fixedTimeStep to use in seconds
  107528. */
  107529. setFixedTimeStep(fixedTimeStep: number): void;
  107530. /**
  107531. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  107532. * @param maxSteps the maximum number of steps by the physics engine per frame
  107533. */
  107534. setMaxSteps(maxSteps: number): void;
  107535. /**
  107536. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  107537. * @returns the current timestep in seconds
  107538. */
  107539. getTimeStep(): number;
  107540. private _isImpostorInContact;
  107541. private _isImpostorPairInContact;
  107542. private _stepSimulation;
  107543. /**
  107544. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  107545. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  107546. * After the step the babylon meshes are set to the position of the physics imposters
  107547. * @param delta amount of time to step forward
  107548. * @param impostors array of imposters to update before/after the step
  107549. */
  107550. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  107551. /**
  107552. * Update babylon mesh to match physics world object
  107553. * @param impostor imposter to match
  107554. */
  107555. private _afterSoftStep;
  107556. /**
  107557. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  107558. * @param impostor imposter to match
  107559. */
  107560. private _ropeStep;
  107561. /**
  107562. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  107563. * @param impostor imposter to match
  107564. */
  107565. private _softbodyOrClothStep;
  107566. private _tmpVector;
  107567. private _tmpMatrix;
  107568. /**
  107569. * Applies an impulse on the imposter
  107570. * @param impostor imposter to apply impulse to
  107571. * @param force amount of force to be applied to the imposter
  107572. * @param contactPoint the location to apply the impulse on the imposter
  107573. */
  107574. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  107575. /**
  107576. * Applies a force on the imposter
  107577. * @param impostor imposter to apply force
  107578. * @param force amount of force to be applied to the imposter
  107579. * @param contactPoint the location to apply the force on the imposter
  107580. */
  107581. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  107582. /**
  107583. * Creates a physics body using the plugin
  107584. * @param impostor the imposter to create the physics body on
  107585. */
  107586. generatePhysicsBody(impostor: PhysicsImpostor): void;
  107587. /**
  107588. * Removes the physics body from the imposter and disposes of the body's memory
  107589. * @param impostor imposter to remove the physics body from
  107590. */
  107591. removePhysicsBody(impostor: PhysicsImpostor): void;
  107592. /**
  107593. * Generates a joint
  107594. * @param impostorJoint the imposter joint to create the joint with
  107595. */
  107596. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  107597. /**
  107598. * Removes a joint
  107599. * @param impostorJoint the imposter joint to remove the joint from
  107600. */
  107601. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  107602. private _addMeshVerts;
  107603. /**
  107604. * Initialise the soft body vertices to match its object's (mesh) vertices
  107605. * Softbody vertices (nodes) are in world space and to match this
  107606. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  107607. * @param impostor to create the softbody for
  107608. */
  107609. private _softVertexData;
  107610. /**
  107611. * Create an impostor's soft body
  107612. * @param impostor to create the softbody for
  107613. */
  107614. private _createSoftbody;
  107615. /**
  107616. * Create cloth for an impostor
  107617. * @param impostor to create the softbody for
  107618. */
  107619. private _createCloth;
  107620. /**
  107621. * Create rope for an impostor
  107622. * @param impostor to create the softbody for
  107623. */
  107624. private _createRope;
  107625. private _addHullVerts;
  107626. private _createShape;
  107627. /**
  107628. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  107629. * @param impostor imposter containing the physics body and babylon object
  107630. */
  107631. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  107632. /**
  107633. * Sets the babylon object's position/rotation from the physics body's position/rotation
  107634. * @param impostor imposter containing the physics body and babylon object
  107635. * @param newPosition new position
  107636. * @param newRotation new rotation
  107637. */
  107638. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  107639. /**
  107640. * If this plugin is supported
  107641. * @returns true if its supported
  107642. */
  107643. isSupported(): boolean;
  107644. /**
  107645. * Sets the linear velocity of the physics body
  107646. * @param impostor imposter to set the velocity on
  107647. * @param velocity velocity to set
  107648. */
  107649. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  107650. /**
  107651. * Sets the angular velocity of the physics body
  107652. * @param impostor imposter to set the velocity on
  107653. * @param velocity velocity to set
  107654. */
  107655. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  107656. /**
  107657. * gets the linear velocity
  107658. * @param impostor imposter to get linear velocity from
  107659. * @returns linear velocity
  107660. */
  107661. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  107662. /**
  107663. * gets the angular velocity
  107664. * @param impostor imposter to get angular velocity from
  107665. * @returns angular velocity
  107666. */
  107667. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  107668. /**
  107669. * Sets the mass of physics body
  107670. * @param impostor imposter to set the mass on
  107671. * @param mass mass to set
  107672. */
  107673. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  107674. /**
  107675. * Gets the mass of the physics body
  107676. * @param impostor imposter to get the mass from
  107677. * @returns mass
  107678. */
  107679. getBodyMass(impostor: PhysicsImpostor): number;
  107680. /**
  107681. * Gets friction of the impostor
  107682. * @param impostor impostor to get friction from
  107683. * @returns friction value
  107684. */
  107685. getBodyFriction(impostor: PhysicsImpostor): number;
  107686. /**
  107687. * Sets friction of the impostor
  107688. * @param impostor impostor to set friction on
  107689. * @param friction friction value
  107690. */
  107691. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  107692. /**
  107693. * Gets restitution of the impostor
  107694. * @param impostor impostor to get restitution from
  107695. * @returns restitution value
  107696. */
  107697. getBodyRestitution(impostor: PhysicsImpostor): number;
  107698. /**
  107699. * Sets resitution of the impostor
  107700. * @param impostor impostor to set resitution on
  107701. * @param restitution resitution value
  107702. */
  107703. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  107704. /**
  107705. * Gets pressure inside the impostor
  107706. * @param impostor impostor to get pressure from
  107707. * @returns pressure value
  107708. */
  107709. getBodyPressure(impostor: PhysicsImpostor): number;
  107710. /**
  107711. * Sets pressure inside a soft body impostor
  107712. * Cloth and rope must remain 0 pressure
  107713. * @param impostor impostor to set pressure on
  107714. * @param pressure pressure value
  107715. */
  107716. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  107717. /**
  107718. * Gets stiffness of the impostor
  107719. * @param impostor impostor to get stiffness from
  107720. * @returns pressure value
  107721. */
  107722. getBodyStiffness(impostor: PhysicsImpostor): number;
  107723. /**
  107724. * Sets stiffness of the impostor
  107725. * @param impostor impostor to set stiffness on
  107726. * @param stiffness stiffness value from 0 to 1
  107727. */
  107728. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  107729. /**
  107730. * Gets velocityIterations of the impostor
  107731. * @param impostor impostor to get velocity iterations from
  107732. * @returns velocityIterations value
  107733. */
  107734. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  107735. /**
  107736. * Sets velocityIterations of the impostor
  107737. * @param impostor impostor to set velocity iterations on
  107738. * @param velocityIterations velocityIterations value
  107739. */
  107740. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  107741. /**
  107742. * Gets positionIterations of the impostor
  107743. * @param impostor impostor to get position iterations from
  107744. * @returns positionIterations value
  107745. */
  107746. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  107747. /**
  107748. * Sets positionIterations of the impostor
  107749. * @param impostor impostor to set position on
  107750. * @param positionIterations positionIterations value
  107751. */
  107752. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  107753. /**
  107754. * Append an anchor to a cloth object
  107755. * @param impostor is the cloth impostor to add anchor to
  107756. * @param otherImpostor is the rigid impostor to anchor to
  107757. * @param width ratio across width from 0 to 1
  107758. * @param height ratio up height from 0 to 1
  107759. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  107760. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  107761. */
  107762. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  107763. /**
  107764. * Append an hook to a rope object
  107765. * @param impostor is the rope impostor to add hook to
  107766. * @param otherImpostor is the rigid impostor to hook to
  107767. * @param length ratio along the rope from 0 to 1
  107768. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  107769. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  107770. */
  107771. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  107772. /**
  107773. * Sleeps the physics body and stops it from being active
  107774. * @param impostor impostor to sleep
  107775. */
  107776. sleepBody(impostor: PhysicsImpostor): void;
  107777. /**
  107778. * Activates the physics body
  107779. * @param impostor impostor to activate
  107780. */
  107781. wakeUpBody(impostor: PhysicsImpostor): void;
  107782. /**
  107783. * Updates the distance parameters of the joint
  107784. * @param joint joint to update
  107785. * @param maxDistance maximum distance of the joint
  107786. * @param minDistance minimum distance of the joint
  107787. */
  107788. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  107789. /**
  107790. * Sets a motor on the joint
  107791. * @param joint joint to set motor on
  107792. * @param speed speed of the motor
  107793. * @param maxForce maximum force of the motor
  107794. * @param motorIndex index of the motor
  107795. */
  107796. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  107797. /**
  107798. * Sets the motors limit
  107799. * @param joint joint to set limit on
  107800. * @param upperLimit upper limit
  107801. * @param lowerLimit lower limit
  107802. */
  107803. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  107804. /**
  107805. * Syncs the position and rotation of a mesh with the impostor
  107806. * @param mesh mesh to sync
  107807. * @param impostor impostor to update the mesh with
  107808. */
  107809. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  107810. /**
  107811. * Gets the radius of the impostor
  107812. * @param impostor impostor to get radius from
  107813. * @returns the radius
  107814. */
  107815. getRadius(impostor: PhysicsImpostor): number;
  107816. /**
  107817. * Gets the box size of the impostor
  107818. * @param impostor impostor to get box size from
  107819. * @param result the resulting box size
  107820. */
  107821. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  107822. /**
  107823. * Disposes of the impostor
  107824. */
  107825. dispose(): void;
  107826. /**
  107827. * Does a raycast in the physics world
  107828. * @param from when should the ray start?
  107829. * @param to when should the ray end?
  107830. * @returns PhysicsRaycastResult
  107831. */
  107832. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  107833. }
  107834. }
  107835. declare module BABYLON {
  107836. interface AbstractScene {
  107837. /**
  107838. * The list of reflection probes added to the scene
  107839. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  107840. */
  107841. reflectionProbes: Array<ReflectionProbe>;
  107842. /**
  107843. * Removes the given reflection probe from this scene.
  107844. * @param toRemove The reflection probe to remove
  107845. * @returns The index of the removed reflection probe
  107846. */
  107847. removeReflectionProbe(toRemove: ReflectionProbe): number;
  107848. /**
  107849. * Adds the given reflection probe to this scene.
  107850. * @param newReflectionProbe The reflection probe to add
  107851. */
  107852. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  107853. }
  107854. /**
  107855. * Class used to generate realtime reflection / refraction cube textures
  107856. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  107857. */
  107858. export class ReflectionProbe {
  107859. /** defines the name of the probe */
  107860. name: string;
  107861. private _scene;
  107862. private _renderTargetTexture;
  107863. private _projectionMatrix;
  107864. private _viewMatrix;
  107865. private _target;
  107866. private _add;
  107867. private _attachedMesh;
  107868. private _invertYAxis;
  107869. /** Gets or sets probe position (center of the cube map) */
  107870. position: Vector3;
  107871. /**
  107872. * Creates a new reflection probe
  107873. * @param name defines the name of the probe
  107874. * @param size defines the texture resolution (for each face)
  107875. * @param scene defines the hosting scene
  107876. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  107877. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  107878. */
  107879. constructor(
  107880. /** defines the name of the probe */
  107881. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  107882. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  107883. samples: number;
  107884. /** Gets or sets the refresh rate to use (on every frame by default) */
  107885. refreshRate: number;
  107886. /**
  107887. * Gets the hosting scene
  107888. * @returns a Scene
  107889. */
  107890. getScene(): Scene;
  107891. /** Gets the internal CubeTexture used to render to */
  107892. readonly cubeTexture: RenderTargetTexture;
  107893. /** Gets the list of meshes to render */
  107894. readonly renderList: Nullable<AbstractMesh[]>;
  107895. /**
  107896. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  107897. * @param mesh defines the mesh to attach to
  107898. */
  107899. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  107900. /**
  107901. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  107902. * @param renderingGroupId The rendering group id corresponding to its index
  107903. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  107904. */
  107905. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  107906. /**
  107907. * Clean all associated resources
  107908. */
  107909. dispose(): void;
  107910. /**
  107911. * Converts the reflection probe information to a readable string for debug purpose.
  107912. * @param fullDetails Supports for multiple levels of logging within scene loading
  107913. * @returns the human readable reflection probe info
  107914. */
  107915. toString(fullDetails?: boolean): string;
  107916. /**
  107917. * Get the class name of the relfection probe.
  107918. * @returns "ReflectionProbe"
  107919. */
  107920. getClassName(): string;
  107921. /**
  107922. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  107923. * @returns The JSON representation of the texture
  107924. */
  107925. serialize(): any;
  107926. /**
  107927. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  107928. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  107929. * @param scene Define the scene the parsed reflection probe should be instantiated in
  107930. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  107931. * @returns The parsed reflection probe if successful
  107932. */
  107933. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  107934. }
  107935. }
  107936. declare module BABYLON {
  107937. /** @hidden */
  107938. export var _BabylonLoaderRegistered: boolean;
  107939. }
  107940. declare module BABYLON {
  107941. /**
  107942. * The Physically based simple base material of BJS.
  107943. *
  107944. * This enables better naming and convention enforcements on top of the pbrMaterial.
  107945. * It is used as the base class for both the specGloss and metalRough conventions.
  107946. */
  107947. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  107948. /**
  107949. * Number of Simultaneous lights allowed on the material.
  107950. */
  107951. maxSimultaneousLights: number;
  107952. /**
  107953. * If sets to true, disables all the lights affecting the material.
  107954. */
  107955. disableLighting: boolean;
  107956. /**
  107957. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  107958. */
  107959. environmentTexture: BaseTexture;
  107960. /**
  107961. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  107962. */
  107963. invertNormalMapX: boolean;
  107964. /**
  107965. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  107966. */
  107967. invertNormalMapY: boolean;
  107968. /**
  107969. * Normal map used in the model.
  107970. */
  107971. normalTexture: BaseTexture;
  107972. /**
  107973. * Emissivie color used to self-illuminate the model.
  107974. */
  107975. emissiveColor: Color3;
  107976. /**
  107977. * Emissivie texture used to self-illuminate the model.
  107978. */
  107979. emissiveTexture: BaseTexture;
  107980. /**
  107981. * Occlusion Channel Strenght.
  107982. */
  107983. occlusionStrength: number;
  107984. /**
  107985. * Occlusion Texture of the material (adding extra occlusion effects).
  107986. */
  107987. occlusionTexture: BaseTexture;
  107988. /**
  107989. * Defines the alpha limits in alpha test mode.
  107990. */
  107991. alphaCutOff: number;
  107992. /**
  107993. * Gets the current double sided mode.
  107994. */
  107995. /**
  107996. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  107997. */
  107998. doubleSided: boolean;
  107999. /**
  108000. * Stores the pre-calculated light information of a mesh in a texture.
  108001. */
  108002. lightmapTexture: BaseTexture;
  108003. /**
  108004. * If true, the light map contains occlusion information instead of lighting info.
  108005. */
  108006. useLightmapAsShadowmap: boolean;
  108007. /**
  108008. * Instantiates a new PBRMaterial instance.
  108009. *
  108010. * @param name The material name
  108011. * @param scene The scene the material will be use in.
  108012. */
  108013. constructor(name: string, scene: Scene);
  108014. getClassName(): string;
  108015. }
  108016. }
  108017. declare module BABYLON {
  108018. /**
  108019. * The PBR material of BJS following the metal roughness convention.
  108020. *
  108021. * This fits to the PBR convention in the GLTF definition:
  108022. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  108023. */
  108024. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  108025. /**
  108026. * The base color has two different interpretations depending on the value of metalness.
  108027. * When the material is a metal, the base color is the specific measured reflectance value
  108028. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  108029. * of the material.
  108030. */
  108031. baseColor: Color3;
  108032. /**
  108033. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  108034. * well as opacity information in the alpha channel.
  108035. */
  108036. baseTexture: BaseTexture;
  108037. /**
  108038. * Specifies the metallic scalar value of the material.
  108039. * Can also be used to scale the metalness values of the metallic texture.
  108040. */
  108041. metallic: number;
  108042. /**
  108043. * Specifies the roughness scalar value of the material.
  108044. * Can also be used to scale the roughness values of the metallic texture.
  108045. */
  108046. roughness: number;
  108047. /**
  108048. * Texture containing both the metallic value in the B channel and the
  108049. * roughness value in the G channel to keep better precision.
  108050. */
  108051. metallicRoughnessTexture: BaseTexture;
  108052. /**
  108053. * Instantiates a new PBRMetalRoughnessMaterial instance.
  108054. *
  108055. * @param name The material name
  108056. * @param scene The scene the material will be use in.
  108057. */
  108058. constructor(name: string, scene: Scene);
  108059. /**
  108060. * Return the currrent class name of the material.
  108061. */
  108062. getClassName(): string;
  108063. /**
  108064. * Makes a duplicate of the current material.
  108065. * @param name - name to use for the new material.
  108066. */
  108067. clone(name: string): PBRMetallicRoughnessMaterial;
  108068. /**
  108069. * Serialize the material to a parsable JSON object.
  108070. */
  108071. serialize(): any;
  108072. /**
  108073. * Parses a JSON object correponding to the serialize function.
  108074. */
  108075. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  108076. }
  108077. }
  108078. declare module BABYLON {
  108079. /**
  108080. * The PBR material of BJS following the specular glossiness convention.
  108081. *
  108082. * This fits to the PBR convention in the GLTF definition:
  108083. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  108084. */
  108085. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  108086. /**
  108087. * Specifies the diffuse color of the material.
  108088. */
  108089. diffuseColor: Color3;
  108090. /**
  108091. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  108092. * channel.
  108093. */
  108094. diffuseTexture: BaseTexture;
  108095. /**
  108096. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  108097. */
  108098. specularColor: Color3;
  108099. /**
  108100. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  108101. */
  108102. glossiness: number;
  108103. /**
  108104. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  108105. */
  108106. specularGlossinessTexture: BaseTexture;
  108107. /**
  108108. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  108109. *
  108110. * @param name The material name
  108111. * @param scene The scene the material will be use in.
  108112. */
  108113. constructor(name: string, scene: Scene);
  108114. /**
  108115. * Return the currrent class name of the material.
  108116. */
  108117. getClassName(): string;
  108118. /**
  108119. * Makes a duplicate of the current material.
  108120. * @param name - name to use for the new material.
  108121. */
  108122. clone(name: string): PBRSpecularGlossinessMaterial;
  108123. /**
  108124. * Serialize the material to a parsable JSON object.
  108125. */
  108126. serialize(): any;
  108127. /**
  108128. * Parses a JSON object correponding to the serialize function.
  108129. */
  108130. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  108131. }
  108132. }
  108133. declare module BABYLON {
  108134. /**
  108135. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  108136. * It can help converting any input color in a desired output one. This can then be used to create effects
  108137. * from sepia, black and white to sixties or futuristic rendering...
  108138. *
  108139. * The only supported format is currently 3dl.
  108140. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  108141. */
  108142. export class ColorGradingTexture extends BaseTexture {
  108143. /**
  108144. * The current texture matrix. (will always be identity in color grading texture)
  108145. */
  108146. private _textureMatrix;
  108147. /**
  108148. * The texture URL.
  108149. */
  108150. url: string;
  108151. /**
  108152. * Empty line regex stored for GC.
  108153. */
  108154. private static _noneEmptyLineRegex;
  108155. private _engine;
  108156. /**
  108157. * Instantiates a ColorGradingTexture from the following parameters.
  108158. *
  108159. * @param url The location of the color gradind data (currently only supporting 3dl)
  108160. * @param scene The scene the texture will be used in
  108161. */
  108162. constructor(url: string, scene: Scene);
  108163. /**
  108164. * Returns the texture matrix used in most of the material.
  108165. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  108166. */
  108167. getTextureMatrix(): Matrix;
  108168. /**
  108169. * Occurs when the file being loaded is a .3dl LUT file.
  108170. */
  108171. private load3dlTexture;
  108172. /**
  108173. * Starts the loading process of the texture.
  108174. */
  108175. private loadTexture;
  108176. /**
  108177. * Clones the color gradind texture.
  108178. */
  108179. clone(): ColorGradingTexture;
  108180. /**
  108181. * Called during delayed load for textures.
  108182. */
  108183. delayLoad(): void;
  108184. /**
  108185. * Parses a color grading texture serialized by Babylon.
  108186. * @param parsedTexture The texture information being parsedTexture
  108187. * @param scene The scene to load the texture in
  108188. * @param rootUrl The root url of the data assets to load
  108189. * @return A color gradind texture
  108190. */
  108191. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  108192. /**
  108193. * Serializes the LUT texture to json format.
  108194. */
  108195. serialize(): any;
  108196. }
  108197. }
  108198. declare module BABYLON {
  108199. /**
  108200. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  108201. */
  108202. export class EquiRectangularCubeTexture extends BaseTexture {
  108203. /** The six faces of the cube. */
  108204. private static _FacesMapping;
  108205. private _noMipmap;
  108206. private _onLoad;
  108207. private _onError;
  108208. /** The size of the cubemap. */
  108209. private _size;
  108210. /** The buffer of the image. */
  108211. private _buffer;
  108212. /** The width of the input image. */
  108213. private _width;
  108214. /** The height of the input image. */
  108215. private _height;
  108216. /** The URL to the image. */
  108217. url: string;
  108218. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  108219. coordinatesMode: number;
  108220. /**
  108221. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  108222. * @param url The location of the image
  108223. * @param scene The scene the texture will be used in
  108224. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  108225. * @param noMipmap Forces to not generate the mipmap if true
  108226. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  108227. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  108228. * @param onLoad — defines a callback called when texture is loaded
  108229. * @param onError — defines a callback called if there is an error
  108230. */
  108231. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  108232. /**
  108233. * Load the image data, by putting the image on a canvas and extracting its buffer.
  108234. */
  108235. private loadImage;
  108236. /**
  108237. * Convert the image buffer into a cubemap and create a CubeTexture.
  108238. */
  108239. private loadTexture;
  108240. /**
  108241. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  108242. * @param buffer The ArrayBuffer that should be converted.
  108243. * @returns The buffer as Float32Array.
  108244. */
  108245. private getFloat32ArrayFromArrayBuffer;
  108246. /**
  108247. * Get the current class name of the texture useful for serialization or dynamic coding.
  108248. * @returns "EquiRectangularCubeTexture"
  108249. */
  108250. getClassName(): string;
  108251. /**
  108252. * Create a clone of the current EquiRectangularCubeTexture and return it.
  108253. * @returns A clone of the current EquiRectangularCubeTexture.
  108254. */
  108255. clone(): EquiRectangularCubeTexture;
  108256. }
  108257. }
  108258. declare module BABYLON {
  108259. /**
  108260. * Based on jsTGALoader - Javascript loader for TGA file
  108261. * By Vincent Thibault
  108262. * @see http://blog.robrowser.com/javascript-tga-loader.html
  108263. */
  108264. export class TGATools {
  108265. private static _TYPE_INDEXED;
  108266. private static _TYPE_RGB;
  108267. private static _TYPE_GREY;
  108268. private static _TYPE_RLE_INDEXED;
  108269. private static _TYPE_RLE_RGB;
  108270. private static _TYPE_RLE_GREY;
  108271. private static _ORIGIN_MASK;
  108272. private static _ORIGIN_SHIFT;
  108273. private static _ORIGIN_BL;
  108274. private static _ORIGIN_BR;
  108275. private static _ORIGIN_UL;
  108276. private static _ORIGIN_UR;
  108277. /**
  108278. * Gets the header of a TGA file
  108279. * @param data defines the TGA data
  108280. * @returns the header
  108281. */
  108282. static GetTGAHeader(data: Uint8Array): any;
  108283. /**
  108284. * Uploads TGA content to a Babylon Texture
  108285. * @hidden
  108286. */
  108287. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  108288. /** @hidden */
  108289. 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;
  108290. /** @hidden */
  108291. 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;
  108292. /** @hidden */
  108293. 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;
  108294. /** @hidden */
  108295. 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;
  108296. /** @hidden */
  108297. 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;
  108298. /** @hidden */
  108299. 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;
  108300. }
  108301. }
  108302. declare module BABYLON {
  108303. /**
  108304. * Implementation of the TGA Texture Loader.
  108305. * @hidden
  108306. */
  108307. export class _TGATextureLoader implements IInternalTextureLoader {
  108308. /**
  108309. * Defines wether the loader supports cascade loading the different faces.
  108310. */
  108311. readonly supportCascades: boolean;
  108312. /**
  108313. * This returns if the loader support the current file information.
  108314. * @param extension defines the file extension of the file being loaded
  108315. * @param textureFormatInUse defines the current compressed format in use iun the engine
  108316. * @param fallback defines the fallback internal texture if any
  108317. * @param isBase64 defines whether the texture is encoded as a base64
  108318. * @param isBuffer defines whether the texture data are stored as a buffer
  108319. * @returns true if the loader can load the specified file
  108320. */
  108321. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  108322. /**
  108323. * Transform the url before loading if required.
  108324. * @param rootUrl the url of the texture
  108325. * @param textureFormatInUse defines the current compressed format in use iun the engine
  108326. * @returns the transformed texture
  108327. */
  108328. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  108329. /**
  108330. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  108331. * @param rootUrl the url of the texture
  108332. * @param textureFormatInUse defines the current compressed format in use iun the engine
  108333. * @returns the fallback texture
  108334. */
  108335. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  108336. /**
  108337. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  108338. * @param data contains the texture data
  108339. * @param texture defines the BabylonJS internal texture
  108340. * @param createPolynomials will be true if polynomials have been requested
  108341. * @param onLoad defines the callback to trigger once the texture is ready
  108342. * @param onError defines the callback to trigger in case of error
  108343. */
  108344. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  108345. /**
  108346. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  108347. * @param data contains the texture data
  108348. * @param texture defines the BabylonJS internal texture
  108349. * @param callback defines the method to call once ready to upload
  108350. */
  108351. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  108352. }
  108353. }
  108354. declare module BABYLON {
  108355. /**
  108356. * 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.
  108357. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  108358. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  108359. */
  108360. export class CustomProceduralTexture extends ProceduralTexture {
  108361. private _animate;
  108362. private _time;
  108363. private _config;
  108364. private _texturePath;
  108365. /**
  108366. * Instantiates a new Custom Procedural Texture.
  108367. * 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.
  108368. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  108369. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  108370. * @param name Define the name of the texture
  108371. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  108372. * @param size Define the size of the texture to create
  108373. * @param scene Define the scene the texture belongs to
  108374. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  108375. * @param generateMipMaps Define if the texture should creates mip maps or not
  108376. */
  108377. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  108378. private _loadJson;
  108379. /**
  108380. * Is the texture ready to be used ? (rendered at least once)
  108381. * @returns true if ready, otherwise, false.
  108382. */
  108383. isReady(): boolean;
  108384. /**
  108385. * Render the texture to its associated render target.
  108386. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  108387. */
  108388. render(useCameraPostProcess?: boolean): void;
  108389. /**
  108390. * Update the list of dependant textures samplers in the shader.
  108391. */
  108392. updateTextures(): void;
  108393. /**
  108394. * Update the uniform values of the procedural texture in the shader.
  108395. */
  108396. updateShaderUniforms(): void;
  108397. /**
  108398. * Define if the texture animates or not.
  108399. */
  108400. animate: boolean;
  108401. }
  108402. }
  108403. declare module BABYLON {
  108404. /** @hidden */
  108405. export var noisePixelShader: {
  108406. name: string;
  108407. shader: string;
  108408. };
  108409. }
  108410. declare module BABYLON {
  108411. /**
  108412. * Class used to generate noise procedural textures
  108413. */
  108414. export class NoiseProceduralTexture extends ProceduralTexture {
  108415. private _time;
  108416. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  108417. brightness: number;
  108418. /** Defines the number of octaves to process */
  108419. octaves: number;
  108420. /** Defines the level of persistence (0.8 by default) */
  108421. persistence: number;
  108422. /** Gets or sets animation speed factor (default is 1) */
  108423. animationSpeedFactor: number;
  108424. /**
  108425. * Creates a new NoiseProceduralTexture
  108426. * @param name defines the name fo the texture
  108427. * @param size defines the size of the texture (default is 256)
  108428. * @param scene defines the hosting scene
  108429. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  108430. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  108431. */
  108432. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  108433. private _updateShaderUniforms;
  108434. protected _getDefines(): string;
  108435. /** Generate the current state of the procedural texture */
  108436. render(useCameraPostProcess?: boolean): void;
  108437. /**
  108438. * Serializes this noise procedural texture
  108439. * @returns a serialized noise procedural texture object
  108440. */
  108441. serialize(): any;
  108442. /**
  108443. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  108444. * @param parsedTexture defines parsed texture data
  108445. * @param scene defines the current scene
  108446. * @param rootUrl defines the root URL containing noise procedural texture information
  108447. * @returns a parsed NoiseProceduralTexture
  108448. */
  108449. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  108450. }
  108451. }
  108452. declare module BABYLON {
  108453. /**
  108454. * Raw cube texture where the raw buffers are passed in
  108455. */
  108456. export class RawCubeTexture extends CubeTexture {
  108457. /**
  108458. * Creates a cube texture where the raw buffers are passed in.
  108459. * @param scene defines the scene the texture is attached to
  108460. * @param data defines the array of data to use to create each face
  108461. * @param size defines the size of the textures
  108462. * @param format defines the format of the data
  108463. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  108464. * @param generateMipMaps defines if the engine should generate the mip levels
  108465. * @param invertY defines if data must be stored with Y axis inverted
  108466. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  108467. * @param compression defines the compression used (null by default)
  108468. */
  108469. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  108470. /**
  108471. * Updates the raw cube texture.
  108472. * @param data defines the data to store
  108473. * @param format defines the data format
  108474. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  108475. * @param invertY defines if data must be stored with Y axis inverted
  108476. * @param compression defines the compression used (null by default)
  108477. * @param level defines which level of the texture to update
  108478. */
  108479. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  108480. /**
  108481. * Updates a raw cube texture with RGBD encoded data.
  108482. * @param data defines the array of data [mipmap][face] to use to create each face
  108483. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  108484. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  108485. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  108486. * @returns a promsie that resolves when the operation is complete
  108487. */
  108488. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  108489. /**
  108490. * Clones the raw cube texture.
  108491. * @return a new cube texture
  108492. */
  108493. clone(): CubeTexture;
  108494. /** @hidden */
  108495. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  108496. }
  108497. }
  108498. declare module BABYLON {
  108499. /**
  108500. * Class used to store 3D textures containing user data
  108501. */
  108502. export class RawTexture3D extends Texture {
  108503. /** Gets or sets the texture format to use */
  108504. format: number;
  108505. private _engine;
  108506. /**
  108507. * Create a new RawTexture3D
  108508. * @param data defines the data of the texture
  108509. * @param width defines the width of the texture
  108510. * @param height defines the height of the texture
  108511. * @param depth defines the depth of the texture
  108512. * @param format defines the texture format to use
  108513. * @param scene defines the hosting scene
  108514. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  108515. * @param invertY defines if texture must be stored with Y axis inverted
  108516. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  108517. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  108518. */
  108519. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  108520. /** Gets or sets the texture format to use */
  108521. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  108522. /**
  108523. * Update the texture with new data
  108524. * @param data defines the data to store in the texture
  108525. */
  108526. update(data: ArrayBufferView): void;
  108527. }
  108528. }
  108529. declare module BABYLON {
  108530. /**
  108531. * Creates a refraction texture used by refraction channel of the standard material.
  108532. * It is like a mirror but to see through a material.
  108533. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  108534. */
  108535. export class RefractionTexture extends RenderTargetTexture {
  108536. /**
  108537. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  108538. * 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.
  108539. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  108540. */
  108541. refractionPlane: Plane;
  108542. /**
  108543. * Define how deep under the surface we should see.
  108544. */
  108545. depth: number;
  108546. /**
  108547. * Creates a refraction texture used by refraction channel of the standard material.
  108548. * It is like a mirror but to see through a material.
  108549. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  108550. * @param name Define the texture name
  108551. * @param size Define the size of the underlying texture
  108552. * @param scene Define the scene the refraction belongs to
  108553. * @param generateMipMaps Define if we need to generate mips level for the refraction
  108554. */
  108555. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  108556. /**
  108557. * Clone the refraction texture.
  108558. * @returns the cloned texture
  108559. */
  108560. clone(): RefractionTexture;
  108561. /**
  108562. * Serialize the texture to a JSON representation you could use in Parse later on
  108563. * @returns the serialized JSON representation
  108564. */
  108565. serialize(): any;
  108566. }
  108567. }
  108568. declare module BABYLON {
  108569. /**
  108570. * Helper class to push actions to a pool of workers.
  108571. */
  108572. export class WorkerPool implements IDisposable {
  108573. private _workerInfos;
  108574. private _pendingActions;
  108575. /**
  108576. * Constructor
  108577. * @param workers Array of workers to use for actions
  108578. */
  108579. constructor(workers: Array<Worker>);
  108580. /**
  108581. * Terminates all workers and clears any pending actions.
  108582. */
  108583. dispose(): void;
  108584. /**
  108585. * Pushes an action to the worker pool. If all the workers are active, the action will be
  108586. * pended until a worker has completed its action.
  108587. * @param action The action to perform. Call onComplete when the action is complete.
  108588. */
  108589. push(action: (worker: Worker, onComplete: () => void) => void): void;
  108590. private _execute;
  108591. }
  108592. }
  108593. declare module BABYLON {
  108594. /**
  108595. * Configuration for Draco compression
  108596. */
  108597. export interface IDracoCompressionConfiguration {
  108598. /**
  108599. * Configuration for the decoder.
  108600. */
  108601. decoder?: {
  108602. /**
  108603. * The url to the WebAssembly module.
  108604. */
  108605. wasmUrl?: string;
  108606. /**
  108607. * The url to the WebAssembly binary.
  108608. */
  108609. wasmBinaryUrl?: string;
  108610. /**
  108611. * The url to the fallback JavaScript module.
  108612. */
  108613. fallbackUrl?: string;
  108614. };
  108615. }
  108616. /**
  108617. * Draco compression (https://google.github.io/draco/)
  108618. *
  108619. * This class wraps the Draco module.
  108620. *
  108621. * **Encoder**
  108622. *
  108623. * The encoder is not currently implemented.
  108624. *
  108625. * **Decoder**
  108626. *
  108627. * 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.
  108628. *
  108629. * To update the configuration, use the following code:
  108630. * ```javascript
  108631. * DracoCompression.Configuration = {
  108632. * decoder: {
  108633. * wasmUrl: "<url to the WebAssembly library>",
  108634. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  108635. * fallbackUrl: "<url to the fallback JavaScript library>",
  108636. * }
  108637. * };
  108638. * ```
  108639. *
  108640. * 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.
  108641. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  108642. * Use `DracoCompression.DecoderAvailable` to determine if the decoder is available for the current session.
  108643. *
  108644. * To decode Draco compressed data, create a DracoCompression object and call decodeMeshAsync:
  108645. * ```javascript
  108646. * var dracoCompression = new DracoCompression();
  108647. * var vertexData = await dracoCompression.decodeMeshAsync(data, {
  108648. * [VertexBuffer.PositionKind]: 0
  108649. * });
  108650. * ```
  108651. *
  108652. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  108653. */
  108654. export class DracoCompression implements IDisposable {
  108655. private _workerPoolPromise;
  108656. /**
  108657. * The configuration. Defaults to the following urls:
  108658. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  108659. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  108660. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  108661. */
  108662. static Configuration: IDracoCompressionConfiguration;
  108663. /**
  108664. * Returns true if the decoder is available.
  108665. */
  108666. static readonly DecoderAvailable: boolean;
  108667. /**
  108668. * Default number of workers to create when creating the draco compression object.
  108669. */
  108670. static DefaultNumWorkers: number;
  108671. private static GetDefaultNumWorkers;
  108672. /**
  108673. * Constructor
  108674. * @param numWorkers The number of workers for async operations
  108675. */
  108676. constructor(numWorkers?: number);
  108677. /**
  108678. * Stop all async operations and release resources.
  108679. */
  108680. dispose(): void;
  108681. /**
  108682. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  108683. * @returns a promise that resolves when ready
  108684. */
  108685. whenReadyAsync(): Promise<void>;
  108686. /**
  108687. * Decode Draco compressed mesh data to vertex data.
  108688. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  108689. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  108690. * @returns A promise that resolves with the decoded vertex data
  108691. */
  108692. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes: {
  108693. [kind: string]: number;
  108694. }): Promise<VertexData>;
  108695. /**
  108696. * The worker function that gets converted to a blob url to pass into a worker.
  108697. */
  108698. private static _Worker;
  108699. private _loadDecoderWasmBinaryAsync;
  108700. }
  108701. }
  108702. declare module BABYLON {
  108703. /**
  108704. * Class for building Constructive Solid Geometry
  108705. */
  108706. export class CSG {
  108707. private polygons;
  108708. /**
  108709. * The world matrix
  108710. */
  108711. matrix: Matrix;
  108712. /**
  108713. * Stores the position
  108714. */
  108715. position: Vector3;
  108716. /**
  108717. * Stores the rotation
  108718. */
  108719. rotation: Vector3;
  108720. /**
  108721. * Stores the rotation quaternion
  108722. */
  108723. rotationQuaternion: Nullable<Quaternion>;
  108724. /**
  108725. * Stores the scaling vector
  108726. */
  108727. scaling: Vector3;
  108728. /**
  108729. * Convert the Mesh to CSG
  108730. * @param mesh The Mesh to convert to CSG
  108731. * @returns A new CSG from the Mesh
  108732. */
  108733. static FromMesh(mesh: Mesh): CSG;
  108734. /**
  108735. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  108736. * @param polygons Polygons used to construct a CSG solid
  108737. */
  108738. private static FromPolygons;
  108739. /**
  108740. * Clones, or makes a deep copy, of the CSG
  108741. * @returns A new CSG
  108742. */
  108743. clone(): CSG;
  108744. /**
  108745. * Unions this CSG with another CSG
  108746. * @param csg The CSG to union against this CSG
  108747. * @returns The unioned CSG
  108748. */
  108749. union(csg: CSG): CSG;
  108750. /**
  108751. * Unions this CSG with another CSG in place
  108752. * @param csg The CSG to union against this CSG
  108753. */
  108754. unionInPlace(csg: CSG): void;
  108755. /**
  108756. * Subtracts this CSG with another CSG
  108757. * @param csg The CSG to subtract against this CSG
  108758. * @returns A new CSG
  108759. */
  108760. subtract(csg: CSG): CSG;
  108761. /**
  108762. * Subtracts this CSG with another CSG in place
  108763. * @param csg The CSG to subtact against this CSG
  108764. */
  108765. subtractInPlace(csg: CSG): void;
  108766. /**
  108767. * Intersect this CSG with another CSG
  108768. * @param csg The CSG to intersect against this CSG
  108769. * @returns A new CSG
  108770. */
  108771. intersect(csg: CSG): CSG;
  108772. /**
  108773. * Intersects this CSG with another CSG in place
  108774. * @param csg The CSG to intersect against this CSG
  108775. */
  108776. intersectInPlace(csg: CSG): void;
  108777. /**
  108778. * Return a new CSG solid with solid and empty space switched. This solid is
  108779. * not modified.
  108780. * @returns A new CSG solid with solid and empty space switched
  108781. */
  108782. inverse(): CSG;
  108783. /**
  108784. * Inverses the CSG in place
  108785. */
  108786. inverseInPlace(): void;
  108787. /**
  108788. * This is used to keep meshes transformations so they can be restored
  108789. * when we build back a Babylon Mesh
  108790. * NB : All CSG operations are performed in world coordinates
  108791. * @param csg The CSG to copy the transform attributes from
  108792. * @returns This CSG
  108793. */
  108794. copyTransformAttributes(csg: CSG): CSG;
  108795. /**
  108796. * Build Raw mesh from CSG
  108797. * Coordinates here are in world space
  108798. * @param name The name of the mesh geometry
  108799. * @param scene The Scene
  108800. * @param keepSubMeshes Specifies if the submeshes should be kept
  108801. * @returns A new Mesh
  108802. */
  108803. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  108804. /**
  108805. * Build Mesh from CSG taking material and transforms into account
  108806. * @param name The name of the Mesh
  108807. * @param material The material of the Mesh
  108808. * @param scene The Scene
  108809. * @param keepSubMeshes Specifies if submeshes should be kept
  108810. * @returns The new Mesh
  108811. */
  108812. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  108813. }
  108814. }
  108815. declare module BABYLON {
  108816. /**
  108817. * Class used to create a trail following a mesh
  108818. */
  108819. export class TrailMesh extends Mesh {
  108820. private _generator;
  108821. private _autoStart;
  108822. private _running;
  108823. private _diameter;
  108824. private _length;
  108825. private _sectionPolygonPointsCount;
  108826. private _sectionVectors;
  108827. private _sectionNormalVectors;
  108828. private _beforeRenderObserver;
  108829. /**
  108830. * @constructor
  108831. * @param name The value used by scene.getMeshByName() to do a lookup.
  108832. * @param generator The mesh to generate a trail.
  108833. * @param scene The scene to add this mesh to.
  108834. * @param diameter Diameter of trailing mesh. Default is 1.
  108835. * @param length Length of trailing mesh. Default is 60.
  108836. * @param autoStart Automatically start trailing mesh. Default true.
  108837. */
  108838. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  108839. /**
  108840. * "TrailMesh"
  108841. * @returns "TrailMesh"
  108842. */
  108843. getClassName(): string;
  108844. private _createMesh;
  108845. /**
  108846. * Start trailing mesh.
  108847. */
  108848. start(): void;
  108849. /**
  108850. * Stop trailing mesh.
  108851. */
  108852. stop(): void;
  108853. /**
  108854. * Update trailing mesh geometry.
  108855. */
  108856. update(): void;
  108857. /**
  108858. * Returns a new TrailMesh object.
  108859. * @param name is a string, the name given to the new mesh
  108860. * @param newGenerator use new generator object for cloned trail mesh
  108861. * @returns a new mesh
  108862. */
  108863. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  108864. /**
  108865. * Serializes this trail mesh
  108866. * @param serializationObject object to write serialization to
  108867. */
  108868. serialize(serializationObject: any): void;
  108869. /**
  108870. * Parses a serialized trail mesh
  108871. * @param parsedMesh the serialized mesh
  108872. * @param scene the scene to create the trail mesh in
  108873. * @returns the created trail mesh
  108874. */
  108875. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  108876. }
  108877. }
  108878. declare module BABYLON {
  108879. /**
  108880. * Class containing static functions to help procedurally build meshes
  108881. */
  108882. export class TorusKnotBuilder {
  108883. /**
  108884. * Creates a torus knot mesh
  108885. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  108886. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  108887. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  108888. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  108889. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  108890. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  108891. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  108892. * @param name defines the name of the mesh
  108893. * @param options defines the options used to create the mesh
  108894. * @param scene defines the hosting scene
  108895. * @returns the torus knot mesh
  108896. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  108897. */
  108898. static CreateTorusKnot(name: string, options: {
  108899. radius?: number;
  108900. tube?: number;
  108901. radialSegments?: number;
  108902. tubularSegments?: number;
  108903. p?: number;
  108904. q?: number;
  108905. updatable?: boolean;
  108906. sideOrientation?: number;
  108907. frontUVs?: Vector4;
  108908. backUVs?: Vector4;
  108909. }, scene: any): Mesh;
  108910. }
  108911. }
  108912. declare module BABYLON {
  108913. /**
  108914. * Polygon
  108915. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  108916. */
  108917. export class Polygon {
  108918. /**
  108919. * Creates a rectangle
  108920. * @param xmin bottom X coord
  108921. * @param ymin bottom Y coord
  108922. * @param xmax top X coord
  108923. * @param ymax top Y coord
  108924. * @returns points that make the resulting rectation
  108925. */
  108926. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  108927. /**
  108928. * Creates a circle
  108929. * @param radius radius of circle
  108930. * @param cx scale in x
  108931. * @param cy scale in y
  108932. * @param numberOfSides number of sides that make up the circle
  108933. * @returns points that make the resulting circle
  108934. */
  108935. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  108936. /**
  108937. * Creates a polygon from input string
  108938. * @param input Input polygon data
  108939. * @returns the parsed points
  108940. */
  108941. static Parse(input: string): Vector2[];
  108942. /**
  108943. * Starts building a polygon from x and y coordinates
  108944. * @param x x coordinate
  108945. * @param y y coordinate
  108946. * @returns the started path2
  108947. */
  108948. static StartingAt(x: number, y: number): Path2;
  108949. }
  108950. /**
  108951. * Builds a polygon
  108952. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  108953. */
  108954. export class PolygonMeshBuilder {
  108955. private _points;
  108956. private _outlinepoints;
  108957. private _holes;
  108958. private _name;
  108959. private _scene;
  108960. private _epoints;
  108961. private _eholes;
  108962. private _addToepoint;
  108963. /**
  108964. * Babylon reference to the earcut plugin.
  108965. */
  108966. bjsEarcut: any;
  108967. /**
  108968. * Creates a PolygonMeshBuilder
  108969. * @param name name of the builder
  108970. * @param contours Path of the polygon
  108971. * @param scene scene to add to when creating the mesh
  108972. * @param earcutInjection can be used to inject your own earcut reference
  108973. */
  108974. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  108975. /**
  108976. * Adds a whole within the polygon
  108977. * @param hole Array of points defining the hole
  108978. * @returns this
  108979. */
  108980. addHole(hole: Vector2[]): PolygonMeshBuilder;
  108981. /**
  108982. * Creates the polygon
  108983. * @param updatable If the mesh should be updatable
  108984. * @param depth The depth of the mesh created
  108985. * @returns the created mesh
  108986. */
  108987. build(updatable?: boolean, depth?: number): Mesh;
  108988. /**
  108989. * Creates the polygon
  108990. * @param depth The depth of the mesh created
  108991. * @returns the created VertexData
  108992. */
  108993. buildVertexData(depth?: number): VertexData;
  108994. /**
  108995. * Adds a side to the polygon
  108996. * @param positions points that make the polygon
  108997. * @param normals normals of the polygon
  108998. * @param uvs uvs of the polygon
  108999. * @param indices indices of the polygon
  109000. * @param bounds bounds of the polygon
  109001. * @param points points of the polygon
  109002. * @param depth depth of the polygon
  109003. * @param flip flip of the polygon
  109004. */
  109005. private addSide;
  109006. }
  109007. }
  109008. declare module BABYLON {
  109009. /**
  109010. * Class containing static functions to help procedurally build meshes
  109011. */
  109012. export class PolygonBuilder {
  109013. /**
  109014. * Creates a polygon mesh
  109015. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  109016. * * 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
  109017. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  109018. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109019. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  109020. * * Remember you can only change the shape positions, not their number when updating a polygon
  109021. * @param name defines the name of the mesh
  109022. * @param options defines the options used to create the mesh
  109023. * @param scene defines the hosting scene
  109024. * @param earcutInjection can be used to inject your own earcut reference
  109025. * @returns the polygon mesh
  109026. */
  109027. static CreatePolygon(name: string, options: {
  109028. shape: Vector3[];
  109029. holes?: Vector3[][];
  109030. depth?: number;
  109031. faceUV?: Vector4[];
  109032. faceColors?: Color4[];
  109033. updatable?: boolean;
  109034. sideOrientation?: number;
  109035. frontUVs?: Vector4;
  109036. backUVs?: Vector4;
  109037. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  109038. /**
  109039. * Creates an extruded polygon mesh, with depth in the Y direction.
  109040. * * 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)
  109041. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  109042. * @param name defines the name of the mesh
  109043. * @param options defines the options used to create the mesh
  109044. * @param scene defines the hosting scene
  109045. * @param earcutInjection can be used to inject your own earcut reference
  109046. * @returns the polygon mesh
  109047. */
  109048. static ExtrudePolygon(name: string, options: {
  109049. shape: Vector3[];
  109050. holes?: Vector3[][];
  109051. depth?: number;
  109052. faceUV?: Vector4[];
  109053. faceColors?: Color4[];
  109054. updatable?: boolean;
  109055. sideOrientation?: number;
  109056. frontUVs?: Vector4;
  109057. backUVs?: Vector4;
  109058. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  109059. }
  109060. }
  109061. declare module BABYLON {
  109062. /**
  109063. * Class containing static functions to help procedurally build meshes
  109064. */
  109065. export class LatheBuilder {
  109066. /**
  109067. * Creates lathe mesh.
  109068. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  109069. * * 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
  109070. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  109071. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  109072. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  109073. * * 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
  109074. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  109075. * * 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
  109076. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  109077. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109078. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  109079. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109080. * @param name defines the name of the mesh
  109081. * @param options defines the options used to create the mesh
  109082. * @param scene defines the hosting scene
  109083. * @returns the lathe mesh
  109084. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  109085. */
  109086. static CreateLathe(name: string, options: {
  109087. shape: Vector3[];
  109088. radius?: number;
  109089. tessellation?: number;
  109090. clip?: number;
  109091. arc?: number;
  109092. closed?: boolean;
  109093. updatable?: boolean;
  109094. sideOrientation?: number;
  109095. frontUVs?: Vector4;
  109096. backUVs?: Vector4;
  109097. cap?: number;
  109098. invertUV?: boolean;
  109099. }, scene?: Nullable<Scene>): Mesh;
  109100. }
  109101. }
  109102. declare module BABYLON {
  109103. /**
  109104. * Class containing static functions to help procedurally build meshes
  109105. */
  109106. export class TubeBuilder {
  109107. /**
  109108. * Creates a tube mesh.
  109109. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  109110. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  109111. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  109112. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  109113. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  109114. * * 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)
  109115. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  109116. * * 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
  109117. * * 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
  109118. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  109119. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109120. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  109121. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109122. * @param name defines the name of the mesh
  109123. * @param options defines the options used to create the mesh
  109124. * @param scene defines the hosting scene
  109125. * @returns the tube mesh
  109126. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  109127. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  109128. */
  109129. static CreateTube(name: string, options: {
  109130. path: Vector3[];
  109131. radius?: number;
  109132. tessellation?: number;
  109133. radiusFunction?: {
  109134. (i: number, distance: number): number;
  109135. };
  109136. cap?: number;
  109137. arc?: number;
  109138. updatable?: boolean;
  109139. sideOrientation?: number;
  109140. frontUVs?: Vector4;
  109141. backUVs?: Vector4;
  109142. instance?: Mesh;
  109143. invertUV?: boolean;
  109144. }, scene?: Nullable<Scene>): Mesh;
  109145. }
  109146. }
  109147. declare module BABYLON {
  109148. /**
  109149. * Class containing static functions to help procedurally build meshes
  109150. */
  109151. export class IcoSphereBuilder {
  109152. /**
  109153. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  109154. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  109155. * * 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`)
  109156. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  109157. * * 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
  109158. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  109159. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109160. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109161. * @param name defines the name of the mesh
  109162. * @param options defines the options used to create the mesh
  109163. * @param scene defines the hosting scene
  109164. * @returns the icosahedron mesh
  109165. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  109166. */
  109167. static CreateIcoSphere(name: string, options: {
  109168. radius?: number;
  109169. radiusX?: number;
  109170. radiusY?: number;
  109171. radiusZ?: number;
  109172. flat?: boolean;
  109173. subdivisions?: number;
  109174. sideOrientation?: number;
  109175. frontUVs?: Vector4;
  109176. backUVs?: Vector4;
  109177. updatable?: boolean;
  109178. }, scene?: Nullable<Scene>): Mesh;
  109179. }
  109180. }
  109181. declare module BABYLON {
  109182. /**
  109183. * Class containing static functions to help procedurally build meshes
  109184. */
  109185. export class DecalBuilder {
  109186. /**
  109187. * Creates a decal mesh.
  109188. * 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
  109189. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  109190. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  109191. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  109192. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  109193. * @param name defines the name of the mesh
  109194. * @param sourceMesh defines the mesh where the decal must be applied
  109195. * @param options defines the options used to create the mesh
  109196. * @param scene defines the hosting scene
  109197. * @returns the decal mesh
  109198. * @see https://doc.babylonjs.com/how_to/decals
  109199. */
  109200. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  109201. position?: Vector3;
  109202. normal?: Vector3;
  109203. size?: Vector3;
  109204. angle?: number;
  109205. }): Mesh;
  109206. }
  109207. }
  109208. declare module BABYLON {
  109209. /**
  109210. * Class containing static functions to help procedurally build meshes
  109211. */
  109212. export class MeshBuilder {
  109213. /**
  109214. * Creates a box mesh
  109215. * * The parameter `size` sets the size (float) of each box side (default 1)
  109216. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  109217. * * 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)
  109218. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  109219. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  109220. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109221. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109222. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  109223. * @param name defines the name of the mesh
  109224. * @param options defines the options used to create the mesh
  109225. * @param scene defines the hosting scene
  109226. * @returns the box mesh
  109227. */
  109228. static CreateBox(name: string, options: {
  109229. size?: number;
  109230. width?: number;
  109231. height?: number;
  109232. depth?: number;
  109233. faceUV?: Vector4[];
  109234. faceColors?: Color4[];
  109235. sideOrientation?: number;
  109236. frontUVs?: Vector4;
  109237. backUVs?: Vector4;
  109238. updatable?: boolean;
  109239. }, scene?: Nullable<Scene>): Mesh;
  109240. /**
  109241. * Creates a sphere mesh
  109242. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  109243. * * 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`)
  109244. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  109245. * * 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
  109246. * * 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)
  109247. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  109248. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109249. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109250. * @param name defines the name of the mesh
  109251. * @param options defines the options used to create the mesh
  109252. * @param scene defines the hosting scene
  109253. * @returns the sphere mesh
  109254. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  109255. */
  109256. static CreateSphere(name: string, options: {
  109257. segments?: number;
  109258. diameter?: number;
  109259. diameterX?: number;
  109260. diameterY?: number;
  109261. diameterZ?: number;
  109262. arc?: number;
  109263. slice?: number;
  109264. sideOrientation?: number;
  109265. frontUVs?: Vector4;
  109266. backUVs?: Vector4;
  109267. updatable?: boolean;
  109268. }, scene?: Nullable<Scene>): Mesh;
  109269. /**
  109270. * Creates a plane polygonal mesh. By default, this is a disc
  109271. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  109272. * * 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
  109273. * * 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
  109274. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  109275. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109276. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109277. * @param name defines the name of the mesh
  109278. * @param options defines the options used to create the mesh
  109279. * @param scene defines the hosting scene
  109280. * @returns the plane polygonal mesh
  109281. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  109282. */
  109283. static CreateDisc(name: string, options: {
  109284. radius?: number;
  109285. tessellation?: number;
  109286. arc?: number;
  109287. updatable?: boolean;
  109288. sideOrientation?: number;
  109289. frontUVs?: Vector4;
  109290. backUVs?: Vector4;
  109291. }, scene?: Nullable<Scene>): Mesh;
  109292. /**
  109293. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  109294. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  109295. * * 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`)
  109296. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  109297. * * 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
  109298. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  109299. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109300. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109301. * @param name defines the name of the mesh
  109302. * @param options defines the options used to create the mesh
  109303. * @param scene defines the hosting scene
  109304. * @returns the icosahedron mesh
  109305. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  109306. */
  109307. static CreateIcoSphere(name: string, options: {
  109308. radius?: number;
  109309. radiusX?: number;
  109310. radiusY?: number;
  109311. radiusZ?: number;
  109312. flat?: boolean;
  109313. subdivisions?: number;
  109314. sideOrientation?: number;
  109315. frontUVs?: Vector4;
  109316. backUVs?: Vector4;
  109317. updatable?: boolean;
  109318. }, scene?: Nullable<Scene>): Mesh;
  109319. /**
  109320. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  109321. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  109322. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  109323. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  109324. * * 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
  109325. * * 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
  109326. * * 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
  109327. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  109328. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109329. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  109330. * * 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
  109331. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  109332. * * 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
  109333. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  109334. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109335. * @param name defines the name of the mesh
  109336. * @param options defines the options used to create the mesh
  109337. * @param scene defines the hosting scene
  109338. * @returns the ribbon mesh
  109339. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  109340. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  109341. */
  109342. static CreateRibbon(name: string, options: {
  109343. pathArray: Vector3[][];
  109344. closeArray?: boolean;
  109345. closePath?: boolean;
  109346. offset?: number;
  109347. updatable?: boolean;
  109348. sideOrientation?: number;
  109349. frontUVs?: Vector4;
  109350. backUVs?: Vector4;
  109351. instance?: Mesh;
  109352. invertUV?: boolean;
  109353. uvs?: Vector2[];
  109354. colors?: Color4[];
  109355. }, scene?: Nullable<Scene>): Mesh;
  109356. /**
  109357. * Creates a cylinder or a cone mesh
  109358. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  109359. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  109360. * * 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.
  109361. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  109362. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  109363. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  109364. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  109365. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  109366. * * 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).
  109367. * * 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
  109368. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  109369. * * 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
  109370. * * 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.
  109371. * * If `enclose` is false, a ring surface is one element.
  109372. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  109373. * * 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
  109374. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  109375. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109376. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  109377. * @param name defines the name of the mesh
  109378. * @param options defines the options used to create the mesh
  109379. * @param scene defines the hosting scene
  109380. * @returns the cylinder mesh
  109381. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  109382. */
  109383. static CreateCylinder(name: string, options: {
  109384. height?: number;
  109385. diameterTop?: number;
  109386. diameterBottom?: number;
  109387. diameter?: number;
  109388. tessellation?: number;
  109389. subdivisions?: number;
  109390. arc?: number;
  109391. faceColors?: Color4[];
  109392. faceUV?: Vector4[];
  109393. updatable?: boolean;
  109394. hasRings?: boolean;
  109395. enclose?: boolean;
  109396. sideOrientation?: number;
  109397. frontUVs?: Vector4;
  109398. backUVs?: Vector4;
  109399. }, scene?: Nullable<Scene>): Mesh;
  109400. /**
  109401. * Creates a torus mesh
  109402. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  109403. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  109404. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  109405. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  109406. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109407. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  109408. * @param name defines the name of the mesh
  109409. * @param options defines the options used to create the mesh
  109410. * @param scene defines the hosting scene
  109411. * @returns the torus mesh
  109412. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  109413. */
  109414. static CreateTorus(name: string, options: {
  109415. diameter?: number;
  109416. thickness?: number;
  109417. tessellation?: number;
  109418. updatable?: boolean;
  109419. sideOrientation?: number;
  109420. frontUVs?: Vector4;
  109421. backUVs?: Vector4;
  109422. }, scene?: Nullable<Scene>): Mesh;
  109423. /**
  109424. * Creates a torus knot mesh
  109425. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  109426. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  109427. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  109428. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  109429. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  109430. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109431. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  109432. * @param name defines the name of the mesh
  109433. * @param options defines the options used to create the mesh
  109434. * @param scene defines the hosting scene
  109435. * @returns the torus knot mesh
  109436. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  109437. */
  109438. static CreateTorusKnot(name: string, options: {
  109439. radius?: number;
  109440. tube?: number;
  109441. radialSegments?: number;
  109442. tubularSegments?: number;
  109443. p?: number;
  109444. q?: number;
  109445. updatable?: boolean;
  109446. sideOrientation?: number;
  109447. frontUVs?: Vector4;
  109448. backUVs?: Vector4;
  109449. }, scene?: Nullable<Scene>): Mesh;
  109450. /**
  109451. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  109452. * * 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
  109453. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  109454. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  109455. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  109456. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  109457. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  109458. * * 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
  109459. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  109460. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109461. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  109462. * @param name defines the name of the new line system
  109463. * @param options defines the options used to create the line system
  109464. * @param scene defines the hosting scene
  109465. * @returns a new line system mesh
  109466. */
  109467. static CreateLineSystem(name: string, options: {
  109468. lines: Vector3[][];
  109469. updatable?: boolean;
  109470. instance?: Nullable<LinesMesh>;
  109471. colors?: Nullable<Color4[][]>;
  109472. useVertexAlpha?: boolean;
  109473. }, scene: Nullable<Scene>): LinesMesh;
  109474. /**
  109475. * Creates a line mesh
  109476. * 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
  109477. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  109478. * * The parameter `points` is an array successive Vector3
  109479. * * 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
  109480. * * The optional parameter `colors` is an array of successive Color4, one per line point
  109481. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  109482. * * When updating an instance, remember that only point positions can change, not the number of points
  109483. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109484. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  109485. * @param name defines the name of the new line system
  109486. * @param options defines the options used to create the line system
  109487. * @param scene defines the hosting scene
  109488. * @returns a new line mesh
  109489. */
  109490. static CreateLines(name: string, options: {
  109491. points: Vector3[];
  109492. updatable?: boolean;
  109493. instance?: Nullable<LinesMesh>;
  109494. colors?: Color4[];
  109495. useVertexAlpha?: boolean;
  109496. }, scene?: Nullable<Scene>): LinesMesh;
  109497. /**
  109498. * Creates a dashed line mesh
  109499. * * 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
  109500. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  109501. * * The parameter `points` is an array successive Vector3
  109502. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  109503. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  109504. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  109505. * * 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
  109506. * * When updating an instance, remember that only point positions can change, not the number of points
  109507. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109508. * @param name defines the name of the mesh
  109509. * @param options defines the options used to create the mesh
  109510. * @param scene defines the hosting scene
  109511. * @returns the dashed line mesh
  109512. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  109513. */
  109514. static CreateDashedLines(name: string, options: {
  109515. points: Vector3[];
  109516. dashSize?: number;
  109517. gapSize?: number;
  109518. dashNb?: number;
  109519. updatable?: boolean;
  109520. instance?: LinesMesh;
  109521. }, scene?: Nullable<Scene>): LinesMesh;
  109522. /**
  109523. * 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.
  109524. * * 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.
  109525. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  109526. * * 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.
  109527. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  109528. * * 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
  109529. * * 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
  109530. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  109531. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  109532. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109533. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  109534. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  109535. * @param name defines the name of the mesh
  109536. * @param options defines the options used to create the mesh
  109537. * @param scene defines the hosting scene
  109538. * @returns the extruded shape mesh
  109539. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  109540. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  109541. */
  109542. static ExtrudeShape(name: string, options: {
  109543. shape: Vector3[];
  109544. path: Vector3[];
  109545. scale?: number;
  109546. rotation?: number;
  109547. cap?: number;
  109548. updatable?: boolean;
  109549. sideOrientation?: number;
  109550. frontUVs?: Vector4;
  109551. backUVs?: Vector4;
  109552. instance?: Mesh;
  109553. invertUV?: boolean;
  109554. }, scene?: Nullable<Scene>): Mesh;
  109555. /**
  109556. * Creates an custom extruded shape mesh.
  109557. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  109558. * * 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.
  109559. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  109560. * * 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
  109561. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  109562. * * 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
  109563. * * It must returns a float value that will be the scale value applied to the shape on each path point
  109564. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  109565. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  109566. * * 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
  109567. * * 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
  109568. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  109569. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  109570. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109571. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  109572. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109573. * @param name defines the name of the mesh
  109574. * @param options defines the options used to create the mesh
  109575. * @param scene defines the hosting scene
  109576. * @returns the custom extruded shape mesh
  109577. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  109578. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  109579. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  109580. */
  109581. static ExtrudeShapeCustom(name: string, options: {
  109582. shape: Vector3[];
  109583. path: Vector3[];
  109584. scaleFunction?: any;
  109585. rotationFunction?: any;
  109586. ribbonCloseArray?: boolean;
  109587. ribbonClosePath?: boolean;
  109588. cap?: number;
  109589. updatable?: boolean;
  109590. sideOrientation?: number;
  109591. frontUVs?: Vector4;
  109592. backUVs?: Vector4;
  109593. instance?: Mesh;
  109594. invertUV?: boolean;
  109595. }, scene?: Nullable<Scene>): Mesh;
  109596. /**
  109597. * Creates lathe mesh.
  109598. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  109599. * * 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
  109600. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  109601. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  109602. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  109603. * * 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
  109604. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  109605. * * 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
  109606. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  109607. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109608. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  109609. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109610. * @param name defines the name of the mesh
  109611. * @param options defines the options used to create the mesh
  109612. * @param scene defines the hosting scene
  109613. * @returns the lathe mesh
  109614. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  109615. */
  109616. static CreateLathe(name: string, options: {
  109617. shape: Vector3[];
  109618. radius?: number;
  109619. tessellation?: number;
  109620. clip?: number;
  109621. arc?: number;
  109622. closed?: boolean;
  109623. updatable?: boolean;
  109624. sideOrientation?: number;
  109625. frontUVs?: Vector4;
  109626. backUVs?: Vector4;
  109627. cap?: number;
  109628. invertUV?: boolean;
  109629. }, scene?: Nullable<Scene>): Mesh;
  109630. /**
  109631. * Creates a plane mesh
  109632. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  109633. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  109634. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  109635. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  109636. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109637. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109638. * @param name defines the name of the mesh
  109639. * @param options defines the options used to create the mesh
  109640. * @param scene defines the hosting scene
  109641. * @returns the plane mesh
  109642. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  109643. */
  109644. static CreatePlane(name: string, options: {
  109645. size?: number;
  109646. width?: number;
  109647. height?: number;
  109648. sideOrientation?: number;
  109649. frontUVs?: Vector4;
  109650. backUVs?: Vector4;
  109651. updatable?: boolean;
  109652. sourcePlane?: Plane;
  109653. }, scene?: Nullable<Scene>): Mesh;
  109654. /**
  109655. * Creates a ground mesh
  109656. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  109657. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  109658. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109659. * @param name defines the name of the mesh
  109660. * @param options defines the options used to create the mesh
  109661. * @param scene defines the hosting scene
  109662. * @returns the ground mesh
  109663. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  109664. */
  109665. static CreateGround(name: string, options: {
  109666. width?: number;
  109667. height?: number;
  109668. subdivisions?: number;
  109669. subdivisionsX?: number;
  109670. subdivisionsY?: number;
  109671. updatable?: boolean;
  109672. }, scene?: Nullable<Scene>): Mesh;
  109673. /**
  109674. * Creates a tiled ground mesh
  109675. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  109676. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  109677. * * 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
  109678. * * 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
  109679. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  109680. * @param name defines the name of the mesh
  109681. * @param options defines the options used to create the mesh
  109682. * @param scene defines the hosting scene
  109683. * @returns the tiled ground mesh
  109684. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  109685. */
  109686. static CreateTiledGround(name: string, options: {
  109687. xmin: number;
  109688. zmin: number;
  109689. xmax: number;
  109690. zmax: number;
  109691. subdivisions?: {
  109692. w: number;
  109693. h: number;
  109694. };
  109695. precision?: {
  109696. w: number;
  109697. h: number;
  109698. };
  109699. updatable?: boolean;
  109700. }, scene?: Nullable<Scene>): Mesh;
  109701. /**
  109702. * Creates a ground mesh from a height map
  109703. * * The parameter `url` sets the URL of the height map image resource.
  109704. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  109705. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  109706. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  109707. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  109708. * * 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.
  109709. * * 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).
  109710. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  109711. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  109712. * @param name defines the name of the mesh
  109713. * @param url defines the url to the height map
  109714. * @param options defines the options used to create the mesh
  109715. * @param scene defines the hosting scene
  109716. * @returns the ground mesh
  109717. * @see https://doc.babylonjs.com/babylon101/height_map
  109718. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  109719. */
  109720. static CreateGroundFromHeightMap(name: string, url: string, options: {
  109721. width?: number;
  109722. height?: number;
  109723. subdivisions?: number;
  109724. minHeight?: number;
  109725. maxHeight?: number;
  109726. colorFilter?: Color3;
  109727. alphaFilter?: number;
  109728. updatable?: boolean;
  109729. onReady?: (mesh: GroundMesh) => void;
  109730. }, scene?: Nullable<Scene>): GroundMesh;
  109731. /**
  109732. * Creates a polygon mesh
  109733. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  109734. * * 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
  109735. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  109736. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109737. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  109738. * * Remember you can only change the shape positions, not their number when updating a polygon
  109739. * @param name defines the name of the mesh
  109740. * @param options defines the options used to create the mesh
  109741. * @param scene defines the hosting scene
  109742. * @param earcutInjection can be used to inject your own earcut reference
  109743. * @returns the polygon mesh
  109744. */
  109745. static CreatePolygon(name: string, options: {
  109746. shape: Vector3[];
  109747. holes?: Vector3[][];
  109748. depth?: number;
  109749. faceUV?: Vector4[];
  109750. faceColors?: Color4[];
  109751. updatable?: boolean;
  109752. sideOrientation?: number;
  109753. frontUVs?: Vector4;
  109754. backUVs?: Vector4;
  109755. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  109756. /**
  109757. * Creates an extruded polygon mesh, with depth in the Y direction.
  109758. * * 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)
  109759. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  109760. * @param name defines the name of the mesh
  109761. * @param options defines the options used to create the mesh
  109762. * @param scene defines the hosting scene
  109763. * @param earcutInjection can be used to inject your own earcut reference
  109764. * @returns the polygon mesh
  109765. */
  109766. static ExtrudePolygon(name: string, options: {
  109767. shape: Vector3[];
  109768. holes?: Vector3[][];
  109769. depth?: number;
  109770. faceUV?: Vector4[];
  109771. faceColors?: Color4[];
  109772. updatable?: boolean;
  109773. sideOrientation?: number;
  109774. frontUVs?: Vector4;
  109775. backUVs?: Vector4;
  109776. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  109777. /**
  109778. * Creates a tube mesh.
  109779. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  109780. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  109781. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  109782. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  109783. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  109784. * * 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)
  109785. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  109786. * * 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
  109787. * * 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
  109788. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  109789. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109790. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  109791. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109792. * @param name defines the name of the mesh
  109793. * @param options defines the options used to create the mesh
  109794. * @param scene defines the hosting scene
  109795. * @returns the tube mesh
  109796. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  109797. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  109798. */
  109799. static CreateTube(name: string, options: {
  109800. path: Vector3[];
  109801. radius?: number;
  109802. tessellation?: number;
  109803. radiusFunction?: {
  109804. (i: number, distance: number): number;
  109805. };
  109806. cap?: number;
  109807. arc?: number;
  109808. updatable?: boolean;
  109809. sideOrientation?: number;
  109810. frontUVs?: Vector4;
  109811. backUVs?: Vector4;
  109812. instance?: Mesh;
  109813. invertUV?: boolean;
  109814. }, scene?: Nullable<Scene>): Mesh;
  109815. /**
  109816. * Creates a polyhedron mesh
  109817. * * 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
  109818. * * The parameter `size` (positive float, default 1) sets the polygon size
  109819. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  109820. * * 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`
  109821. * * 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
  109822. * * 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)`)
  109823. * * 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
  109824. * * 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
  109825. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  109826. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109827. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109828. * @param name defines the name of the mesh
  109829. * @param options defines the options used to create the mesh
  109830. * @param scene defines the hosting scene
  109831. * @returns the polyhedron mesh
  109832. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  109833. */
  109834. static CreatePolyhedron(name: string, options: {
  109835. type?: number;
  109836. size?: number;
  109837. sizeX?: number;
  109838. sizeY?: number;
  109839. sizeZ?: number;
  109840. custom?: any;
  109841. faceUV?: Vector4[];
  109842. faceColors?: Color4[];
  109843. flat?: boolean;
  109844. updatable?: boolean;
  109845. sideOrientation?: number;
  109846. frontUVs?: Vector4;
  109847. backUVs?: Vector4;
  109848. }, scene?: Nullable<Scene>): Mesh;
  109849. /**
  109850. * Creates a decal mesh.
  109851. * 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
  109852. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  109853. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  109854. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  109855. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  109856. * @param name defines the name of the mesh
  109857. * @param sourceMesh defines the mesh where the decal must be applied
  109858. * @param options defines the options used to create the mesh
  109859. * @param scene defines the hosting scene
  109860. * @returns the decal mesh
  109861. * @see https://doc.babylonjs.com/how_to/decals
  109862. */
  109863. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  109864. position?: Vector3;
  109865. normal?: Vector3;
  109866. size?: Vector3;
  109867. angle?: number;
  109868. }): Mesh;
  109869. }
  109870. }
  109871. declare module BABYLON {
  109872. /**
  109873. * A simplifier interface for future simplification implementations
  109874. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  109875. */
  109876. export interface ISimplifier {
  109877. /**
  109878. * Simplification of a given mesh according to the given settings.
  109879. * Since this requires computation, it is assumed that the function runs async.
  109880. * @param settings The settings of the simplification, including quality and distance
  109881. * @param successCallback A callback that will be called after the mesh was simplified.
  109882. * @param errorCallback in case of an error, this callback will be called. optional.
  109883. */
  109884. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  109885. }
  109886. /**
  109887. * Expected simplification settings.
  109888. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  109889. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  109890. */
  109891. export interface ISimplificationSettings {
  109892. /**
  109893. * Gets or sets the expected quality
  109894. */
  109895. quality: number;
  109896. /**
  109897. * Gets or sets the distance when this optimized version should be used
  109898. */
  109899. distance: number;
  109900. /**
  109901. * Gets an already optimized mesh
  109902. */
  109903. optimizeMesh?: boolean;
  109904. }
  109905. /**
  109906. * Class used to specify simplification options
  109907. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  109908. */
  109909. export class SimplificationSettings implements ISimplificationSettings {
  109910. /** expected quality */
  109911. quality: number;
  109912. /** distance when this optimized version should be used */
  109913. distance: number;
  109914. /** already optimized mesh */
  109915. optimizeMesh?: boolean | undefined;
  109916. /**
  109917. * Creates a SimplificationSettings
  109918. * @param quality expected quality
  109919. * @param distance distance when this optimized version should be used
  109920. * @param optimizeMesh already optimized mesh
  109921. */
  109922. constructor(
  109923. /** expected quality */
  109924. quality: number,
  109925. /** distance when this optimized version should be used */
  109926. distance: number,
  109927. /** already optimized mesh */
  109928. optimizeMesh?: boolean | undefined);
  109929. }
  109930. /**
  109931. * Interface used to define a simplification task
  109932. */
  109933. export interface ISimplificationTask {
  109934. /**
  109935. * Array of settings
  109936. */
  109937. settings: Array<ISimplificationSettings>;
  109938. /**
  109939. * Simplification type
  109940. */
  109941. simplificationType: SimplificationType;
  109942. /**
  109943. * Mesh to simplify
  109944. */
  109945. mesh: Mesh;
  109946. /**
  109947. * Callback called on success
  109948. */
  109949. successCallback?: () => void;
  109950. /**
  109951. * Defines if parallel processing can be used
  109952. */
  109953. parallelProcessing: boolean;
  109954. }
  109955. /**
  109956. * Queue used to order the simplification tasks
  109957. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  109958. */
  109959. export class SimplificationQueue {
  109960. private _simplificationArray;
  109961. /**
  109962. * Gets a boolean indicating that the process is still running
  109963. */
  109964. running: boolean;
  109965. /**
  109966. * Creates a new queue
  109967. */
  109968. constructor();
  109969. /**
  109970. * Adds a new simplification task
  109971. * @param task defines a task to add
  109972. */
  109973. addTask(task: ISimplificationTask): void;
  109974. /**
  109975. * Execute next task
  109976. */
  109977. executeNext(): void;
  109978. /**
  109979. * Execute a simplification task
  109980. * @param task defines the task to run
  109981. */
  109982. runSimplification(task: ISimplificationTask): void;
  109983. private getSimplifier;
  109984. }
  109985. /**
  109986. * The implemented types of simplification
  109987. * At the moment only Quadratic Error Decimation is implemented
  109988. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  109989. */
  109990. export enum SimplificationType {
  109991. /** Quadratic error decimation */
  109992. QUADRATIC = 0
  109993. }
  109994. }
  109995. declare module BABYLON {
  109996. interface Scene {
  109997. /** @hidden (Backing field) */
  109998. _simplificationQueue: SimplificationQueue;
  109999. /**
  110000. * Gets or sets the simplification queue attached to the scene
  110001. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  110002. */
  110003. simplificationQueue: SimplificationQueue;
  110004. }
  110005. interface Mesh {
  110006. /**
  110007. * Simplify the mesh according to the given array of settings.
  110008. * Function will return immediately and will simplify async
  110009. * @param settings a collection of simplification settings
  110010. * @param parallelProcessing should all levels calculate parallel or one after the other
  110011. * @param simplificationType the type of simplification to run
  110012. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  110013. * @returns the current mesh
  110014. */
  110015. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  110016. }
  110017. /**
  110018. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  110019. * created in a scene
  110020. */
  110021. export class SimplicationQueueSceneComponent implements ISceneComponent {
  110022. /**
  110023. * The component name helpfull to identify the component in the list of scene components.
  110024. */
  110025. readonly name: string;
  110026. /**
  110027. * The scene the component belongs to.
  110028. */
  110029. scene: Scene;
  110030. /**
  110031. * Creates a new instance of the component for the given scene
  110032. * @param scene Defines the scene to register the component in
  110033. */
  110034. constructor(scene: Scene);
  110035. /**
  110036. * Registers the component in a given scene
  110037. */
  110038. register(): void;
  110039. /**
  110040. * Rebuilds the elements related to this component in case of
  110041. * context lost for instance.
  110042. */
  110043. rebuild(): void;
  110044. /**
  110045. * Disposes the component and the associated ressources
  110046. */
  110047. dispose(): void;
  110048. private _beforeCameraUpdate;
  110049. }
  110050. }
  110051. declare module BABYLON {
  110052. /**
  110053. * Class used to enable access to IndexedDB
  110054. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  110055. */
  110056. export class Database implements IOfflineProvider {
  110057. private _callbackManifestChecked;
  110058. private _currentSceneUrl;
  110059. private _db;
  110060. private _enableSceneOffline;
  110061. private _enableTexturesOffline;
  110062. private _manifestVersionFound;
  110063. private _mustUpdateRessources;
  110064. private _hasReachedQuota;
  110065. private _isSupported;
  110066. private _idbFactory;
  110067. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  110068. private static IsUASupportingBlobStorage;
  110069. /**
  110070. * Gets a boolean indicating if Database storate is enabled (off by default)
  110071. */
  110072. static IDBStorageEnabled: boolean;
  110073. /**
  110074. * Gets a boolean indicating if scene must be saved in the database
  110075. */
  110076. readonly enableSceneOffline: boolean;
  110077. /**
  110078. * Gets a boolean indicating if textures must be saved in the database
  110079. */
  110080. readonly enableTexturesOffline: boolean;
  110081. /**
  110082. * Creates a new Database
  110083. * @param urlToScene defines the url to load the scene
  110084. * @param callbackManifestChecked defines the callback to use when manifest is checked
  110085. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  110086. */
  110087. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  110088. private static _ParseURL;
  110089. private static _ReturnFullUrlLocation;
  110090. private _checkManifestFile;
  110091. /**
  110092. * Open the database and make it available
  110093. * @param successCallback defines the callback to call on success
  110094. * @param errorCallback defines the callback to call on error
  110095. */
  110096. open(successCallback: () => void, errorCallback: () => void): void;
  110097. /**
  110098. * Loads an image from the database
  110099. * @param url defines the url to load from
  110100. * @param image defines the target DOM image
  110101. */
  110102. loadImage(url: string, image: HTMLImageElement): void;
  110103. private _loadImageFromDBAsync;
  110104. private _saveImageIntoDBAsync;
  110105. private _checkVersionFromDB;
  110106. private _loadVersionFromDBAsync;
  110107. private _saveVersionIntoDBAsync;
  110108. /**
  110109. * Loads a file from database
  110110. * @param url defines the URL to load from
  110111. * @param sceneLoaded defines a callback to call on success
  110112. * @param progressCallBack defines a callback to call when progress changed
  110113. * @param errorCallback defines a callback to call on error
  110114. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  110115. */
  110116. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  110117. private _loadFileAsync;
  110118. private _saveFileAsync;
  110119. /**
  110120. * Validates if xhr data is correct
  110121. * @param xhr defines the request to validate
  110122. * @param dataType defines the expected data type
  110123. * @returns true if data is correct
  110124. */
  110125. private static _ValidateXHRData;
  110126. }
  110127. }
  110128. declare module BABYLON {
  110129. /** @hidden */
  110130. export var gpuUpdateParticlesPixelShader: {
  110131. name: string;
  110132. shader: string;
  110133. };
  110134. }
  110135. declare module BABYLON {
  110136. /** @hidden */
  110137. export var gpuUpdateParticlesVertexShader: {
  110138. name: string;
  110139. shader: string;
  110140. };
  110141. }
  110142. declare module BABYLON {
  110143. /** @hidden */
  110144. export var clipPlaneFragmentDeclaration2: {
  110145. name: string;
  110146. shader: string;
  110147. };
  110148. }
  110149. declare module BABYLON {
  110150. /** @hidden */
  110151. export var gpuRenderParticlesPixelShader: {
  110152. name: string;
  110153. shader: string;
  110154. };
  110155. }
  110156. declare module BABYLON {
  110157. /** @hidden */
  110158. export var clipPlaneVertexDeclaration2: {
  110159. name: string;
  110160. shader: string;
  110161. };
  110162. }
  110163. declare module BABYLON {
  110164. /** @hidden */
  110165. export var gpuRenderParticlesVertexShader: {
  110166. name: string;
  110167. shader: string;
  110168. };
  110169. }
  110170. declare module BABYLON {
  110171. /**
  110172. * This represents a GPU particle system in Babylon
  110173. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  110174. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  110175. */
  110176. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  110177. /**
  110178. * The layer mask we are rendering the particles through.
  110179. */
  110180. layerMask: number;
  110181. private _capacity;
  110182. private _activeCount;
  110183. private _currentActiveCount;
  110184. private _accumulatedCount;
  110185. private _renderEffect;
  110186. private _updateEffect;
  110187. private _buffer0;
  110188. private _buffer1;
  110189. private _spriteBuffer;
  110190. private _updateVAO;
  110191. private _renderVAO;
  110192. private _targetIndex;
  110193. private _sourceBuffer;
  110194. private _targetBuffer;
  110195. private _engine;
  110196. private _currentRenderId;
  110197. private _started;
  110198. private _stopped;
  110199. private _timeDelta;
  110200. private _randomTexture;
  110201. private _randomTexture2;
  110202. private _attributesStrideSize;
  110203. private _updateEffectOptions;
  110204. private _randomTextureSize;
  110205. private _actualFrame;
  110206. private readonly _rawTextureWidth;
  110207. /**
  110208. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  110209. */
  110210. static readonly IsSupported: boolean;
  110211. /**
  110212. * An event triggered when the system is disposed.
  110213. */
  110214. onDisposeObservable: Observable<GPUParticleSystem>;
  110215. /**
  110216. * Gets the maximum number of particles active at the same time.
  110217. * @returns The max number of active particles.
  110218. */
  110219. getCapacity(): number;
  110220. /**
  110221. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  110222. * to override the particles.
  110223. */
  110224. forceDepthWrite: boolean;
  110225. /**
  110226. * Gets or set the number of active particles
  110227. */
  110228. activeParticleCount: number;
  110229. private _preWarmDone;
  110230. /**
  110231. * Is this system ready to be used/rendered
  110232. * @return true if the system is ready
  110233. */
  110234. isReady(): boolean;
  110235. /**
  110236. * Gets if the system has been started. (Note: this will still be true after stop is called)
  110237. * @returns True if it has been started, otherwise false.
  110238. */
  110239. isStarted(): boolean;
  110240. /**
  110241. * Starts the particle system and begins to emit
  110242. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  110243. */
  110244. start(delay?: number): void;
  110245. /**
  110246. * Stops the particle system.
  110247. */
  110248. stop(): void;
  110249. /**
  110250. * Remove all active particles
  110251. */
  110252. reset(): void;
  110253. /**
  110254. * Returns the string "GPUParticleSystem"
  110255. * @returns a string containing the class name
  110256. */
  110257. getClassName(): string;
  110258. private _colorGradientsTexture;
  110259. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  110260. /**
  110261. * Adds a new color gradient
  110262. * @param gradient defines the gradient to use (between 0 and 1)
  110263. * @param color1 defines the color to affect to the specified gradient
  110264. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  110265. * @returns the current particle system
  110266. */
  110267. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  110268. /**
  110269. * Remove a specific color gradient
  110270. * @param gradient defines the gradient to remove
  110271. * @returns the current particle system
  110272. */
  110273. removeColorGradient(gradient: number): GPUParticleSystem;
  110274. private _angularSpeedGradientsTexture;
  110275. private _sizeGradientsTexture;
  110276. private _velocityGradientsTexture;
  110277. private _limitVelocityGradientsTexture;
  110278. private _dragGradientsTexture;
  110279. private _addFactorGradient;
  110280. /**
  110281. * Adds a new size gradient
  110282. * @param gradient defines the gradient to use (between 0 and 1)
  110283. * @param factor defines the size factor to affect to the specified gradient
  110284. * @returns the current particle system
  110285. */
  110286. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  110287. /**
  110288. * Remove a specific size gradient
  110289. * @param gradient defines the gradient to remove
  110290. * @returns the current particle system
  110291. */
  110292. removeSizeGradient(gradient: number): GPUParticleSystem;
  110293. /**
  110294. * Adds a new angular speed gradient
  110295. * @param gradient defines the gradient to use (between 0 and 1)
  110296. * @param factor defines the angular speed to affect to the specified gradient
  110297. * @returns the current particle system
  110298. */
  110299. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  110300. /**
  110301. * Remove a specific angular speed gradient
  110302. * @param gradient defines the gradient to remove
  110303. * @returns the current particle system
  110304. */
  110305. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  110306. /**
  110307. * Adds a new velocity gradient
  110308. * @param gradient defines the gradient to use (between 0 and 1)
  110309. * @param factor defines the velocity to affect to the specified gradient
  110310. * @returns the current particle system
  110311. */
  110312. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  110313. /**
  110314. * Remove a specific velocity gradient
  110315. * @param gradient defines the gradient to remove
  110316. * @returns the current particle system
  110317. */
  110318. removeVelocityGradient(gradient: number): GPUParticleSystem;
  110319. /**
  110320. * Adds a new limit velocity gradient
  110321. * @param gradient defines the gradient to use (between 0 and 1)
  110322. * @param factor defines the limit velocity value to affect to the specified gradient
  110323. * @returns the current particle system
  110324. */
  110325. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  110326. /**
  110327. * Remove a specific limit velocity gradient
  110328. * @param gradient defines the gradient to remove
  110329. * @returns the current particle system
  110330. */
  110331. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  110332. /**
  110333. * Adds a new drag gradient
  110334. * @param gradient defines the gradient to use (between 0 and 1)
  110335. * @param factor defines the drag value to affect to the specified gradient
  110336. * @returns the current particle system
  110337. */
  110338. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  110339. /**
  110340. * Remove a specific drag gradient
  110341. * @param gradient defines the gradient to remove
  110342. * @returns the current particle system
  110343. */
  110344. removeDragGradient(gradient: number): GPUParticleSystem;
  110345. /**
  110346. * Not supported by GPUParticleSystem
  110347. * @param gradient defines the gradient to use (between 0 and 1)
  110348. * @param factor defines the emit rate value to affect to the specified gradient
  110349. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  110350. * @returns the current particle system
  110351. */
  110352. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  110353. /**
  110354. * Not supported by GPUParticleSystem
  110355. * @param gradient defines the gradient to remove
  110356. * @returns the current particle system
  110357. */
  110358. removeEmitRateGradient(gradient: number): IParticleSystem;
  110359. /**
  110360. * Not supported by GPUParticleSystem
  110361. * @param gradient defines the gradient to use (between 0 and 1)
  110362. * @param factor defines the start size value to affect to the specified gradient
  110363. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  110364. * @returns the current particle system
  110365. */
  110366. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  110367. /**
  110368. * Not supported by GPUParticleSystem
  110369. * @param gradient defines the gradient to remove
  110370. * @returns the current particle system
  110371. */
  110372. removeStartSizeGradient(gradient: number): IParticleSystem;
  110373. /**
  110374. * Not supported by GPUParticleSystem
  110375. * @param gradient defines the gradient to use (between 0 and 1)
  110376. * @param min defines the color remap minimal range
  110377. * @param max defines the color remap maximal range
  110378. * @returns the current particle system
  110379. */
  110380. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  110381. /**
  110382. * Not supported by GPUParticleSystem
  110383. * @param gradient defines the gradient to remove
  110384. * @returns the current particle system
  110385. */
  110386. removeColorRemapGradient(): IParticleSystem;
  110387. /**
  110388. * Not supported by GPUParticleSystem
  110389. * @param gradient defines the gradient to use (between 0 and 1)
  110390. * @param min defines the alpha remap minimal range
  110391. * @param max defines the alpha remap maximal range
  110392. * @returns the current particle system
  110393. */
  110394. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  110395. /**
  110396. * Not supported by GPUParticleSystem
  110397. * @param gradient defines the gradient to remove
  110398. * @returns the current particle system
  110399. */
  110400. removeAlphaRemapGradient(): IParticleSystem;
  110401. /**
  110402. * Not supported by GPUParticleSystem
  110403. * @param gradient defines the gradient to use (between 0 and 1)
  110404. * @param color defines the color to affect to the specified gradient
  110405. * @returns the current particle system
  110406. */
  110407. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  110408. /**
  110409. * Not supported by GPUParticleSystem
  110410. * @param gradient defines the gradient to remove
  110411. * @returns the current particle system
  110412. */
  110413. removeRampGradient(): IParticleSystem;
  110414. /**
  110415. * Not supported by GPUParticleSystem
  110416. * @returns the list of ramp gradients
  110417. */
  110418. getRampGradients(): Nullable<Array<Color3Gradient>>;
  110419. /**
  110420. * Not supported by GPUParticleSystem
  110421. * Gets or sets a boolean indicating that ramp gradients must be used
  110422. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  110423. */
  110424. useRampGradients: boolean;
  110425. /**
  110426. * Not supported by GPUParticleSystem
  110427. * @param gradient defines the gradient to use (between 0 and 1)
  110428. * @param factor defines the life time factor to affect to the specified gradient
  110429. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  110430. * @returns the current particle system
  110431. */
  110432. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  110433. /**
  110434. * Not supported by GPUParticleSystem
  110435. * @param gradient defines the gradient to remove
  110436. * @returns the current particle system
  110437. */
  110438. removeLifeTimeGradient(gradient: number): IParticleSystem;
  110439. /**
  110440. * Instantiates a GPU particle system.
  110441. * 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.
  110442. * @param name The name of the particle system
  110443. * @param options The options used to create the system
  110444. * @param scene The scene the particle system belongs to
  110445. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  110446. */
  110447. constructor(name: string, options: Partial<{
  110448. capacity: number;
  110449. randomTextureSize: number;
  110450. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  110451. protected _reset(): void;
  110452. private _createUpdateVAO;
  110453. private _createRenderVAO;
  110454. private _initialize;
  110455. /** @hidden */
  110456. _recreateUpdateEffect(): void;
  110457. /** @hidden */
  110458. _recreateRenderEffect(): void;
  110459. /**
  110460. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  110461. * @param preWarm defines if we are in the pre-warmimg phase
  110462. */
  110463. animate(preWarm?: boolean): void;
  110464. private _createFactorGradientTexture;
  110465. private _createSizeGradientTexture;
  110466. private _createAngularSpeedGradientTexture;
  110467. private _createVelocityGradientTexture;
  110468. private _createLimitVelocityGradientTexture;
  110469. private _createDragGradientTexture;
  110470. private _createColorGradientTexture;
  110471. /**
  110472. * Renders the particle system in its current state
  110473. * @param preWarm defines if the system should only update the particles but not render them
  110474. * @returns the current number of particles
  110475. */
  110476. render(preWarm?: boolean): number;
  110477. /**
  110478. * Rebuilds the particle system
  110479. */
  110480. rebuild(): void;
  110481. private _releaseBuffers;
  110482. private _releaseVAOs;
  110483. /**
  110484. * Disposes the particle system and free the associated resources
  110485. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  110486. */
  110487. dispose(disposeTexture?: boolean): void;
  110488. /**
  110489. * Clones the particle system.
  110490. * @param name The name of the cloned object
  110491. * @param newEmitter The new emitter to use
  110492. * @returns the cloned particle system
  110493. */
  110494. clone(name: string, newEmitter: any): GPUParticleSystem;
  110495. /**
  110496. * Serializes the particle system to a JSON object.
  110497. * @returns the JSON object
  110498. */
  110499. serialize(): any;
  110500. /**
  110501. * Parses a JSON object to create a GPU particle system.
  110502. * @param parsedParticleSystem The JSON object to parse
  110503. * @param scene The scene to create the particle system in
  110504. * @param rootUrl The root url to use to load external dependencies like texture
  110505. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  110506. * @returns the parsed GPU particle system
  110507. */
  110508. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  110509. }
  110510. }
  110511. declare module BABYLON {
  110512. /**
  110513. * Represents a set of particle systems working together to create a specific effect
  110514. */
  110515. export class ParticleSystemSet implements IDisposable {
  110516. private _emitterCreationOptions;
  110517. private _emitterNode;
  110518. /**
  110519. * Gets the particle system list
  110520. */
  110521. systems: IParticleSystem[];
  110522. /**
  110523. * Gets the emitter node used with this set
  110524. */
  110525. readonly emitterNode: Nullable<TransformNode>;
  110526. /**
  110527. * Creates a new emitter mesh as a sphere
  110528. * @param options defines the options used to create the sphere
  110529. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  110530. * @param scene defines the hosting scene
  110531. */
  110532. setEmitterAsSphere(options: {
  110533. diameter: number;
  110534. segments: number;
  110535. color: Color3;
  110536. }, renderingGroupId: number, scene: Scene): void;
  110537. /**
  110538. * Starts all particle systems of the set
  110539. * @param emitter defines an optional mesh to use as emitter for the particle systems
  110540. */
  110541. start(emitter?: AbstractMesh): void;
  110542. /**
  110543. * Release all associated resources
  110544. */
  110545. dispose(): void;
  110546. /**
  110547. * Serialize the set into a JSON compatible object
  110548. * @returns a JSON compatible representation of the set
  110549. */
  110550. serialize(): any;
  110551. /**
  110552. * Parse a new ParticleSystemSet from a serialized source
  110553. * @param data defines a JSON compatible representation of the set
  110554. * @param scene defines the hosting scene
  110555. * @param gpu defines if we want GPU particles or CPU particles
  110556. * @returns a new ParticleSystemSet
  110557. */
  110558. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  110559. }
  110560. }
  110561. declare module BABYLON {
  110562. /**
  110563. * This class is made for on one-liner static method to help creating particle system set.
  110564. */
  110565. export class ParticleHelper {
  110566. /**
  110567. * Gets or sets base Assets URL
  110568. */
  110569. static BaseAssetsUrl: string;
  110570. /**
  110571. * Create a default particle system that you can tweak
  110572. * @param emitter defines the emitter to use
  110573. * @param capacity defines the system capacity (default is 500 particles)
  110574. * @param scene defines the hosting scene
  110575. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  110576. * @returns the new Particle system
  110577. */
  110578. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  110579. /**
  110580. * This is the main static method (one-liner) of this helper to create different particle systems
  110581. * @param type This string represents the type to the particle system to create
  110582. * @param scene The scene where the particle system should live
  110583. * @param gpu If the system will use gpu
  110584. * @returns the ParticleSystemSet created
  110585. */
  110586. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  110587. /**
  110588. * Static function used to export a particle system to a ParticleSystemSet variable.
  110589. * Please note that the emitter shape is not exported
  110590. * @param systems defines the particle systems to export
  110591. * @returns the created particle system set
  110592. */
  110593. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  110594. }
  110595. }
  110596. declare module BABYLON {
  110597. interface Engine {
  110598. /**
  110599. * Create an effect to use with particle systems.
  110600. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  110601. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  110602. * @param uniformsNames defines a list of attribute names
  110603. * @param samplers defines an array of string used to represent textures
  110604. * @param defines defines the string containing the defines to use to compile the shaders
  110605. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  110606. * @param onCompiled defines a function to call when the effect creation is successful
  110607. * @param onError defines a function to call when the effect creation has failed
  110608. * @returns the new Effect
  110609. */
  110610. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  110611. }
  110612. interface Mesh {
  110613. /**
  110614. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  110615. * @returns an array of IParticleSystem
  110616. */
  110617. getEmittedParticleSystems(): IParticleSystem[];
  110618. /**
  110619. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  110620. * @returns an array of IParticleSystem
  110621. */
  110622. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  110623. }
  110624. /**
  110625. * @hidden
  110626. */
  110627. export var _IDoNeedToBeInTheBuild: number;
  110628. }
  110629. declare module BABYLON {
  110630. interface Scene {
  110631. /** @hidden (Backing field) */
  110632. _physicsEngine: Nullable<IPhysicsEngine>;
  110633. /**
  110634. * Gets the current physics engine
  110635. * @returns a IPhysicsEngine or null if none attached
  110636. */
  110637. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  110638. /**
  110639. * Enables physics to the current scene
  110640. * @param gravity defines the scene's gravity for the physics engine
  110641. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  110642. * @return a boolean indicating if the physics engine was initialized
  110643. */
  110644. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  110645. /**
  110646. * Disables and disposes the physics engine associated with the scene
  110647. */
  110648. disablePhysicsEngine(): void;
  110649. /**
  110650. * Gets a boolean indicating if there is an active physics engine
  110651. * @returns a boolean indicating if there is an active physics engine
  110652. */
  110653. isPhysicsEnabled(): boolean;
  110654. /**
  110655. * Deletes a physics compound impostor
  110656. * @param compound defines the compound to delete
  110657. */
  110658. deleteCompoundImpostor(compound: any): void;
  110659. /**
  110660. * An event triggered when physic simulation is about to be run
  110661. */
  110662. onBeforePhysicsObservable: Observable<Scene>;
  110663. /**
  110664. * An event triggered when physic simulation has been done
  110665. */
  110666. onAfterPhysicsObservable: Observable<Scene>;
  110667. }
  110668. interface AbstractMesh {
  110669. /** @hidden */
  110670. _physicsImpostor: Nullable<PhysicsImpostor>;
  110671. /**
  110672. * Gets or sets impostor used for physic simulation
  110673. * @see http://doc.babylonjs.com/features/physics_engine
  110674. */
  110675. physicsImpostor: Nullable<PhysicsImpostor>;
  110676. /**
  110677. * Gets the current physics impostor
  110678. * @see http://doc.babylonjs.com/features/physics_engine
  110679. * @returns a physics impostor or null
  110680. */
  110681. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  110682. /** Apply a physic impulse to the mesh
  110683. * @param force defines the force to apply
  110684. * @param contactPoint defines where to apply the force
  110685. * @returns the current mesh
  110686. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  110687. */
  110688. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  110689. /**
  110690. * Creates a physic joint between two meshes
  110691. * @param otherMesh defines the other mesh to use
  110692. * @param pivot1 defines the pivot to use on this mesh
  110693. * @param pivot2 defines the pivot to use on the other mesh
  110694. * @param options defines additional options (can be plugin dependent)
  110695. * @returns the current mesh
  110696. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  110697. */
  110698. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  110699. /** @hidden */
  110700. _disposePhysicsObserver: Nullable<Observer<Node>>;
  110701. }
  110702. /**
  110703. * Defines the physics engine scene component responsible to manage a physics engine
  110704. */
  110705. export class PhysicsEngineSceneComponent implements ISceneComponent {
  110706. /**
  110707. * The component name helpful to identify the component in the list of scene components.
  110708. */
  110709. readonly name: string;
  110710. /**
  110711. * The scene the component belongs to.
  110712. */
  110713. scene: Scene;
  110714. /**
  110715. * Creates a new instance of the component for the given scene
  110716. * @param scene Defines the scene to register the component in
  110717. */
  110718. constructor(scene: Scene);
  110719. /**
  110720. * Registers the component in a given scene
  110721. */
  110722. register(): void;
  110723. /**
  110724. * Rebuilds the elements related to this component in case of
  110725. * context lost for instance.
  110726. */
  110727. rebuild(): void;
  110728. /**
  110729. * Disposes the component and the associated ressources
  110730. */
  110731. dispose(): void;
  110732. }
  110733. }
  110734. declare module BABYLON {
  110735. /**
  110736. * A helper for physics simulations
  110737. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  110738. */
  110739. export class PhysicsHelper {
  110740. private _scene;
  110741. private _physicsEngine;
  110742. /**
  110743. * Initializes the Physics helper
  110744. * @param scene Babylon.js scene
  110745. */
  110746. constructor(scene: Scene);
  110747. /**
  110748. * Applies a radial explosion impulse
  110749. * @param origin the origin of the explosion
  110750. * @param radiusOrEventOptions the radius or the options of radial explosion
  110751. * @param strength the explosion strength
  110752. * @param falloff possible options: Constant & Linear. Defaults to Constant
  110753. * @returns A physics radial explosion event, or null
  110754. */
  110755. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  110756. /**
  110757. * Applies a radial explosion force
  110758. * @param origin the origin of the explosion
  110759. * @param radiusOrEventOptions the radius or the options of radial explosion
  110760. * @param strength the explosion strength
  110761. * @param falloff possible options: Constant & Linear. Defaults to Constant
  110762. * @returns A physics radial explosion event, or null
  110763. */
  110764. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  110765. /**
  110766. * Creates a gravitational field
  110767. * @param origin the origin of the explosion
  110768. * @param radiusOrEventOptions the radius or the options of radial explosion
  110769. * @param strength the explosion strength
  110770. * @param falloff possible options: Constant & Linear. Defaults to Constant
  110771. * @returns A physics gravitational field event, or null
  110772. */
  110773. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  110774. /**
  110775. * Creates a physics updraft event
  110776. * @param origin the origin of the updraft
  110777. * @param radiusOrEventOptions the radius or the options of the updraft
  110778. * @param strength the strength of the updraft
  110779. * @param height the height of the updraft
  110780. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  110781. * @returns A physics updraft event, or null
  110782. */
  110783. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  110784. /**
  110785. * Creates a physics vortex event
  110786. * @param origin the of the vortex
  110787. * @param radiusOrEventOptions the radius or the options of the vortex
  110788. * @param strength the strength of the vortex
  110789. * @param height the height of the vortex
  110790. * @returns a Physics vortex event, or null
  110791. * A physics vortex event or null
  110792. */
  110793. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  110794. }
  110795. /**
  110796. * Represents a physics radial explosion event
  110797. */
  110798. class PhysicsRadialExplosionEvent {
  110799. private _scene;
  110800. private _options;
  110801. private _sphere;
  110802. private _dataFetched;
  110803. /**
  110804. * Initializes a radial explosioin event
  110805. * @param _scene BabylonJS scene
  110806. * @param _options The options for the vortex event
  110807. */
  110808. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  110809. /**
  110810. * Returns the data related to the radial explosion event (sphere).
  110811. * @returns The radial explosion event data
  110812. */
  110813. getData(): PhysicsRadialExplosionEventData;
  110814. /**
  110815. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  110816. * @param impostor A physics imposter
  110817. * @param origin the origin of the explosion
  110818. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  110819. */
  110820. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  110821. /**
  110822. * Triggers affecterd impostors callbacks
  110823. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  110824. */
  110825. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  110826. /**
  110827. * Disposes the sphere.
  110828. * @param force Specifies if the sphere should be disposed by force
  110829. */
  110830. dispose(force?: boolean): void;
  110831. /*** Helpers ***/
  110832. private _prepareSphere;
  110833. private _intersectsWithSphere;
  110834. }
  110835. /**
  110836. * Represents a gravitational field event
  110837. */
  110838. class PhysicsGravitationalFieldEvent {
  110839. private _physicsHelper;
  110840. private _scene;
  110841. private _origin;
  110842. private _options;
  110843. private _tickCallback;
  110844. private _sphere;
  110845. private _dataFetched;
  110846. /**
  110847. * Initializes the physics gravitational field event
  110848. * @param _physicsHelper A physics helper
  110849. * @param _scene BabylonJS scene
  110850. * @param _origin The origin position of the gravitational field event
  110851. * @param _options The options for the vortex event
  110852. */
  110853. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  110854. /**
  110855. * Returns the data related to the gravitational field event (sphere).
  110856. * @returns A gravitational field event
  110857. */
  110858. getData(): PhysicsGravitationalFieldEventData;
  110859. /**
  110860. * Enables the gravitational field.
  110861. */
  110862. enable(): void;
  110863. /**
  110864. * Disables the gravitational field.
  110865. */
  110866. disable(): void;
  110867. /**
  110868. * Disposes the sphere.
  110869. * @param force The force to dispose from the gravitational field event
  110870. */
  110871. dispose(force?: boolean): void;
  110872. private _tick;
  110873. }
  110874. /**
  110875. * Represents a physics updraft event
  110876. */
  110877. class PhysicsUpdraftEvent {
  110878. private _scene;
  110879. private _origin;
  110880. private _options;
  110881. private _physicsEngine;
  110882. private _originTop;
  110883. private _originDirection;
  110884. private _tickCallback;
  110885. private _cylinder;
  110886. private _cylinderPosition;
  110887. private _dataFetched;
  110888. /**
  110889. * Initializes the physics updraft event
  110890. * @param _scene BabylonJS scene
  110891. * @param _origin The origin position of the updraft
  110892. * @param _options The options for the updraft event
  110893. */
  110894. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  110895. /**
  110896. * Returns the data related to the updraft event (cylinder).
  110897. * @returns A physics updraft event
  110898. */
  110899. getData(): PhysicsUpdraftEventData;
  110900. /**
  110901. * Enables the updraft.
  110902. */
  110903. enable(): void;
  110904. /**
  110905. * Disables the updraft.
  110906. */
  110907. disable(): void;
  110908. /**
  110909. * Disposes the cylinder.
  110910. * @param force Specifies if the updraft should be disposed by force
  110911. */
  110912. dispose(force?: boolean): void;
  110913. private getImpostorHitData;
  110914. private _tick;
  110915. /*** Helpers ***/
  110916. private _prepareCylinder;
  110917. private _intersectsWithCylinder;
  110918. }
  110919. /**
  110920. * Represents a physics vortex event
  110921. */
  110922. class PhysicsVortexEvent {
  110923. private _scene;
  110924. private _origin;
  110925. private _options;
  110926. private _physicsEngine;
  110927. private _originTop;
  110928. private _tickCallback;
  110929. private _cylinder;
  110930. private _cylinderPosition;
  110931. private _dataFetched;
  110932. /**
  110933. * Initializes the physics vortex event
  110934. * @param _scene The BabylonJS scene
  110935. * @param _origin The origin position of the vortex
  110936. * @param _options The options for the vortex event
  110937. */
  110938. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  110939. /**
  110940. * Returns the data related to the vortex event (cylinder).
  110941. * @returns The physics vortex event data
  110942. */
  110943. getData(): PhysicsVortexEventData;
  110944. /**
  110945. * Enables the vortex.
  110946. */
  110947. enable(): void;
  110948. /**
  110949. * Disables the cortex.
  110950. */
  110951. disable(): void;
  110952. /**
  110953. * Disposes the sphere.
  110954. * @param force
  110955. */
  110956. dispose(force?: boolean): void;
  110957. private getImpostorHitData;
  110958. private _tick;
  110959. /*** Helpers ***/
  110960. private _prepareCylinder;
  110961. private _intersectsWithCylinder;
  110962. }
  110963. /**
  110964. * Options fot the radial explosion event
  110965. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  110966. */
  110967. export class PhysicsRadialExplosionEventOptions {
  110968. /**
  110969. * The radius of the sphere for the radial explosion.
  110970. */
  110971. radius: number;
  110972. /**
  110973. * The strenth of the explosion.
  110974. */
  110975. strength: number;
  110976. /**
  110977. * The strenght of the force in correspondence to the distance of the affected object
  110978. */
  110979. falloff: PhysicsRadialImpulseFalloff;
  110980. /**
  110981. * Sphere options for the radial explosion.
  110982. */
  110983. sphere: {
  110984. segments: number;
  110985. diameter: number;
  110986. };
  110987. /**
  110988. * Sphere options for the radial explosion.
  110989. */
  110990. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  110991. }
  110992. /**
  110993. * Options fot the updraft event
  110994. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  110995. */
  110996. export class PhysicsUpdraftEventOptions {
  110997. /**
  110998. * The radius of the cylinder for the vortex
  110999. */
  111000. radius: number;
  111001. /**
  111002. * The strenth of the updraft.
  111003. */
  111004. strength: number;
  111005. /**
  111006. * The height of the cylinder for the updraft.
  111007. */
  111008. height: number;
  111009. /**
  111010. * The mode for the the updraft.
  111011. */
  111012. updraftMode: PhysicsUpdraftMode;
  111013. }
  111014. /**
  111015. * Options fot the vortex event
  111016. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  111017. */
  111018. export class PhysicsVortexEventOptions {
  111019. /**
  111020. * The radius of the cylinder for the vortex
  111021. */
  111022. radius: number;
  111023. /**
  111024. * The strenth of the vortex.
  111025. */
  111026. strength: number;
  111027. /**
  111028. * The height of the cylinder for the vortex.
  111029. */
  111030. height: number;
  111031. /**
  111032. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  111033. */
  111034. centripetalForceThreshold: number;
  111035. /**
  111036. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  111037. */
  111038. centripetalForceMultiplier: number;
  111039. /**
  111040. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  111041. */
  111042. centrifugalForceMultiplier: number;
  111043. /**
  111044. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  111045. */
  111046. updraftForceMultiplier: number;
  111047. }
  111048. /**
  111049. * The strenght of the force in correspondence to the distance of the affected object
  111050. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  111051. */
  111052. export enum PhysicsRadialImpulseFalloff {
  111053. /** Defines that impulse is constant in strength across it's whole radius */
  111054. Constant = 0,
  111055. /** Defines that impulse gets weaker if it's further from the origin */
  111056. Linear = 1
  111057. }
  111058. /**
  111059. * The strength of the force in correspondence to the distance of the affected object
  111060. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  111061. */
  111062. export enum PhysicsUpdraftMode {
  111063. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  111064. Center = 0,
  111065. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  111066. Perpendicular = 1
  111067. }
  111068. /**
  111069. * Interface for a physics hit data
  111070. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  111071. */
  111072. export interface PhysicsHitData {
  111073. /**
  111074. * The force applied at the contact point
  111075. */
  111076. force: Vector3;
  111077. /**
  111078. * The contact point
  111079. */
  111080. contactPoint: Vector3;
  111081. /**
  111082. * The distance from the origin to the contact point
  111083. */
  111084. distanceFromOrigin: number;
  111085. }
  111086. /**
  111087. * Interface for radial explosion event data
  111088. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  111089. */
  111090. export interface PhysicsRadialExplosionEventData {
  111091. /**
  111092. * A sphere used for the radial explosion event
  111093. */
  111094. sphere: Mesh;
  111095. }
  111096. /**
  111097. * Interface for gravitational field event data
  111098. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  111099. */
  111100. export interface PhysicsGravitationalFieldEventData {
  111101. /**
  111102. * A sphere mesh used for the gravitational field event
  111103. */
  111104. sphere: Mesh;
  111105. }
  111106. /**
  111107. * Interface for updraft event data
  111108. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  111109. */
  111110. export interface PhysicsUpdraftEventData {
  111111. /**
  111112. * A cylinder used for the updraft event
  111113. */
  111114. cylinder: Mesh;
  111115. }
  111116. /**
  111117. * Interface for vortex event data
  111118. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  111119. */
  111120. export interface PhysicsVortexEventData {
  111121. /**
  111122. * A cylinder used for the vortex event
  111123. */
  111124. cylinder: Mesh;
  111125. }
  111126. /**
  111127. * Interface for an affected physics impostor
  111128. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  111129. */
  111130. export interface PhysicsAffectedImpostorWithData {
  111131. /**
  111132. * The impostor affected by the effect
  111133. */
  111134. impostor: PhysicsImpostor;
  111135. /**
  111136. * The data about the hit/horce from the explosion
  111137. */
  111138. hitData: PhysicsHitData;
  111139. }
  111140. }
  111141. declare module BABYLON {
  111142. /** @hidden */
  111143. export var blackAndWhitePixelShader: {
  111144. name: string;
  111145. shader: string;
  111146. };
  111147. }
  111148. declare module BABYLON {
  111149. /**
  111150. * Post process used to render in black and white
  111151. */
  111152. export class BlackAndWhitePostProcess extends PostProcess {
  111153. /**
  111154. * Linear about to convert he result to black and white (default: 1)
  111155. */
  111156. degree: number;
  111157. /**
  111158. * Creates a black and white post process
  111159. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  111160. * @param name The name of the effect.
  111161. * @param options The required width/height ratio to downsize to before computing the render pass.
  111162. * @param camera The camera to apply the render pass to.
  111163. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  111164. * @param engine The engine which the post process will be applied. (default: current engine)
  111165. * @param reusable If the post process can be reused on the same frame. (default: false)
  111166. */
  111167. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  111168. }
  111169. }
  111170. declare module BABYLON {
  111171. /**
  111172. * This represents a set of one or more post processes in Babylon.
  111173. * A post process can be used to apply a shader to a texture after it is rendered.
  111174. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  111175. */
  111176. export class PostProcessRenderEffect {
  111177. private _postProcesses;
  111178. private _getPostProcesses;
  111179. private _singleInstance;
  111180. private _cameras;
  111181. private _indicesForCamera;
  111182. /**
  111183. * Name of the effect
  111184. * @hidden
  111185. */
  111186. _name: string;
  111187. /**
  111188. * Instantiates a post process render effect.
  111189. * A post process can be used to apply a shader to a texture after it is rendered.
  111190. * @param engine The engine the effect is tied to
  111191. * @param name The name of the effect
  111192. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  111193. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  111194. */
  111195. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  111196. /**
  111197. * Checks if all the post processes in the effect are supported.
  111198. */
  111199. readonly isSupported: boolean;
  111200. /**
  111201. * Updates the current state of the effect
  111202. * @hidden
  111203. */
  111204. _update(): void;
  111205. /**
  111206. * Attaches the effect on cameras
  111207. * @param cameras The camera to attach to.
  111208. * @hidden
  111209. */
  111210. _attachCameras(cameras: Camera): void;
  111211. /**
  111212. * Attaches the effect on cameras
  111213. * @param cameras The camera to attach to.
  111214. * @hidden
  111215. */
  111216. _attachCameras(cameras: Camera[]): void;
  111217. /**
  111218. * Detatches the effect on cameras
  111219. * @param cameras The camera to detatch from.
  111220. * @hidden
  111221. */
  111222. _detachCameras(cameras: Camera): void;
  111223. /**
  111224. * Detatches the effect on cameras
  111225. * @param cameras The camera to detatch from.
  111226. * @hidden
  111227. */
  111228. _detachCameras(cameras: Camera[]): void;
  111229. /**
  111230. * Enables the effect on given cameras
  111231. * @param cameras The camera to enable.
  111232. * @hidden
  111233. */
  111234. _enable(cameras: Camera): void;
  111235. /**
  111236. * Enables the effect on given cameras
  111237. * @param cameras The camera to enable.
  111238. * @hidden
  111239. */
  111240. _enable(cameras: Nullable<Camera[]>): void;
  111241. /**
  111242. * Disables the effect on the given cameras
  111243. * @param cameras The camera to disable.
  111244. * @hidden
  111245. */
  111246. _disable(cameras: Camera): void;
  111247. /**
  111248. * Disables the effect on the given cameras
  111249. * @param cameras The camera to disable.
  111250. * @hidden
  111251. */
  111252. _disable(cameras: Nullable<Camera[]>): void;
  111253. /**
  111254. * Gets a list of the post processes contained in the effect.
  111255. * @param camera The camera to get the post processes on.
  111256. * @returns The list of the post processes in the effect.
  111257. */
  111258. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  111259. }
  111260. }
  111261. declare module BABYLON {
  111262. /** @hidden */
  111263. export var extractHighlightsPixelShader: {
  111264. name: string;
  111265. shader: string;
  111266. };
  111267. }
  111268. declare module BABYLON {
  111269. /**
  111270. * 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.
  111271. */
  111272. export class ExtractHighlightsPostProcess extends PostProcess {
  111273. /**
  111274. * The luminance threshold, pixels below this value will be set to black.
  111275. */
  111276. threshold: number;
  111277. /** @hidden */
  111278. _exposure: number;
  111279. /**
  111280. * Post process which has the input texture to be used when performing highlight extraction
  111281. * @hidden
  111282. */
  111283. _inputPostProcess: Nullable<PostProcess>;
  111284. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  111285. }
  111286. }
  111287. declare module BABYLON {
  111288. /** @hidden */
  111289. export var bloomMergePixelShader: {
  111290. name: string;
  111291. shader: string;
  111292. };
  111293. }
  111294. declare module BABYLON {
  111295. /**
  111296. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  111297. */
  111298. export class BloomMergePostProcess extends PostProcess {
  111299. /** Weight of the bloom to be added to the original input. */
  111300. weight: number;
  111301. /**
  111302. * Creates a new instance of @see BloomMergePostProcess
  111303. * @param name The name of the effect.
  111304. * @param originalFromInput Post process which's input will be used for the merge.
  111305. * @param blurred Blurred highlights post process which's output will be used.
  111306. * @param weight Weight of the bloom to be added to the original input.
  111307. * @param options The required width/height ratio to downsize to before computing the render pass.
  111308. * @param camera The camera to apply the render pass to.
  111309. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  111310. * @param engine The engine which the post process will be applied. (default: current engine)
  111311. * @param reusable If the post process can be reused on the same frame. (default: false)
  111312. * @param textureType Type of textures used when performing the post process. (default: 0)
  111313. * @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)
  111314. */
  111315. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  111316. /** Weight of the bloom to be added to the original input. */
  111317. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  111318. }
  111319. }
  111320. declare module BABYLON {
  111321. /**
  111322. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  111323. */
  111324. export class BloomEffect extends PostProcessRenderEffect {
  111325. private bloomScale;
  111326. /**
  111327. * @hidden Internal
  111328. */
  111329. _effects: Array<PostProcess>;
  111330. /**
  111331. * @hidden Internal
  111332. */
  111333. _downscale: ExtractHighlightsPostProcess;
  111334. private _blurX;
  111335. private _blurY;
  111336. private _merge;
  111337. /**
  111338. * The luminance threshold to find bright areas of the image to bloom.
  111339. */
  111340. threshold: number;
  111341. /**
  111342. * The strength of the bloom.
  111343. */
  111344. weight: number;
  111345. /**
  111346. * Specifies the size of the bloom blur kernel, relative to the final output size
  111347. */
  111348. kernel: number;
  111349. /**
  111350. * Creates a new instance of @see BloomEffect
  111351. * @param scene The scene the effect belongs to.
  111352. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  111353. * @param bloomKernel The size of the kernel to be used when applying the blur.
  111354. * @param bloomWeight The the strength of bloom.
  111355. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  111356. * @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)
  111357. */
  111358. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  111359. /**
  111360. * Disposes each of the internal effects for a given camera.
  111361. * @param camera The camera to dispose the effect on.
  111362. */
  111363. disposeEffects(camera: Camera): void;
  111364. /**
  111365. * @hidden Internal
  111366. */
  111367. _updateEffects(): void;
  111368. /**
  111369. * Internal
  111370. * @returns if all the contained post processes are ready.
  111371. * @hidden
  111372. */
  111373. _isReady(): boolean;
  111374. }
  111375. }
  111376. declare module BABYLON {
  111377. /** @hidden */
  111378. export var chromaticAberrationPixelShader: {
  111379. name: string;
  111380. shader: string;
  111381. };
  111382. }
  111383. declare module BABYLON {
  111384. /**
  111385. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  111386. */
  111387. export class ChromaticAberrationPostProcess extends PostProcess {
  111388. /**
  111389. * The amount of seperation of rgb channels (default: 30)
  111390. */
  111391. aberrationAmount: number;
  111392. /**
  111393. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  111394. */
  111395. radialIntensity: number;
  111396. /**
  111397. * 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))
  111398. */
  111399. direction: Vector2;
  111400. /**
  111401. * 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))
  111402. */
  111403. centerPosition: Vector2;
  111404. /**
  111405. * Creates a new instance ChromaticAberrationPostProcess
  111406. * @param name The name of the effect.
  111407. * @param screenWidth The width of the screen to apply the effect on.
  111408. * @param screenHeight The height of the screen to apply the effect on.
  111409. * @param options The required width/height ratio to downsize to before computing the render pass.
  111410. * @param camera The camera to apply the render pass to.
  111411. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  111412. * @param engine The engine which the post process will be applied. (default: current engine)
  111413. * @param reusable If the post process can be reused on the same frame. (default: false)
  111414. * @param textureType Type of textures used when performing the post process. (default: 0)
  111415. * @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)
  111416. */
  111417. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  111418. }
  111419. }
  111420. declare module BABYLON {
  111421. /** @hidden */
  111422. export var circleOfConfusionPixelShader: {
  111423. name: string;
  111424. shader: string;
  111425. };
  111426. }
  111427. declare module BABYLON {
  111428. /**
  111429. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  111430. */
  111431. export class CircleOfConfusionPostProcess extends PostProcess {
  111432. /**
  111433. * 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.
  111434. */
  111435. lensSize: number;
  111436. /**
  111437. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  111438. */
  111439. fStop: number;
  111440. /**
  111441. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  111442. */
  111443. focusDistance: number;
  111444. /**
  111445. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  111446. */
  111447. focalLength: number;
  111448. private _depthTexture;
  111449. /**
  111450. * Creates a new instance CircleOfConfusionPostProcess
  111451. * @param name The name of the effect.
  111452. * @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.
  111453. * @param options The required width/height ratio to downsize to before computing the render pass.
  111454. * @param camera The camera to apply the render pass to.
  111455. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  111456. * @param engine The engine which the post process will be applied. (default: current engine)
  111457. * @param reusable If the post process can be reused on the same frame. (default: false)
  111458. * @param textureType Type of textures used when performing the post process. (default: 0)
  111459. * @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)
  111460. */
  111461. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  111462. /**
  111463. * 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.
  111464. */
  111465. depthTexture: RenderTargetTexture;
  111466. }
  111467. }
  111468. declare module BABYLON {
  111469. /** @hidden */
  111470. export var colorCorrectionPixelShader: {
  111471. name: string;
  111472. shader: string;
  111473. };
  111474. }
  111475. declare module BABYLON {
  111476. /**
  111477. *
  111478. * This post-process allows the modification of rendered colors by using
  111479. * a 'look-up table' (LUT). This effect is also called Color Grading.
  111480. *
  111481. * The object needs to be provided an url to a texture containing the color
  111482. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  111483. * Use an image editing software to tweak the LUT to match your needs.
  111484. *
  111485. * For an example of a color LUT, see here:
  111486. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  111487. * For explanations on color grading, see here:
  111488. * @see http://udn.epicgames.com/Three/ColorGrading.html
  111489. *
  111490. */
  111491. export class ColorCorrectionPostProcess extends PostProcess {
  111492. private _colorTableTexture;
  111493. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  111494. }
  111495. }
  111496. declare module BABYLON {
  111497. /** @hidden */
  111498. export var convolutionPixelShader: {
  111499. name: string;
  111500. shader: string;
  111501. };
  111502. }
  111503. declare module BABYLON {
  111504. /**
  111505. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  111506. * input texture to perform effects such as edge detection or sharpening
  111507. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  111508. */
  111509. export class ConvolutionPostProcess extends PostProcess {
  111510. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  111511. kernel: number[];
  111512. /**
  111513. * Creates a new instance ConvolutionPostProcess
  111514. * @param name The name of the effect.
  111515. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  111516. * @param options The required width/height ratio to downsize to before computing the render pass.
  111517. * @param camera The camera to apply the render pass to.
  111518. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  111519. * @param engine The engine which the post process will be applied. (default: current engine)
  111520. * @param reusable If the post process can be reused on the same frame. (default: false)
  111521. * @param textureType Type of textures used when performing the post process. (default: 0)
  111522. */
  111523. constructor(name: string,
  111524. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  111525. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  111526. /**
  111527. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  111528. */
  111529. static EdgeDetect0Kernel: number[];
  111530. /**
  111531. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  111532. */
  111533. static EdgeDetect1Kernel: number[];
  111534. /**
  111535. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  111536. */
  111537. static EdgeDetect2Kernel: number[];
  111538. /**
  111539. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  111540. */
  111541. static SharpenKernel: number[];
  111542. /**
  111543. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  111544. */
  111545. static EmbossKernel: number[];
  111546. /**
  111547. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  111548. */
  111549. static GaussianKernel: number[];
  111550. }
  111551. }
  111552. declare module BABYLON {
  111553. /**
  111554. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  111555. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  111556. * based on samples that have a large difference in distance than the center pixel.
  111557. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  111558. */
  111559. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  111560. direction: Vector2;
  111561. /**
  111562. * Creates a new instance CircleOfConfusionPostProcess
  111563. * @param name The name of the effect.
  111564. * @param scene The scene the effect belongs to.
  111565. * @param direction The direction the blur should be applied.
  111566. * @param kernel The size of the kernel used to blur.
  111567. * @param options The required width/height ratio to downsize to before computing the render pass.
  111568. * @param camera The camera to apply the render pass to.
  111569. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  111570. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  111571. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  111572. * @param engine The engine which the post process will be applied. (default: current engine)
  111573. * @param reusable If the post process can be reused on the same frame. (default: false)
  111574. * @param textureType Type of textures used when performing the post process. (default: 0)
  111575. * @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)
  111576. */
  111577. 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);
  111578. }
  111579. }
  111580. declare module BABYLON {
  111581. /** @hidden */
  111582. export var depthOfFieldMergePixelShader: {
  111583. name: string;
  111584. shader: string;
  111585. };
  111586. }
  111587. declare module BABYLON {
  111588. /**
  111589. * Options to be set when merging outputs from the default pipeline.
  111590. */
  111591. export class DepthOfFieldMergePostProcessOptions {
  111592. /**
  111593. * The original image to merge on top of
  111594. */
  111595. originalFromInput: PostProcess;
  111596. /**
  111597. * Parameters to perform the merge of the depth of field effect
  111598. */
  111599. depthOfField?: {
  111600. circleOfConfusion: PostProcess;
  111601. blurSteps: Array<PostProcess>;
  111602. };
  111603. /**
  111604. * Parameters to perform the merge of bloom effect
  111605. */
  111606. bloom?: {
  111607. blurred: PostProcess;
  111608. weight: number;
  111609. };
  111610. }
  111611. /**
  111612. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  111613. */
  111614. export class DepthOfFieldMergePostProcess extends PostProcess {
  111615. private blurSteps;
  111616. /**
  111617. * Creates a new instance of DepthOfFieldMergePostProcess
  111618. * @param name The name of the effect.
  111619. * @param originalFromInput Post process which's input will be used for the merge.
  111620. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  111621. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  111622. * @param options The required width/height ratio to downsize to before computing the render pass.
  111623. * @param camera The camera to apply the render pass to.
  111624. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  111625. * @param engine The engine which the post process will be applied. (default: current engine)
  111626. * @param reusable If the post process can be reused on the same frame. (default: false)
  111627. * @param textureType Type of textures used when performing the post process. (default: 0)
  111628. * @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)
  111629. */
  111630. 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);
  111631. /**
  111632. * Updates the effect with the current post process compile time values and recompiles the shader.
  111633. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  111634. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  111635. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  111636. * @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
  111637. * @param onCompiled Called when the shader has been compiled.
  111638. * @param onError Called if there is an error when compiling a shader.
  111639. */
  111640. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  111641. }
  111642. }
  111643. declare module BABYLON {
  111644. /**
  111645. * Specifies the level of max blur that should be applied when using the depth of field effect
  111646. */
  111647. export enum DepthOfFieldEffectBlurLevel {
  111648. /**
  111649. * Subtle blur
  111650. */
  111651. Low = 0,
  111652. /**
  111653. * Medium blur
  111654. */
  111655. Medium = 1,
  111656. /**
  111657. * Large blur
  111658. */
  111659. High = 2
  111660. }
  111661. /**
  111662. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  111663. */
  111664. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  111665. private _circleOfConfusion;
  111666. /**
  111667. * @hidden Internal, blurs from high to low
  111668. */
  111669. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  111670. private _depthOfFieldBlurY;
  111671. private _dofMerge;
  111672. /**
  111673. * @hidden Internal post processes in depth of field effect
  111674. */
  111675. _effects: Array<PostProcess>;
  111676. /**
  111677. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  111678. */
  111679. focalLength: number;
  111680. /**
  111681. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  111682. */
  111683. fStop: number;
  111684. /**
  111685. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  111686. */
  111687. focusDistance: number;
  111688. /**
  111689. * 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.
  111690. */
  111691. lensSize: number;
  111692. /**
  111693. * Creates a new instance DepthOfFieldEffect
  111694. * @param scene The scene the effect belongs to.
  111695. * @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.
  111696. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  111697. * @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)
  111698. */
  111699. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  111700. /**
  111701. * 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.
  111702. */
  111703. depthTexture: RenderTargetTexture;
  111704. /**
  111705. * Disposes each of the internal effects for a given camera.
  111706. * @param camera The camera to dispose the effect on.
  111707. */
  111708. disposeEffects(camera: Camera): void;
  111709. /**
  111710. * @hidden Internal
  111711. */
  111712. _updateEffects(): void;
  111713. /**
  111714. * Internal
  111715. * @returns if all the contained post processes are ready.
  111716. * @hidden
  111717. */
  111718. _isReady(): boolean;
  111719. }
  111720. }
  111721. declare module BABYLON {
  111722. /** @hidden */
  111723. export var displayPassPixelShader: {
  111724. name: string;
  111725. shader: string;
  111726. };
  111727. }
  111728. declare module BABYLON {
  111729. /**
  111730. * DisplayPassPostProcess which produces an output the same as it's input
  111731. */
  111732. export class DisplayPassPostProcess extends PostProcess {
  111733. /**
  111734. * Creates the DisplayPassPostProcess
  111735. * @param name The name of the effect.
  111736. * @param options The required width/height ratio to downsize to before computing the render pass.
  111737. * @param camera The camera to apply the render pass to.
  111738. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  111739. * @param engine The engine which the post process will be applied. (default: current engine)
  111740. * @param reusable If the post process can be reused on the same frame. (default: false)
  111741. */
  111742. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  111743. }
  111744. }
  111745. declare module BABYLON {
  111746. /** @hidden */
  111747. export var filterPixelShader: {
  111748. name: string;
  111749. shader: string;
  111750. };
  111751. }
  111752. declare module BABYLON {
  111753. /**
  111754. * Applies a kernel filter to the image
  111755. */
  111756. export class FilterPostProcess extends PostProcess {
  111757. /** The matrix to be applied to the image */
  111758. kernelMatrix: Matrix;
  111759. /**
  111760. *
  111761. * @param name The name of the effect.
  111762. * @param kernelMatrix The matrix to be applied to the image
  111763. * @param options The required width/height ratio to downsize to before computing the render pass.
  111764. * @param camera The camera to apply the render pass to.
  111765. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  111766. * @param engine The engine which the post process will be applied. (default: current engine)
  111767. * @param reusable If the post process can be reused on the same frame. (default: false)
  111768. */
  111769. constructor(name: string,
  111770. /** The matrix to be applied to the image */
  111771. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  111772. }
  111773. }
  111774. declare module BABYLON {
  111775. /** @hidden */
  111776. export var fxaaPixelShader: {
  111777. name: string;
  111778. shader: string;
  111779. };
  111780. }
  111781. declare module BABYLON {
  111782. /** @hidden */
  111783. export var fxaaVertexShader: {
  111784. name: string;
  111785. shader: string;
  111786. };
  111787. }
  111788. declare module BABYLON {
  111789. /**
  111790. * Fxaa post process
  111791. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  111792. */
  111793. export class FxaaPostProcess extends PostProcess {
  111794. /** @hidden */
  111795. texelWidth: number;
  111796. /** @hidden */
  111797. texelHeight: number;
  111798. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  111799. private _getDefines;
  111800. }
  111801. }
  111802. declare module BABYLON {
  111803. /** @hidden */
  111804. export var grainPixelShader: {
  111805. name: string;
  111806. shader: string;
  111807. };
  111808. }
  111809. declare module BABYLON {
  111810. /**
  111811. * The GrainPostProcess adds noise to the image at mid luminance levels
  111812. */
  111813. export class GrainPostProcess extends PostProcess {
  111814. /**
  111815. * The intensity of the grain added (default: 30)
  111816. */
  111817. intensity: number;
  111818. /**
  111819. * If the grain should be randomized on every frame
  111820. */
  111821. animated: boolean;
  111822. /**
  111823. * Creates a new instance of @see GrainPostProcess
  111824. * @param name The name of the effect.
  111825. * @param options The required width/height ratio to downsize to before computing the render pass.
  111826. * @param camera The camera to apply the render pass to.
  111827. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  111828. * @param engine The engine which the post process will be applied. (default: current engine)
  111829. * @param reusable If the post process can be reused on the same frame. (default: false)
  111830. * @param textureType Type of textures used when performing the post process. (default: 0)
  111831. * @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)
  111832. */
  111833. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  111834. }
  111835. }
  111836. declare module BABYLON {
  111837. /** @hidden */
  111838. export var highlightsPixelShader: {
  111839. name: string;
  111840. shader: string;
  111841. };
  111842. }
  111843. declare module BABYLON {
  111844. /**
  111845. * Extracts highlights from the image
  111846. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  111847. */
  111848. export class HighlightsPostProcess extends PostProcess {
  111849. /**
  111850. * Extracts highlights from the image
  111851. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  111852. * @param name The name of the effect.
  111853. * @param options The required width/height ratio to downsize to before computing the render pass.
  111854. * @param camera The camera to apply the render pass to.
  111855. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  111856. * @param engine The engine which the post process will be applied. (default: current engine)
  111857. * @param reusable If the post process can be reused on the same frame. (default: false)
  111858. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  111859. */
  111860. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  111861. }
  111862. }
  111863. declare module BABYLON {
  111864. /** @hidden */
  111865. export var mrtFragmentDeclaration: {
  111866. name: string;
  111867. shader: string;
  111868. };
  111869. }
  111870. declare module BABYLON {
  111871. /** @hidden */
  111872. export var geometryPixelShader: {
  111873. name: string;
  111874. shader: string;
  111875. };
  111876. }
  111877. declare module BABYLON {
  111878. /** @hidden */
  111879. export var geometryVertexShader: {
  111880. name: string;
  111881. shader: string;
  111882. };
  111883. }
  111884. declare module BABYLON {
  111885. /**
  111886. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  111887. */
  111888. export class GeometryBufferRenderer {
  111889. /**
  111890. * Constant used to retrieve the position texture index in the G-Buffer textures array
  111891. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  111892. */
  111893. static readonly POSITION_TEXTURE_TYPE: number;
  111894. /**
  111895. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  111896. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  111897. */
  111898. static readonly VELOCITY_TEXTURE_TYPE: number;
  111899. /**
  111900. * Dictionary used to store the previous transformation matrices of each rendered mesh
  111901. * in order to compute objects velocities when enableVelocity is set to "true"
  111902. * @hidden
  111903. */
  111904. _previousTransformationMatrices: {
  111905. [index: number]: Matrix;
  111906. };
  111907. private _scene;
  111908. private _multiRenderTarget;
  111909. private _ratio;
  111910. private _enablePosition;
  111911. private _enableVelocity;
  111912. private _positionIndex;
  111913. private _velocityIndex;
  111914. protected _effect: Effect;
  111915. protected _cachedDefines: string;
  111916. /**
  111917. * Set the render list (meshes to be rendered) used in the G buffer.
  111918. */
  111919. renderList: Mesh[];
  111920. /**
  111921. * Gets wether or not G buffer are supported by the running hardware.
  111922. * This requires draw buffer supports
  111923. */
  111924. readonly isSupported: boolean;
  111925. /**
  111926. * Returns the index of the given texture type in the G-Buffer textures array
  111927. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  111928. * @returns the index of the given texture type in the G-Buffer textures array
  111929. */
  111930. getTextureIndex(textureType: number): number;
  111931. /**
  111932. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  111933. */
  111934. /**
  111935. * Sets whether or not objects positions are enabled for the G buffer.
  111936. */
  111937. enablePosition: boolean;
  111938. /**
  111939. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  111940. */
  111941. /**
  111942. * Sets wether or not objects velocities are enabled for the G buffer.
  111943. */
  111944. enableVelocity: boolean;
  111945. /**
  111946. * Gets the scene associated with the buffer.
  111947. */
  111948. readonly scene: Scene;
  111949. /**
  111950. * Gets the ratio used by the buffer during its creation.
  111951. * How big is the buffer related to the main canvas.
  111952. */
  111953. readonly ratio: number;
  111954. /** @hidden */
  111955. static _SceneComponentInitialization: (scene: Scene) => void;
  111956. /**
  111957. * Creates a new G Buffer for the scene
  111958. * @param scene The scene the buffer belongs to
  111959. * @param ratio How big is the buffer related to the main canvas.
  111960. */
  111961. constructor(scene: Scene, ratio?: number);
  111962. /**
  111963. * Checks wether everything is ready to render a submesh to the G buffer.
  111964. * @param subMesh the submesh to check readiness for
  111965. * @param useInstances is the mesh drawn using instance or not
  111966. * @returns true if ready otherwise false
  111967. */
  111968. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  111969. /**
  111970. * Gets the current underlying G Buffer.
  111971. * @returns the buffer
  111972. */
  111973. getGBuffer(): MultiRenderTarget;
  111974. /**
  111975. * Gets the number of samples used to render the buffer (anti aliasing).
  111976. */
  111977. /**
  111978. * Sets the number of samples used to render the buffer (anti aliasing).
  111979. */
  111980. samples: number;
  111981. /**
  111982. * Disposes the renderer and frees up associated resources.
  111983. */
  111984. dispose(): void;
  111985. protected _createRenderTargets(): void;
  111986. }
  111987. }
  111988. declare module BABYLON {
  111989. interface Scene {
  111990. /** @hidden (Backing field) */
  111991. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  111992. /**
  111993. * Gets or Sets the current geometry buffer associated to the scene.
  111994. */
  111995. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  111996. /**
  111997. * Enables a GeometryBufferRender and associates it with the scene
  111998. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  111999. * @returns the GeometryBufferRenderer
  112000. */
  112001. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  112002. /**
  112003. * Disables the GeometryBufferRender associated with the scene
  112004. */
  112005. disableGeometryBufferRenderer(): void;
  112006. }
  112007. /**
  112008. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  112009. * in several rendering techniques.
  112010. */
  112011. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  112012. /**
  112013. * The component name helpful to identify the component in the list of scene components.
  112014. */
  112015. readonly name: string;
  112016. /**
  112017. * The scene the component belongs to.
  112018. */
  112019. scene: Scene;
  112020. /**
  112021. * Creates a new instance of the component for the given scene
  112022. * @param scene Defines the scene to register the component in
  112023. */
  112024. constructor(scene: Scene);
  112025. /**
  112026. * Registers the component in a given scene
  112027. */
  112028. register(): void;
  112029. /**
  112030. * Rebuilds the elements related to this component in case of
  112031. * context lost for instance.
  112032. */
  112033. rebuild(): void;
  112034. /**
  112035. * Disposes the component and the associated ressources
  112036. */
  112037. dispose(): void;
  112038. private _gatherRenderTargets;
  112039. }
  112040. }
  112041. declare module BABYLON {
  112042. /** @hidden */
  112043. export var motionBlurPixelShader: {
  112044. name: string;
  112045. shader: string;
  112046. };
  112047. }
  112048. declare module BABYLON {
  112049. /**
  112050. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  112051. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  112052. * As an example, all you have to do is to create the post-process:
  112053. * var mb = new BABYLON.MotionBlurPostProcess(
  112054. * 'mb', // The name of the effect.
  112055. * scene, // The scene containing the objects to blur according to their velocity.
  112056. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  112057. * camera // The camera to apply the render pass to.
  112058. * );
  112059. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  112060. */
  112061. export class MotionBlurPostProcess extends PostProcess {
  112062. /**
  112063. * Defines how much the image is blurred by the movement. Default value is equal to 1
  112064. */
  112065. motionStrength: number;
  112066. /**
  112067. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  112068. */
  112069. /**
  112070. * Sets the number of iterations to be used for motion blur quality
  112071. */
  112072. motionBlurSamples: number;
  112073. private _motionBlurSamples;
  112074. private _geometryBufferRenderer;
  112075. /**
  112076. * Creates a new instance MotionBlurPostProcess
  112077. * @param name The name of the effect.
  112078. * @param scene The scene containing the objects to blur according to their velocity.
  112079. * @param options The required width/height ratio to downsize to before computing the render pass.
  112080. * @param camera The camera to apply the render pass to.
  112081. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  112082. * @param engine The engine which the post process will be applied. (default: current engine)
  112083. * @param reusable If the post process can be reused on the same frame. (default: false)
  112084. * @param textureType Type of textures used when performing the post process. (default: 0)
  112085. * @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)
  112086. */
  112087. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  112088. /**
  112089. * Disposes the post process.
  112090. * @param camera The camera to dispose the post process on.
  112091. */
  112092. dispose(camera?: Camera): void;
  112093. }
  112094. }
  112095. declare module BABYLON {
  112096. /** @hidden */
  112097. export var refractionPixelShader: {
  112098. name: string;
  112099. shader: string;
  112100. };
  112101. }
  112102. declare module BABYLON {
  112103. /**
  112104. * Post process which applies a refractin texture
  112105. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  112106. */
  112107. export class RefractionPostProcess extends PostProcess {
  112108. /** the base color of the refraction (used to taint the rendering) */
  112109. color: Color3;
  112110. /** simulated refraction depth */
  112111. depth: number;
  112112. /** the coefficient of the base color (0 to remove base color tainting) */
  112113. colorLevel: number;
  112114. private _refTexture;
  112115. private _ownRefractionTexture;
  112116. /**
  112117. * Gets or sets the refraction texture
  112118. * Please note that you are responsible for disposing the texture if you set it manually
  112119. */
  112120. refractionTexture: Texture;
  112121. /**
  112122. * Initializes the RefractionPostProcess
  112123. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  112124. * @param name The name of the effect.
  112125. * @param refractionTextureUrl Url of the refraction texture to use
  112126. * @param color the base color of the refraction (used to taint the rendering)
  112127. * @param depth simulated refraction depth
  112128. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  112129. * @param camera The camera to apply the render pass to.
  112130. * @param options The required width/height ratio to downsize to before computing the render pass.
  112131. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  112132. * @param engine The engine which the post process will be applied. (default: current engine)
  112133. * @param reusable If the post process can be reused on the same frame. (default: false)
  112134. */
  112135. constructor(name: string, refractionTextureUrl: string,
  112136. /** the base color of the refraction (used to taint the rendering) */
  112137. color: Color3,
  112138. /** simulated refraction depth */
  112139. depth: number,
  112140. /** the coefficient of the base color (0 to remove base color tainting) */
  112141. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  112142. /**
  112143. * Disposes of the post process
  112144. * @param camera Camera to dispose post process on
  112145. */
  112146. dispose(camera: Camera): void;
  112147. }
  112148. }
  112149. declare module BABYLON {
  112150. /** @hidden */
  112151. export var sharpenPixelShader: {
  112152. name: string;
  112153. shader: string;
  112154. };
  112155. }
  112156. declare module BABYLON {
  112157. /**
  112158. * The SharpenPostProcess applies a sharpen kernel to every pixel
  112159. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  112160. */
  112161. export class SharpenPostProcess extends PostProcess {
  112162. /**
  112163. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  112164. */
  112165. colorAmount: number;
  112166. /**
  112167. * How much sharpness should be applied (default: 0.3)
  112168. */
  112169. edgeAmount: number;
  112170. /**
  112171. * Creates a new instance ConvolutionPostProcess
  112172. * @param name The name of the effect.
  112173. * @param options The required width/height ratio to downsize to before computing the render pass.
  112174. * @param camera The camera to apply the render pass to.
  112175. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  112176. * @param engine The engine which the post process will be applied. (default: current engine)
  112177. * @param reusable If the post process can be reused on the same frame. (default: false)
  112178. * @param textureType Type of textures used when performing the post process. (default: 0)
  112179. * @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)
  112180. */
  112181. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  112182. }
  112183. }
  112184. declare module BABYLON {
  112185. /**
  112186. * PostProcessRenderPipeline
  112187. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  112188. */
  112189. export class PostProcessRenderPipeline {
  112190. private engine;
  112191. private _renderEffects;
  112192. private _renderEffectsForIsolatedPass;
  112193. /**
  112194. * List of inspectable custom properties (used by the Inspector)
  112195. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  112196. */
  112197. inspectableCustomProperties: IInspectable[];
  112198. /**
  112199. * @hidden
  112200. */
  112201. protected _cameras: Camera[];
  112202. /** @hidden */
  112203. _name: string;
  112204. /**
  112205. * Gets pipeline name
  112206. */
  112207. readonly name: string;
  112208. /**
  112209. * Initializes a PostProcessRenderPipeline
  112210. * @param engine engine to add the pipeline to
  112211. * @param name name of the pipeline
  112212. */
  112213. constructor(engine: Engine, name: string);
  112214. /**
  112215. * Gets the class name
  112216. * @returns "PostProcessRenderPipeline"
  112217. */
  112218. getClassName(): string;
  112219. /**
  112220. * If all the render effects in the pipeline are supported
  112221. */
  112222. readonly isSupported: boolean;
  112223. /**
  112224. * Adds an effect to the pipeline
  112225. * @param renderEffect the effect to add
  112226. */
  112227. addEffect(renderEffect: PostProcessRenderEffect): void;
  112228. /** @hidden */
  112229. _rebuild(): void;
  112230. /** @hidden */
  112231. _enableEffect(renderEffectName: string, cameras: Camera): void;
  112232. /** @hidden */
  112233. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  112234. /** @hidden */
  112235. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  112236. /** @hidden */
  112237. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  112238. /** @hidden */
  112239. _attachCameras(cameras: Camera, unique: boolean): void;
  112240. /** @hidden */
  112241. _attachCameras(cameras: Camera[], unique: boolean): void;
  112242. /** @hidden */
  112243. _detachCameras(cameras: Camera): void;
  112244. /** @hidden */
  112245. _detachCameras(cameras: Nullable<Camera[]>): void;
  112246. /** @hidden */
  112247. _update(): void;
  112248. /** @hidden */
  112249. _reset(): void;
  112250. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  112251. /**
  112252. * Disposes of the pipeline
  112253. */
  112254. dispose(): void;
  112255. }
  112256. }
  112257. declare module BABYLON {
  112258. /**
  112259. * PostProcessRenderPipelineManager class
  112260. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  112261. */
  112262. export class PostProcessRenderPipelineManager {
  112263. private _renderPipelines;
  112264. /**
  112265. * Initializes a PostProcessRenderPipelineManager
  112266. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  112267. */
  112268. constructor();
  112269. /**
  112270. * Gets the list of supported render pipelines
  112271. */
  112272. readonly supportedPipelines: PostProcessRenderPipeline[];
  112273. /**
  112274. * Adds a pipeline to the manager
  112275. * @param renderPipeline The pipeline to add
  112276. */
  112277. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  112278. /**
  112279. * Attaches a camera to the pipeline
  112280. * @param renderPipelineName The name of the pipeline to attach to
  112281. * @param cameras the camera to attach
  112282. * @param unique if the camera can be attached multiple times to the pipeline
  112283. */
  112284. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  112285. /**
  112286. * Detaches a camera from the pipeline
  112287. * @param renderPipelineName The name of the pipeline to detach from
  112288. * @param cameras the camera to detach
  112289. */
  112290. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  112291. /**
  112292. * Enables an effect by name on a pipeline
  112293. * @param renderPipelineName the name of the pipeline to enable the effect in
  112294. * @param renderEffectName the name of the effect to enable
  112295. * @param cameras the cameras that the effect should be enabled on
  112296. */
  112297. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  112298. /**
  112299. * Disables an effect by name on a pipeline
  112300. * @param renderPipelineName the name of the pipeline to disable the effect in
  112301. * @param renderEffectName the name of the effect to disable
  112302. * @param cameras the cameras that the effect should be disabled on
  112303. */
  112304. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  112305. /**
  112306. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  112307. */
  112308. update(): void;
  112309. /** @hidden */
  112310. _rebuild(): void;
  112311. /**
  112312. * Disposes of the manager and pipelines
  112313. */
  112314. dispose(): void;
  112315. }
  112316. }
  112317. declare module BABYLON {
  112318. interface Scene {
  112319. /** @hidden (Backing field) */
  112320. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  112321. /**
  112322. * Gets the postprocess render pipeline manager
  112323. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  112324. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  112325. */
  112326. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  112327. }
  112328. /**
  112329. * Defines the Render Pipeline scene component responsible to rendering pipelines
  112330. */
  112331. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  112332. /**
  112333. * The component name helpfull to identify the component in the list of scene components.
  112334. */
  112335. readonly name: string;
  112336. /**
  112337. * The scene the component belongs to.
  112338. */
  112339. scene: Scene;
  112340. /**
  112341. * Creates a new instance of the component for the given scene
  112342. * @param scene Defines the scene to register the component in
  112343. */
  112344. constructor(scene: Scene);
  112345. /**
  112346. * Registers the component in a given scene
  112347. */
  112348. register(): void;
  112349. /**
  112350. * Rebuilds the elements related to this component in case of
  112351. * context lost for instance.
  112352. */
  112353. rebuild(): void;
  112354. /**
  112355. * Disposes the component and the associated ressources
  112356. */
  112357. dispose(): void;
  112358. private _gatherRenderTargets;
  112359. }
  112360. }
  112361. declare module BABYLON {
  112362. /**
  112363. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  112364. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  112365. */
  112366. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  112367. private _scene;
  112368. private _camerasToBeAttached;
  112369. /**
  112370. * ID of the sharpen post process,
  112371. */
  112372. private readonly SharpenPostProcessId;
  112373. /**
  112374. * @ignore
  112375. * ID of the image processing post process;
  112376. */
  112377. readonly ImageProcessingPostProcessId: string;
  112378. /**
  112379. * @ignore
  112380. * ID of the Fast Approximate Anti-Aliasing post process;
  112381. */
  112382. readonly FxaaPostProcessId: string;
  112383. /**
  112384. * ID of the chromatic aberration post process,
  112385. */
  112386. private readonly ChromaticAberrationPostProcessId;
  112387. /**
  112388. * ID of the grain post process
  112389. */
  112390. private readonly GrainPostProcessId;
  112391. /**
  112392. * Sharpen post process which will apply a sharpen convolution to enhance edges
  112393. */
  112394. sharpen: SharpenPostProcess;
  112395. private _sharpenEffect;
  112396. private bloom;
  112397. /**
  112398. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  112399. */
  112400. depthOfField: DepthOfFieldEffect;
  112401. /**
  112402. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  112403. */
  112404. fxaa: FxaaPostProcess;
  112405. /**
  112406. * Image post processing pass used to perform operations such as tone mapping or color grading.
  112407. */
  112408. imageProcessing: ImageProcessingPostProcess;
  112409. /**
  112410. * Chromatic aberration post process which will shift rgb colors in the image
  112411. */
  112412. chromaticAberration: ChromaticAberrationPostProcess;
  112413. private _chromaticAberrationEffect;
  112414. /**
  112415. * Grain post process which add noise to the image
  112416. */
  112417. grain: GrainPostProcess;
  112418. private _grainEffect;
  112419. /**
  112420. * Glow post process which adds a glow to emissive areas of the image
  112421. */
  112422. private _glowLayer;
  112423. /**
  112424. * Animations which can be used to tweak settings over a period of time
  112425. */
  112426. animations: Animation[];
  112427. private _imageProcessingConfigurationObserver;
  112428. private _sharpenEnabled;
  112429. private _bloomEnabled;
  112430. private _depthOfFieldEnabled;
  112431. private _depthOfFieldBlurLevel;
  112432. private _fxaaEnabled;
  112433. private _imageProcessingEnabled;
  112434. private _defaultPipelineTextureType;
  112435. private _bloomScale;
  112436. private _chromaticAberrationEnabled;
  112437. private _grainEnabled;
  112438. private _buildAllowed;
  112439. /**
  112440. * Gets active scene
  112441. */
  112442. readonly scene: Scene;
  112443. /**
  112444. * Enable or disable the sharpen process from the pipeline
  112445. */
  112446. sharpenEnabled: boolean;
  112447. private _resizeObserver;
  112448. private _hardwareScaleLevel;
  112449. private _bloomKernel;
  112450. /**
  112451. * Specifies the size of the bloom blur kernel, relative to the final output size
  112452. */
  112453. bloomKernel: number;
  112454. /**
  112455. * Specifies the weight of the bloom in the final rendering
  112456. */
  112457. private _bloomWeight;
  112458. /**
  112459. * Specifies the luma threshold for the area that will be blurred by the bloom
  112460. */
  112461. private _bloomThreshold;
  112462. private _hdr;
  112463. /**
  112464. * The strength of the bloom.
  112465. */
  112466. bloomWeight: number;
  112467. /**
  112468. * The strength of the bloom.
  112469. */
  112470. bloomThreshold: number;
  112471. /**
  112472. * The scale of the bloom, lower value will provide better performance.
  112473. */
  112474. bloomScale: number;
  112475. /**
  112476. * Enable or disable the bloom from the pipeline
  112477. */
  112478. bloomEnabled: boolean;
  112479. private _rebuildBloom;
  112480. /**
  112481. * If the depth of field is enabled.
  112482. */
  112483. depthOfFieldEnabled: boolean;
  112484. /**
  112485. * Blur level of the depth of field effect. (Higher blur will effect performance)
  112486. */
  112487. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  112488. /**
  112489. * If the anti aliasing is enabled.
  112490. */
  112491. fxaaEnabled: boolean;
  112492. private _samples;
  112493. /**
  112494. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  112495. */
  112496. samples: number;
  112497. /**
  112498. * If image processing is enabled.
  112499. */
  112500. imageProcessingEnabled: boolean;
  112501. /**
  112502. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  112503. */
  112504. glowLayerEnabled: boolean;
  112505. /**
  112506. * Enable or disable the chromaticAberration process from the pipeline
  112507. */
  112508. chromaticAberrationEnabled: boolean;
  112509. /**
  112510. * Enable or disable the grain process from the pipeline
  112511. */
  112512. grainEnabled: boolean;
  112513. /**
  112514. * @constructor
  112515. * @param name - The rendering pipeline name (default: "")
  112516. * @param hdr - If high dynamic range textures should be used (default: true)
  112517. * @param scene - The scene linked to this pipeline (default: the last created scene)
  112518. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  112519. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  112520. */
  112521. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  112522. /**
  112523. * Get the class name
  112524. * @returns "DefaultRenderingPipeline"
  112525. */
  112526. getClassName(): string;
  112527. /**
  112528. * Force the compilation of the entire pipeline.
  112529. */
  112530. prepare(): void;
  112531. private _hasCleared;
  112532. private _prevPostProcess;
  112533. private _prevPrevPostProcess;
  112534. private _setAutoClearAndTextureSharing;
  112535. private _depthOfFieldSceneObserver;
  112536. private _buildPipeline;
  112537. private _disposePostProcesses;
  112538. /**
  112539. * Adds a camera to the pipeline
  112540. * @param camera the camera to be added
  112541. */
  112542. addCamera(camera: Camera): void;
  112543. /**
  112544. * Removes a camera from the pipeline
  112545. * @param camera the camera to remove
  112546. */
  112547. removeCamera(camera: Camera): void;
  112548. /**
  112549. * Dispose of the pipeline and stop all post processes
  112550. */
  112551. dispose(): void;
  112552. /**
  112553. * Serialize the rendering pipeline (Used when exporting)
  112554. * @returns the serialized object
  112555. */
  112556. serialize(): any;
  112557. /**
  112558. * Parse the serialized pipeline
  112559. * @param source Source pipeline.
  112560. * @param scene The scene to load the pipeline to.
  112561. * @param rootUrl The URL of the serialized pipeline.
  112562. * @returns An instantiated pipeline from the serialized object.
  112563. */
  112564. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  112565. }
  112566. }
  112567. declare module BABYLON {
  112568. /** @hidden */
  112569. export var lensHighlightsPixelShader: {
  112570. name: string;
  112571. shader: string;
  112572. };
  112573. }
  112574. declare module BABYLON {
  112575. /** @hidden */
  112576. export var depthOfFieldPixelShader: {
  112577. name: string;
  112578. shader: string;
  112579. };
  112580. }
  112581. declare module BABYLON {
  112582. /**
  112583. * BABYLON.JS Chromatic Aberration GLSL Shader
  112584. * Author: Olivier Guyot
  112585. * Separates very slightly R, G and B colors on the edges of the screen
  112586. * Inspired by Francois Tarlier & Martins Upitis
  112587. */
  112588. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  112589. /**
  112590. * @ignore
  112591. * The chromatic aberration PostProcess id in the pipeline
  112592. */
  112593. LensChromaticAberrationEffect: string;
  112594. /**
  112595. * @ignore
  112596. * The highlights enhancing PostProcess id in the pipeline
  112597. */
  112598. HighlightsEnhancingEffect: string;
  112599. /**
  112600. * @ignore
  112601. * The depth-of-field PostProcess id in the pipeline
  112602. */
  112603. LensDepthOfFieldEffect: string;
  112604. private _scene;
  112605. private _depthTexture;
  112606. private _grainTexture;
  112607. private _chromaticAberrationPostProcess;
  112608. private _highlightsPostProcess;
  112609. private _depthOfFieldPostProcess;
  112610. private _edgeBlur;
  112611. private _grainAmount;
  112612. private _chromaticAberration;
  112613. private _distortion;
  112614. private _highlightsGain;
  112615. private _highlightsThreshold;
  112616. private _dofDistance;
  112617. private _dofAperture;
  112618. private _dofDarken;
  112619. private _dofPentagon;
  112620. private _blurNoise;
  112621. /**
  112622. * @constructor
  112623. *
  112624. * Effect parameters are as follow:
  112625. * {
  112626. * chromatic_aberration: number; // from 0 to x (1 for realism)
  112627. * edge_blur: number; // from 0 to x (1 for realism)
  112628. * distortion: number; // from 0 to x (1 for realism)
  112629. * grain_amount: number; // from 0 to 1
  112630. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  112631. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  112632. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  112633. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  112634. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  112635. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  112636. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  112637. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  112638. * }
  112639. * Note: if an effect parameter is unset, effect is disabled
  112640. *
  112641. * @param name The rendering pipeline name
  112642. * @param parameters - An object containing all parameters (see above)
  112643. * @param scene The scene linked to this pipeline
  112644. * @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)
  112645. * @param cameras The array of cameras that the rendering pipeline will be attached to
  112646. */
  112647. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  112648. /**
  112649. * Get the class name
  112650. * @returns "LensRenderingPipeline"
  112651. */
  112652. getClassName(): string;
  112653. /**
  112654. * Gets associated scene
  112655. */
  112656. readonly scene: Scene;
  112657. /**
  112658. * Gets or sets the edge blur
  112659. */
  112660. edgeBlur: number;
  112661. /**
  112662. * Gets or sets the grain amount
  112663. */
  112664. grainAmount: number;
  112665. /**
  112666. * Gets or sets the chromatic aberration amount
  112667. */
  112668. chromaticAberration: number;
  112669. /**
  112670. * Gets or sets the depth of field aperture
  112671. */
  112672. dofAperture: number;
  112673. /**
  112674. * Gets or sets the edge distortion
  112675. */
  112676. edgeDistortion: number;
  112677. /**
  112678. * Gets or sets the depth of field distortion
  112679. */
  112680. dofDistortion: number;
  112681. /**
  112682. * Gets or sets the darken out of focus amount
  112683. */
  112684. darkenOutOfFocus: number;
  112685. /**
  112686. * Gets or sets a boolean indicating if blur noise is enabled
  112687. */
  112688. blurNoise: boolean;
  112689. /**
  112690. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  112691. */
  112692. pentagonBokeh: boolean;
  112693. /**
  112694. * Gets or sets the highlight grain amount
  112695. */
  112696. highlightsGain: number;
  112697. /**
  112698. * Gets or sets the highlight threshold
  112699. */
  112700. highlightsThreshold: number;
  112701. /**
  112702. * Sets the amount of blur at the edges
  112703. * @param amount blur amount
  112704. */
  112705. setEdgeBlur(amount: number): void;
  112706. /**
  112707. * Sets edge blur to 0
  112708. */
  112709. disableEdgeBlur(): void;
  112710. /**
  112711. * Sets the amout of grain
  112712. * @param amount Amount of grain
  112713. */
  112714. setGrainAmount(amount: number): void;
  112715. /**
  112716. * Set grain amount to 0
  112717. */
  112718. disableGrain(): void;
  112719. /**
  112720. * Sets the chromatic aberration amount
  112721. * @param amount amount of chromatic aberration
  112722. */
  112723. setChromaticAberration(amount: number): void;
  112724. /**
  112725. * Sets chromatic aberration amount to 0
  112726. */
  112727. disableChromaticAberration(): void;
  112728. /**
  112729. * Sets the EdgeDistortion amount
  112730. * @param amount amount of EdgeDistortion
  112731. */
  112732. setEdgeDistortion(amount: number): void;
  112733. /**
  112734. * Sets edge distortion to 0
  112735. */
  112736. disableEdgeDistortion(): void;
  112737. /**
  112738. * Sets the FocusDistance amount
  112739. * @param amount amount of FocusDistance
  112740. */
  112741. setFocusDistance(amount: number): void;
  112742. /**
  112743. * Disables depth of field
  112744. */
  112745. disableDepthOfField(): void;
  112746. /**
  112747. * Sets the Aperture amount
  112748. * @param amount amount of Aperture
  112749. */
  112750. setAperture(amount: number): void;
  112751. /**
  112752. * Sets the DarkenOutOfFocus amount
  112753. * @param amount amount of DarkenOutOfFocus
  112754. */
  112755. setDarkenOutOfFocus(amount: number): void;
  112756. private _pentagonBokehIsEnabled;
  112757. /**
  112758. * Creates a pentagon bokeh effect
  112759. */
  112760. enablePentagonBokeh(): void;
  112761. /**
  112762. * Disables the pentagon bokeh effect
  112763. */
  112764. disablePentagonBokeh(): void;
  112765. /**
  112766. * Enables noise blur
  112767. */
  112768. enableNoiseBlur(): void;
  112769. /**
  112770. * Disables noise blur
  112771. */
  112772. disableNoiseBlur(): void;
  112773. /**
  112774. * Sets the HighlightsGain amount
  112775. * @param amount amount of HighlightsGain
  112776. */
  112777. setHighlightsGain(amount: number): void;
  112778. /**
  112779. * Sets the HighlightsThreshold amount
  112780. * @param amount amount of HighlightsThreshold
  112781. */
  112782. setHighlightsThreshold(amount: number): void;
  112783. /**
  112784. * Disables highlights
  112785. */
  112786. disableHighlights(): void;
  112787. /**
  112788. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  112789. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  112790. */
  112791. dispose(disableDepthRender?: boolean): void;
  112792. private _createChromaticAberrationPostProcess;
  112793. private _createHighlightsPostProcess;
  112794. private _createDepthOfFieldPostProcess;
  112795. private _createGrainTexture;
  112796. }
  112797. }
  112798. declare module BABYLON {
  112799. /** @hidden */
  112800. export var ssao2PixelShader: {
  112801. name: string;
  112802. shader: string;
  112803. };
  112804. }
  112805. declare module BABYLON {
  112806. /** @hidden */
  112807. export var ssaoCombinePixelShader: {
  112808. name: string;
  112809. shader: string;
  112810. };
  112811. }
  112812. declare module BABYLON {
  112813. /**
  112814. * Render pipeline to produce ssao effect
  112815. */
  112816. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  112817. /**
  112818. * @ignore
  112819. * The PassPostProcess id in the pipeline that contains the original scene color
  112820. */
  112821. SSAOOriginalSceneColorEffect: string;
  112822. /**
  112823. * @ignore
  112824. * The SSAO PostProcess id in the pipeline
  112825. */
  112826. SSAORenderEffect: string;
  112827. /**
  112828. * @ignore
  112829. * The horizontal blur PostProcess id in the pipeline
  112830. */
  112831. SSAOBlurHRenderEffect: string;
  112832. /**
  112833. * @ignore
  112834. * The vertical blur PostProcess id in the pipeline
  112835. */
  112836. SSAOBlurVRenderEffect: string;
  112837. /**
  112838. * @ignore
  112839. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  112840. */
  112841. SSAOCombineRenderEffect: string;
  112842. /**
  112843. * The output strength of the SSAO post-process. Default value is 1.0.
  112844. */
  112845. totalStrength: number;
  112846. /**
  112847. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  112848. */
  112849. maxZ: number;
  112850. /**
  112851. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  112852. */
  112853. minZAspect: number;
  112854. private _samples;
  112855. /**
  112856. * Number of samples used for the SSAO calculations. Default value is 8
  112857. */
  112858. samples: number;
  112859. private _textureSamples;
  112860. /**
  112861. * Number of samples to use for antialiasing
  112862. */
  112863. textureSamples: number;
  112864. /**
  112865. * Ratio object used for SSAO ratio and blur ratio
  112866. */
  112867. private _ratio;
  112868. /**
  112869. * Dynamically generated sphere sampler.
  112870. */
  112871. private _sampleSphere;
  112872. /**
  112873. * Blur filter offsets
  112874. */
  112875. private _samplerOffsets;
  112876. private _expensiveBlur;
  112877. /**
  112878. * If bilateral blur should be used
  112879. */
  112880. expensiveBlur: boolean;
  112881. /**
  112882. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  112883. */
  112884. radius: number;
  112885. /**
  112886. * The base color of the SSAO post-process
  112887. * The final result is "base + ssao" between [0, 1]
  112888. */
  112889. base: number;
  112890. /**
  112891. * Support test.
  112892. */
  112893. static readonly IsSupported: boolean;
  112894. private _scene;
  112895. private _depthTexture;
  112896. private _normalTexture;
  112897. private _randomTexture;
  112898. private _originalColorPostProcess;
  112899. private _ssaoPostProcess;
  112900. private _blurHPostProcess;
  112901. private _blurVPostProcess;
  112902. private _ssaoCombinePostProcess;
  112903. private _firstUpdate;
  112904. /**
  112905. * Gets active scene
  112906. */
  112907. readonly scene: Scene;
  112908. /**
  112909. * @constructor
  112910. * @param name The rendering pipeline name
  112911. * @param scene The scene linked to this pipeline
  112912. * @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 }
  112913. * @param cameras The array of cameras that the rendering pipeline will be attached to
  112914. */
  112915. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  112916. /**
  112917. * Get the class name
  112918. * @returns "SSAO2RenderingPipeline"
  112919. */
  112920. getClassName(): string;
  112921. /**
  112922. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  112923. */
  112924. dispose(disableGeometryBufferRenderer?: boolean): void;
  112925. private _createBlurPostProcess;
  112926. /** @hidden */
  112927. _rebuild(): void;
  112928. private _bits;
  112929. private _radicalInverse_VdC;
  112930. private _hammersley;
  112931. private _hemisphereSample_uniform;
  112932. private _generateHemisphere;
  112933. private _createSSAOPostProcess;
  112934. private _createSSAOCombinePostProcess;
  112935. private _createRandomTexture;
  112936. /**
  112937. * Serialize the rendering pipeline (Used when exporting)
  112938. * @returns the serialized object
  112939. */
  112940. serialize(): any;
  112941. /**
  112942. * Parse the serialized pipeline
  112943. * @param source Source pipeline.
  112944. * @param scene The scene to load the pipeline to.
  112945. * @param rootUrl The URL of the serialized pipeline.
  112946. * @returns An instantiated pipeline from the serialized object.
  112947. */
  112948. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  112949. }
  112950. }
  112951. declare module BABYLON {
  112952. /** @hidden */
  112953. export var ssaoPixelShader: {
  112954. name: string;
  112955. shader: string;
  112956. };
  112957. }
  112958. declare module BABYLON {
  112959. /**
  112960. * Render pipeline to produce ssao effect
  112961. */
  112962. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  112963. /**
  112964. * @ignore
  112965. * The PassPostProcess id in the pipeline that contains the original scene color
  112966. */
  112967. SSAOOriginalSceneColorEffect: string;
  112968. /**
  112969. * @ignore
  112970. * The SSAO PostProcess id in the pipeline
  112971. */
  112972. SSAORenderEffect: string;
  112973. /**
  112974. * @ignore
  112975. * The horizontal blur PostProcess id in the pipeline
  112976. */
  112977. SSAOBlurHRenderEffect: string;
  112978. /**
  112979. * @ignore
  112980. * The vertical blur PostProcess id in the pipeline
  112981. */
  112982. SSAOBlurVRenderEffect: string;
  112983. /**
  112984. * @ignore
  112985. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  112986. */
  112987. SSAOCombineRenderEffect: string;
  112988. /**
  112989. * The output strength of the SSAO post-process. Default value is 1.0.
  112990. */
  112991. totalStrength: number;
  112992. /**
  112993. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  112994. */
  112995. radius: number;
  112996. /**
  112997. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  112998. * Must not be equal to fallOff and superior to fallOff.
  112999. * Default value is 0.0075
  113000. */
  113001. area: number;
  113002. /**
  113003. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  113004. * Must not be equal to area and inferior to area.
  113005. * Default value is 0.000001
  113006. */
  113007. fallOff: number;
  113008. /**
  113009. * The base color of the SSAO post-process
  113010. * The final result is "base + ssao" between [0, 1]
  113011. */
  113012. base: number;
  113013. private _scene;
  113014. private _depthTexture;
  113015. private _randomTexture;
  113016. private _originalColorPostProcess;
  113017. private _ssaoPostProcess;
  113018. private _blurHPostProcess;
  113019. private _blurVPostProcess;
  113020. private _ssaoCombinePostProcess;
  113021. private _firstUpdate;
  113022. /**
  113023. * Gets active scene
  113024. */
  113025. readonly scene: Scene;
  113026. /**
  113027. * @constructor
  113028. * @param name - The rendering pipeline name
  113029. * @param scene - The scene linked to this pipeline
  113030. * @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 }
  113031. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  113032. */
  113033. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  113034. /**
  113035. * Get the class name
  113036. * @returns "SSAORenderingPipeline"
  113037. */
  113038. getClassName(): string;
  113039. /**
  113040. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  113041. */
  113042. dispose(disableDepthRender?: boolean): void;
  113043. private _createBlurPostProcess;
  113044. /** @hidden */
  113045. _rebuild(): void;
  113046. private _createSSAOPostProcess;
  113047. private _createSSAOCombinePostProcess;
  113048. private _createRandomTexture;
  113049. }
  113050. }
  113051. declare module BABYLON {
  113052. /** @hidden */
  113053. export var standardPixelShader: {
  113054. name: string;
  113055. shader: string;
  113056. };
  113057. }
  113058. declare module BABYLON {
  113059. /**
  113060. * Standard rendering pipeline
  113061. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  113062. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  113063. */
  113064. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  113065. /**
  113066. * Public members
  113067. */
  113068. /**
  113069. * Post-process which contains the original scene color before the pipeline applies all the effects
  113070. */
  113071. originalPostProcess: Nullable<PostProcess>;
  113072. /**
  113073. * Post-process used to down scale an image x4
  113074. */
  113075. downSampleX4PostProcess: Nullable<PostProcess>;
  113076. /**
  113077. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  113078. */
  113079. brightPassPostProcess: Nullable<PostProcess>;
  113080. /**
  113081. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  113082. */
  113083. blurHPostProcesses: PostProcess[];
  113084. /**
  113085. * Post-process array storing all the vertical blur post-processes used by the pipeline
  113086. */
  113087. blurVPostProcesses: PostProcess[];
  113088. /**
  113089. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  113090. */
  113091. textureAdderPostProcess: Nullable<PostProcess>;
  113092. /**
  113093. * Post-process used to create volumetric lighting effect
  113094. */
  113095. volumetricLightPostProcess: Nullable<PostProcess>;
  113096. /**
  113097. * Post-process used to smooth the previous volumetric light post-process on the X axis
  113098. */
  113099. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  113100. /**
  113101. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  113102. */
  113103. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  113104. /**
  113105. * Post-process used to merge the volumetric light effect and the real scene color
  113106. */
  113107. volumetricLightMergePostProces: Nullable<PostProcess>;
  113108. /**
  113109. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  113110. */
  113111. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  113112. /**
  113113. * Base post-process used to calculate the average luminance of the final image for HDR
  113114. */
  113115. luminancePostProcess: Nullable<PostProcess>;
  113116. /**
  113117. * Post-processes used to create down sample post-processes in order to get
  113118. * the average luminance of the final image for HDR
  113119. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  113120. */
  113121. luminanceDownSamplePostProcesses: PostProcess[];
  113122. /**
  113123. * Post-process used to create a HDR effect (light adaptation)
  113124. */
  113125. hdrPostProcess: Nullable<PostProcess>;
  113126. /**
  113127. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  113128. */
  113129. textureAdderFinalPostProcess: Nullable<PostProcess>;
  113130. /**
  113131. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  113132. */
  113133. lensFlareFinalPostProcess: Nullable<PostProcess>;
  113134. /**
  113135. * Post-process used to merge the final HDR post-process and the real scene color
  113136. */
  113137. hdrFinalPostProcess: Nullable<PostProcess>;
  113138. /**
  113139. * Post-process used to create a lens flare effect
  113140. */
  113141. lensFlarePostProcess: Nullable<PostProcess>;
  113142. /**
  113143. * Post-process that merges the result of the lens flare post-process and the real scene color
  113144. */
  113145. lensFlareComposePostProcess: Nullable<PostProcess>;
  113146. /**
  113147. * Post-process used to create a motion blur effect
  113148. */
  113149. motionBlurPostProcess: Nullable<PostProcess>;
  113150. /**
  113151. * Post-process used to create a depth of field effect
  113152. */
  113153. depthOfFieldPostProcess: Nullable<PostProcess>;
  113154. /**
  113155. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  113156. */
  113157. fxaaPostProcess: Nullable<FxaaPostProcess>;
  113158. /**
  113159. * Represents the brightness threshold in order to configure the illuminated surfaces
  113160. */
  113161. brightThreshold: number;
  113162. /**
  113163. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  113164. */
  113165. blurWidth: number;
  113166. /**
  113167. * Sets if the blur for highlighted surfaces must be only horizontal
  113168. */
  113169. horizontalBlur: boolean;
  113170. /**
  113171. * Gets the overall exposure used by the pipeline
  113172. */
  113173. /**
  113174. * Sets the overall exposure used by the pipeline
  113175. */
  113176. exposure: number;
  113177. /**
  113178. * Texture used typically to simulate "dirty" on camera lens
  113179. */
  113180. lensTexture: Nullable<Texture>;
  113181. /**
  113182. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  113183. */
  113184. volumetricLightCoefficient: number;
  113185. /**
  113186. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  113187. */
  113188. volumetricLightPower: number;
  113189. /**
  113190. * Used the set the blur intensity to smooth the volumetric lights
  113191. */
  113192. volumetricLightBlurScale: number;
  113193. /**
  113194. * Light (spot or directional) used to generate the volumetric lights rays
  113195. * The source light must have a shadow generate so the pipeline can get its
  113196. * depth map
  113197. */
  113198. sourceLight: Nullable<SpotLight | DirectionalLight>;
  113199. /**
  113200. * For eye adaptation, represents the minimum luminance the eye can see
  113201. */
  113202. hdrMinimumLuminance: number;
  113203. /**
  113204. * For eye adaptation, represents the decrease luminance speed
  113205. */
  113206. hdrDecreaseRate: number;
  113207. /**
  113208. * For eye adaptation, represents the increase luminance speed
  113209. */
  113210. hdrIncreaseRate: number;
  113211. /**
  113212. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  113213. */
  113214. /**
  113215. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  113216. */
  113217. hdrAutoExposure: boolean;
  113218. /**
  113219. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  113220. */
  113221. lensColorTexture: Nullable<Texture>;
  113222. /**
  113223. * The overall strengh for the lens flare effect
  113224. */
  113225. lensFlareStrength: number;
  113226. /**
  113227. * Dispersion coefficient for lens flare ghosts
  113228. */
  113229. lensFlareGhostDispersal: number;
  113230. /**
  113231. * Main lens flare halo width
  113232. */
  113233. lensFlareHaloWidth: number;
  113234. /**
  113235. * Based on the lens distortion effect, defines how much the lens flare result
  113236. * is distorted
  113237. */
  113238. lensFlareDistortionStrength: number;
  113239. /**
  113240. * Lens star texture must be used to simulate rays on the flares and is available
  113241. * in the documentation
  113242. */
  113243. lensStarTexture: Nullable<Texture>;
  113244. /**
  113245. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  113246. * flare effect by taking account of the dirt texture
  113247. */
  113248. lensFlareDirtTexture: Nullable<Texture>;
  113249. /**
  113250. * Represents the focal length for the depth of field effect
  113251. */
  113252. depthOfFieldDistance: number;
  113253. /**
  113254. * Represents the blur intensity for the blurred part of the depth of field effect
  113255. */
  113256. depthOfFieldBlurWidth: number;
  113257. /**
  113258. * For motion blur, defines how much the image is blurred by the movement
  113259. */
  113260. motionStrength: number;
  113261. /**
  113262. * List of animations for the pipeline (IAnimatable implementation)
  113263. */
  113264. animations: Animation[];
  113265. /**
  113266. * Private members
  113267. */
  113268. private _scene;
  113269. private _currentDepthOfFieldSource;
  113270. private _basePostProcess;
  113271. private _fixedExposure;
  113272. private _currentExposure;
  113273. private _hdrAutoExposure;
  113274. private _hdrCurrentLuminance;
  113275. private _floatTextureType;
  113276. private _ratio;
  113277. private _bloomEnabled;
  113278. private _depthOfFieldEnabled;
  113279. private _vlsEnabled;
  113280. private _lensFlareEnabled;
  113281. private _hdrEnabled;
  113282. private _motionBlurEnabled;
  113283. private _fxaaEnabled;
  113284. private _motionBlurSamples;
  113285. private _volumetricLightStepsCount;
  113286. private _samples;
  113287. /**
  113288. * @ignore
  113289. * Specifies if the bloom pipeline is enabled
  113290. */
  113291. BloomEnabled: boolean;
  113292. /**
  113293. * @ignore
  113294. * Specifies if the depth of field pipeline is enabed
  113295. */
  113296. DepthOfFieldEnabled: boolean;
  113297. /**
  113298. * @ignore
  113299. * Specifies if the lens flare pipeline is enabed
  113300. */
  113301. LensFlareEnabled: boolean;
  113302. /**
  113303. * @ignore
  113304. * Specifies if the HDR pipeline is enabled
  113305. */
  113306. HDREnabled: boolean;
  113307. /**
  113308. * @ignore
  113309. * Specifies if the volumetric lights scattering effect is enabled
  113310. */
  113311. VLSEnabled: boolean;
  113312. /**
  113313. * @ignore
  113314. * Specifies if the motion blur effect is enabled
  113315. */
  113316. MotionBlurEnabled: boolean;
  113317. /**
  113318. * Specifies if anti-aliasing is enabled
  113319. */
  113320. fxaaEnabled: boolean;
  113321. /**
  113322. * Specifies the number of steps used to calculate the volumetric lights
  113323. * Typically in interval [50, 200]
  113324. */
  113325. volumetricLightStepsCount: number;
  113326. /**
  113327. * Specifies the number of samples used for the motion blur effect
  113328. * Typically in interval [16, 64]
  113329. */
  113330. motionBlurSamples: number;
  113331. /**
  113332. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  113333. */
  113334. samples: number;
  113335. /**
  113336. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  113337. * @constructor
  113338. * @param name The rendering pipeline name
  113339. * @param scene The scene linked to this pipeline
  113340. * @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)
  113341. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  113342. * @param cameras The array of cameras that the rendering pipeline will be attached to
  113343. */
  113344. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  113345. private _buildPipeline;
  113346. private _createDownSampleX4PostProcess;
  113347. private _createBrightPassPostProcess;
  113348. private _createBlurPostProcesses;
  113349. private _createTextureAdderPostProcess;
  113350. private _createVolumetricLightPostProcess;
  113351. private _createLuminancePostProcesses;
  113352. private _createHdrPostProcess;
  113353. private _createLensFlarePostProcess;
  113354. private _createDepthOfFieldPostProcess;
  113355. private _createMotionBlurPostProcess;
  113356. private _getDepthTexture;
  113357. private _disposePostProcesses;
  113358. /**
  113359. * Dispose of the pipeline and stop all post processes
  113360. */
  113361. dispose(): void;
  113362. /**
  113363. * Serialize the rendering pipeline (Used when exporting)
  113364. * @returns the serialized object
  113365. */
  113366. serialize(): any;
  113367. /**
  113368. * Parse the serialized pipeline
  113369. * @param source Source pipeline.
  113370. * @param scene The scene to load the pipeline to.
  113371. * @param rootUrl The URL of the serialized pipeline.
  113372. * @returns An instantiated pipeline from the serialized object.
  113373. */
  113374. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  113375. /**
  113376. * Luminance steps
  113377. */
  113378. static LuminanceSteps: number;
  113379. }
  113380. }
  113381. declare module BABYLON {
  113382. /** @hidden */
  113383. export var tonemapPixelShader: {
  113384. name: string;
  113385. shader: string;
  113386. };
  113387. }
  113388. declare module BABYLON {
  113389. /** Defines operator used for tonemapping */
  113390. export enum TonemappingOperator {
  113391. /** Hable */
  113392. Hable = 0,
  113393. /** Reinhard */
  113394. Reinhard = 1,
  113395. /** HejiDawson */
  113396. HejiDawson = 2,
  113397. /** Photographic */
  113398. Photographic = 3
  113399. }
  113400. /**
  113401. * Defines a post process to apply tone mapping
  113402. */
  113403. export class TonemapPostProcess extends PostProcess {
  113404. private _operator;
  113405. /** Defines the required exposure adjustement */
  113406. exposureAdjustment: number;
  113407. /**
  113408. * Creates a new TonemapPostProcess
  113409. * @param name defines the name of the postprocess
  113410. * @param _operator defines the operator to use
  113411. * @param exposureAdjustment defines the required exposure adjustement
  113412. * @param camera defines the camera to use (can be null)
  113413. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  113414. * @param engine defines the hosting engine (can be ignore if camera is set)
  113415. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  113416. */
  113417. constructor(name: string, _operator: TonemappingOperator,
  113418. /** Defines the required exposure adjustement */
  113419. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  113420. }
  113421. }
  113422. declare module BABYLON {
  113423. /** @hidden */
  113424. export var depthVertexShader: {
  113425. name: string;
  113426. shader: string;
  113427. };
  113428. }
  113429. declare module BABYLON {
  113430. /** @hidden */
  113431. export var volumetricLightScatteringPixelShader: {
  113432. name: string;
  113433. shader: string;
  113434. };
  113435. }
  113436. declare module BABYLON {
  113437. /** @hidden */
  113438. export var volumetricLightScatteringPassPixelShader: {
  113439. name: string;
  113440. shader: string;
  113441. };
  113442. }
  113443. declare module BABYLON {
  113444. /**
  113445. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  113446. */
  113447. export class VolumetricLightScatteringPostProcess extends PostProcess {
  113448. private _volumetricLightScatteringPass;
  113449. private _volumetricLightScatteringRTT;
  113450. private _viewPort;
  113451. private _screenCoordinates;
  113452. private _cachedDefines;
  113453. /**
  113454. * If not undefined, the mesh position is computed from the attached node position
  113455. */
  113456. attachedNode: {
  113457. position: Vector3;
  113458. };
  113459. /**
  113460. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  113461. */
  113462. customMeshPosition: Vector3;
  113463. /**
  113464. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  113465. */
  113466. useCustomMeshPosition: boolean;
  113467. /**
  113468. * If the post-process should inverse the light scattering direction
  113469. */
  113470. invert: boolean;
  113471. /**
  113472. * The internal mesh used by the post-process
  113473. */
  113474. mesh: Mesh;
  113475. /**
  113476. * @hidden
  113477. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  113478. */
  113479. useDiffuseColor: boolean;
  113480. /**
  113481. * Array containing the excluded meshes not rendered in the internal pass
  113482. */
  113483. excludedMeshes: AbstractMesh[];
  113484. /**
  113485. * Controls the overall intensity of the post-process
  113486. */
  113487. exposure: number;
  113488. /**
  113489. * Dissipates each sample's contribution in range [0, 1]
  113490. */
  113491. decay: number;
  113492. /**
  113493. * Controls the overall intensity of each sample
  113494. */
  113495. weight: number;
  113496. /**
  113497. * Controls the density of each sample
  113498. */
  113499. density: number;
  113500. /**
  113501. * @constructor
  113502. * @param name The post-process name
  113503. * @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)
  113504. * @param camera The camera that the post-process will be attached to
  113505. * @param mesh The mesh used to create the light scattering
  113506. * @param samples The post-process quality, default 100
  113507. * @param samplingModeThe post-process filtering mode
  113508. * @param engine The babylon engine
  113509. * @param reusable If the post-process is reusable
  113510. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  113511. */
  113512. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  113513. /**
  113514. * Returns the string "VolumetricLightScatteringPostProcess"
  113515. * @returns "VolumetricLightScatteringPostProcess"
  113516. */
  113517. getClassName(): string;
  113518. private _isReady;
  113519. /**
  113520. * Sets the new light position for light scattering effect
  113521. * @param position The new custom light position
  113522. */
  113523. setCustomMeshPosition(position: Vector3): void;
  113524. /**
  113525. * Returns the light position for light scattering effect
  113526. * @return Vector3 The custom light position
  113527. */
  113528. getCustomMeshPosition(): Vector3;
  113529. /**
  113530. * Disposes the internal assets and detaches the post-process from the camera
  113531. */
  113532. dispose(camera: Camera): void;
  113533. /**
  113534. * Returns the render target texture used by the post-process
  113535. * @return the render target texture used by the post-process
  113536. */
  113537. getPass(): RenderTargetTexture;
  113538. private _meshExcluded;
  113539. private _createPass;
  113540. private _updateMeshScreenCoordinates;
  113541. /**
  113542. * Creates a default mesh for the Volumeric Light Scattering post-process
  113543. * @param name The mesh name
  113544. * @param scene The scene where to create the mesh
  113545. * @return the default mesh
  113546. */
  113547. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  113548. }
  113549. }
  113550. declare module BABYLON {
  113551. interface Scene {
  113552. /** @hidden (Backing field) */
  113553. _boundingBoxRenderer: BoundingBoxRenderer;
  113554. /** @hidden (Backing field) */
  113555. _forceShowBoundingBoxes: boolean;
  113556. /**
  113557. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  113558. */
  113559. forceShowBoundingBoxes: boolean;
  113560. /**
  113561. * Gets the bounding box renderer associated with the scene
  113562. * @returns a BoundingBoxRenderer
  113563. */
  113564. getBoundingBoxRenderer(): BoundingBoxRenderer;
  113565. }
  113566. interface AbstractMesh {
  113567. /** @hidden (Backing field) */
  113568. _showBoundingBox: boolean;
  113569. /**
  113570. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  113571. */
  113572. showBoundingBox: boolean;
  113573. }
  113574. /**
  113575. * Component responsible of rendering the bounding box of the meshes in a scene.
  113576. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  113577. */
  113578. export class BoundingBoxRenderer implements ISceneComponent {
  113579. /**
  113580. * The component name helpfull to identify the component in the list of scene components.
  113581. */
  113582. readonly name: string;
  113583. /**
  113584. * The scene the component belongs to.
  113585. */
  113586. scene: Scene;
  113587. /**
  113588. * Color of the bounding box lines placed in front of an object
  113589. */
  113590. frontColor: Color3;
  113591. /**
  113592. * Color of the bounding box lines placed behind an object
  113593. */
  113594. backColor: Color3;
  113595. /**
  113596. * Defines if the renderer should show the back lines or not
  113597. */
  113598. showBackLines: boolean;
  113599. /**
  113600. * @hidden
  113601. */
  113602. renderList: SmartArray<BoundingBox>;
  113603. private _colorShader;
  113604. private _vertexBuffers;
  113605. private _indexBuffer;
  113606. /**
  113607. * Instantiates a new bounding box renderer in a scene.
  113608. * @param scene the scene the renderer renders in
  113609. */
  113610. constructor(scene: Scene);
  113611. /**
  113612. * Registers the component in a given scene
  113613. */
  113614. register(): void;
  113615. private _evaluateSubMesh;
  113616. private _activeMesh;
  113617. private _prepareRessources;
  113618. private _createIndexBuffer;
  113619. /**
  113620. * Rebuilds the elements related to this component in case of
  113621. * context lost for instance.
  113622. */
  113623. rebuild(): void;
  113624. /**
  113625. * @hidden
  113626. */
  113627. reset(): void;
  113628. /**
  113629. * Render the bounding boxes of a specific rendering group
  113630. * @param renderingGroupId defines the rendering group to render
  113631. */
  113632. render(renderingGroupId: number): void;
  113633. /**
  113634. * In case of occlusion queries, we can render the occlusion bounding box through this method
  113635. * @param mesh Define the mesh to render the occlusion bounding box for
  113636. */
  113637. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  113638. /**
  113639. * Dispose and release the resources attached to this renderer.
  113640. */
  113641. dispose(): void;
  113642. }
  113643. }
  113644. declare module BABYLON {
  113645. /** @hidden */
  113646. export var depthPixelShader: {
  113647. name: string;
  113648. shader: string;
  113649. };
  113650. }
  113651. declare module BABYLON {
  113652. /**
  113653. * This represents a depth renderer in Babylon.
  113654. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  113655. */
  113656. export class DepthRenderer {
  113657. private _scene;
  113658. private _depthMap;
  113659. private _effect;
  113660. private _cachedDefines;
  113661. private _camera;
  113662. /**
  113663. * Specifiess that the depth renderer will only be used within
  113664. * the camera it is created for.
  113665. * This can help forcing its rendering during the camera processing.
  113666. */
  113667. useOnlyInActiveCamera: boolean;
  113668. /** @hidden */
  113669. static _SceneComponentInitialization: (scene: Scene) => void;
  113670. /**
  113671. * Instantiates a depth renderer
  113672. * @param scene The scene the renderer belongs to
  113673. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  113674. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  113675. */
  113676. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  113677. /**
  113678. * Creates the depth rendering effect and checks if the effect is ready.
  113679. * @param subMesh The submesh to be used to render the depth map of
  113680. * @param useInstances If multiple world instances should be used
  113681. * @returns if the depth renderer is ready to render the depth map
  113682. */
  113683. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  113684. /**
  113685. * Gets the texture which the depth map will be written to.
  113686. * @returns The depth map texture
  113687. */
  113688. getDepthMap(): RenderTargetTexture;
  113689. /**
  113690. * Disposes of the depth renderer.
  113691. */
  113692. dispose(): void;
  113693. }
  113694. }
  113695. declare module BABYLON {
  113696. interface Scene {
  113697. /** @hidden (Backing field) */
  113698. _depthRenderer: {
  113699. [id: string]: DepthRenderer;
  113700. };
  113701. /**
  113702. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  113703. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  113704. * @returns the created depth renderer
  113705. */
  113706. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  113707. /**
  113708. * Disables a depth renderer for a given camera
  113709. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  113710. */
  113711. disableDepthRenderer(camera?: Nullable<Camera>): void;
  113712. }
  113713. /**
  113714. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  113715. * in several rendering techniques.
  113716. */
  113717. export class DepthRendererSceneComponent implements ISceneComponent {
  113718. /**
  113719. * The component name helpfull to identify the component in the list of scene components.
  113720. */
  113721. readonly name: string;
  113722. /**
  113723. * The scene the component belongs to.
  113724. */
  113725. scene: Scene;
  113726. /**
  113727. * Creates a new instance of the component for the given scene
  113728. * @param scene Defines the scene to register the component in
  113729. */
  113730. constructor(scene: Scene);
  113731. /**
  113732. * Registers the component in a given scene
  113733. */
  113734. register(): void;
  113735. /**
  113736. * Rebuilds the elements related to this component in case of
  113737. * context lost for instance.
  113738. */
  113739. rebuild(): void;
  113740. /**
  113741. * Disposes the component and the associated ressources
  113742. */
  113743. dispose(): void;
  113744. private _gatherRenderTargets;
  113745. private _gatherActiveCameraRenderTargets;
  113746. }
  113747. }
  113748. declare module BABYLON {
  113749. /** @hidden */
  113750. export var outlinePixelShader: {
  113751. name: string;
  113752. shader: string;
  113753. };
  113754. }
  113755. declare module BABYLON {
  113756. /** @hidden */
  113757. export var outlineVertexShader: {
  113758. name: string;
  113759. shader: string;
  113760. };
  113761. }
  113762. declare module BABYLON {
  113763. interface Scene {
  113764. /** @hidden */
  113765. _outlineRenderer: OutlineRenderer;
  113766. /**
  113767. * Gets the outline renderer associated with the scene
  113768. * @returns a OutlineRenderer
  113769. */
  113770. getOutlineRenderer(): OutlineRenderer;
  113771. }
  113772. interface AbstractMesh {
  113773. /** @hidden (Backing field) */
  113774. _renderOutline: boolean;
  113775. /**
  113776. * Gets or sets a boolean indicating if the outline must be rendered as well
  113777. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  113778. */
  113779. renderOutline: boolean;
  113780. /** @hidden (Backing field) */
  113781. _renderOverlay: boolean;
  113782. /**
  113783. * Gets or sets a boolean indicating if the overlay must be rendered as well
  113784. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  113785. */
  113786. renderOverlay: boolean;
  113787. }
  113788. /**
  113789. * This class is responsible to draw bothe outline/overlay of meshes.
  113790. * It should not be used directly but through the available method on mesh.
  113791. */
  113792. export class OutlineRenderer implements ISceneComponent {
  113793. /**
  113794. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  113795. */
  113796. private static _StencilReference;
  113797. /**
  113798. * The name of the component. Each component must have a unique name.
  113799. */
  113800. name: string;
  113801. /**
  113802. * The scene the component belongs to.
  113803. */
  113804. scene: Scene;
  113805. /**
  113806. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  113807. */
  113808. zOffset: number;
  113809. private _engine;
  113810. private _effect;
  113811. private _cachedDefines;
  113812. private _savedDepthWrite;
  113813. /**
  113814. * Instantiates a new outline renderer. (There could be only one per scene).
  113815. * @param scene Defines the scene it belongs to
  113816. */
  113817. constructor(scene: Scene);
  113818. /**
  113819. * Register the component to one instance of a scene.
  113820. */
  113821. register(): void;
  113822. /**
  113823. * Rebuilds the elements related to this component in case of
  113824. * context lost for instance.
  113825. */
  113826. rebuild(): void;
  113827. /**
  113828. * Disposes the component and the associated ressources.
  113829. */
  113830. dispose(): void;
  113831. /**
  113832. * Renders the outline in the canvas.
  113833. * @param subMesh Defines the sumesh to render
  113834. * @param batch Defines the batch of meshes in case of instances
  113835. * @param useOverlay Defines if the rendering is for the overlay or the outline
  113836. */
  113837. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  113838. /**
  113839. * Returns whether or not the outline renderer is ready for a given submesh.
  113840. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  113841. * @param subMesh Defines the submesh to check readyness for
  113842. * @param useInstances Defines wheter wee are trying to render instances or not
  113843. * @returns true if ready otherwise false
  113844. */
  113845. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  113846. private _beforeRenderingMesh;
  113847. private _afterRenderingMesh;
  113848. }
  113849. }
  113850. declare module BABYLON {
  113851. /**
  113852. * Defines the list of states available for a task inside a AssetsManager
  113853. */
  113854. export enum AssetTaskState {
  113855. /**
  113856. * Initialization
  113857. */
  113858. INIT = 0,
  113859. /**
  113860. * Running
  113861. */
  113862. RUNNING = 1,
  113863. /**
  113864. * Done
  113865. */
  113866. DONE = 2,
  113867. /**
  113868. * Error
  113869. */
  113870. ERROR = 3
  113871. }
  113872. /**
  113873. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  113874. */
  113875. export abstract class AbstractAssetTask {
  113876. /**
  113877. * Task name
  113878. */ name: string;
  113879. /**
  113880. * Callback called when the task is successful
  113881. */
  113882. onSuccess: (task: any) => void;
  113883. /**
  113884. * Callback called when the task is not successful
  113885. */
  113886. onError: (task: any, message?: string, exception?: any) => void;
  113887. /**
  113888. * Creates a new AssetsManager
  113889. * @param name defines the name of the task
  113890. */
  113891. constructor(
  113892. /**
  113893. * Task name
  113894. */ name: string);
  113895. private _isCompleted;
  113896. private _taskState;
  113897. private _errorObject;
  113898. /**
  113899. * Get if the task is completed
  113900. */
  113901. readonly isCompleted: boolean;
  113902. /**
  113903. * Gets the current state of the task
  113904. */
  113905. readonly taskState: AssetTaskState;
  113906. /**
  113907. * Gets the current error object (if task is in error)
  113908. */
  113909. readonly errorObject: {
  113910. message?: string;
  113911. exception?: any;
  113912. };
  113913. /**
  113914. * Internal only
  113915. * @hidden
  113916. */
  113917. _setErrorObject(message?: string, exception?: any): void;
  113918. /**
  113919. * Execute the current task
  113920. * @param scene defines the scene where you want your assets to be loaded
  113921. * @param onSuccess is a callback called when the task is successfully executed
  113922. * @param onError is a callback called if an error occurs
  113923. */
  113924. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  113925. /**
  113926. * Execute the current task
  113927. * @param scene defines the scene where you want your assets to be loaded
  113928. * @param onSuccess is a callback called when the task is successfully executed
  113929. * @param onError is a callback called if an error occurs
  113930. */
  113931. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  113932. /**
  113933. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  113934. * This can be used with failed tasks that have the reason for failure fixed.
  113935. */
  113936. reset(): void;
  113937. private onErrorCallback;
  113938. private onDoneCallback;
  113939. }
  113940. /**
  113941. * Define the interface used by progress events raised during assets loading
  113942. */
  113943. export interface IAssetsProgressEvent {
  113944. /**
  113945. * Defines the number of remaining tasks to process
  113946. */
  113947. remainingCount: number;
  113948. /**
  113949. * Defines the total number of tasks
  113950. */
  113951. totalCount: number;
  113952. /**
  113953. * Defines the task that was just processed
  113954. */
  113955. task: AbstractAssetTask;
  113956. }
  113957. /**
  113958. * Class used to share progress information about assets loading
  113959. */
  113960. export class AssetsProgressEvent implements IAssetsProgressEvent {
  113961. /**
  113962. * Defines the number of remaining tasks to process
  113963. */
  113964. remainingCount: number;
  113965. /**
  113966. * Defines the total number of tasks
  113967. */
  113968. totalCount: number;
  113969. /**
  113970. * Defines the task that was just processed
  113971. */
  113972. task: AbstractAssetTask;
  113973. /**
  113974. * Creates a AssetsProgressEvent
  113975. * @param remainingCount defines the number of remaining tasks to process
  113976. * @param totalCount defines the total number of tasks
  113977. * @param task defines the task that was just processed
  113978. */
  113979. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  113980. }
  113981. /**
  113982. * Define a task used by AssetsManager to load meshes
  113983. */
  113984. export class MeshAssetTask extends AbstractAssetTask {
  113985. /**
  113986. * Defines the name of the task
  113987. */
  113988. name: string;
  113989. /**
  113990. * Defines the list of mesh's names you want to load
  113991. */
  113992. meshesNames: any;
  113993. /**
  113994. * Defines the root url to use as a base to load your meshes and associated resources
  113995. */
  113996. rootUrl: string;
  113997. /**
  113998. * Defines the filename of the scene to load from
  113999. */
  114000. sceneFilename: string;
  114001. /**
  114002. * Gets the list of loaded meshes
  114003. */
  114004. loadedMeshes: Array<AbstractMesh>;
  114005. /**
  114006. * Gets the list of loaded particle systems
  114007. */
  114008. loadedParticleSystems: Array<IParticleSystem>;
  114009. /**
  114010. * Gets the list of loaded skeletons
  114011. */
  114012. loadedSkeletons: Array<Skeleton>;
  114013. /**
  114014. * Gets the list of loaded animation groups
  114015. */
  114016. loadedAnimationGroups: Array<AnimationGroup>;
  114017. /**
  114018. * Callback called when the task is successful
  114019. */
  114020. onSuccess: (task: MeshAssetTask) => void;
  114021. /**
  114022. * Callback called when the task is successful
  114023. */
  114024. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  114025. /**
  114026. * Creates a new MeshAssetTask
  114027. * @param name defines the name of the task
  114028. * @param meshesNames defines the list of mesh's names you want to load
  114029. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  114030. * @param sceneFilename defines the filename of the scene to load from
  114031. */
  114032. constructor(
  114033. /**
  114034. * Defines the name of the task
  114035. */
  114036. name: string,
  114037. /**
  114038. * Defines the list of mesh's names you want to load
  114039. */
  114040. meshesNames: any,
  114041. /**
  114042. * Defines the root url to use as a base to load your meshes and associated resources
  114043. */
  114044. rootUrl: string,
  114045. /**
  114046. * Defines the filename of the scene to load from
  114047. */
  114048. sceneFilename: string);
  114049. /**
  114050. * Execute the current task
  114051. * @param scene defines the scene where you want your assets to be loaded
  114052. * @param onSuccess is a callback called when the task is successfully executed
  114053. * @param onError is a callback called if an error occurs
  114054. */
  114055. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  114056. }
  114057. /**
  114058. * Define a task used by AssetsManager to load text content
  114059. */
  114060. export class TextFileAssetTask extends AbstractAssetTask {
  114061. /**
  114062. * Defines the name of the task
  114063. */
  114064. name: string;
  114065. /**
  114066. * Defines the location of the file to load
  114067. */
  114068. url: string;
  114069. /**
  114070. * Gets the loaded text string
  114071. */
  114072. text: string;
  114073. /**
  114074. * Callback called when the task is successful
  114075. */
  114076. onSuccess: (task: TextFileAssetTask) => void;
  114077. /**
  114078. * Callback called when the task is successful
  114079. */
  114080. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  114081. /**
  114082. * Creates a new TextFileAssetTask object
  114083. * @param name defines the name of the task
  114084. * @param url defines the location of the file to load
  114085. */
  114086. constructor(
  114087. /**
  114088. * Defines the name of the task
  114089. */
  114090. name: string,
  114091. /**
  114092. * Defines the location of the file to load
  114093. */
  114094. url: string);
  114095. /**
  114096. * Execute the current task
  114097. * @param scene defines the scene where you want your assets to be loaded
  114098. * @param onSuccess is a callback called when the task is successfully executed
  114099. * @param onError is a callback called if an error occurs
  114100. */
  114101. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  114102. }
  114103. /**
  114104. * Define a task used by AssetsManager to load binary data
  114105. */
  114106. export class BinaryFileAssetTask extends AbstractAssetTask {
  114107. /**
  114108. * Defines the name of the task
  114109. */
  114110. name: string;
  114111. /**
  114112. * Defines the location of the file to load
  114113. */
  114114. url: string;
  114115. /**
  114116. * Gets the lodaded data (as an array buffer)
  114117. */
  114118. data: ArrayBuffer;
  114119. /**
  114120. * Callback called when the task is successful
  114121. */
  114122. onSuccess: (task: BinaryFileAssetTask) => void;
  114123. /**
  114124. * Callback called when the task is successful
  114125. */
  114126. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  114127. /**
  114128. * Creates a new BinaryFileAssetTask object
  114129. * @param name defines the name of the new task
  114130. * @param url defines the location of the file to load
  114131. */
  114132. constructor(
  114133. /**
  114134. * Defines the name of the task
  114135. */
  114136. name: string,
  114137. /**
  114138. * Defines the location of the file to load
  114139. */
  114140. url: string);
  114141. /**
  114142. * Execute the current task
  114143. * @param scene defines the scene where you want your assets to be loaded
  114144. * @param onSuccess is a callback called when the task is successfully executed
  114145. * @param onError is a callback called if an error occurs
  114146. */
  114147. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  114148. }
  114149. /**
  114150. * Define a task used by AssetsManager to load images
  114151. */
  114152. export class ImageAssetTask extends AbstractAssetTask {
  114153. /**
  114154. * Defines the name of the task
  114155. */
  114156. name: string;
  114157. /**
  114158. * Defines the location of the image to load
  114159. */
  114160. url: string;
  114161. /**
  114162. * Gets the loaded images
  114163. */
  114164. image: HTMLImageElement;
  114165. /**
  114166. * Callback called when the task is successful
  114167. */
  114168. onSuccess: (task: ImageAssetTask) => void;
  114169. /**
  114170. * Callback called when the task is successful
  114171. */
  114172. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  114173. /**
  114174. * Creates a new ImageAssetTask
  114175. * @param name defines the name of the task
  114176. * @param url defines the location of the image to load
  114177. */
  114178. constructor(
  114179. /**
  114180. * Defines the name of the task
  114181. */
  114182. name: string,
  114183. /**
  114184. * Defines the location of the image to load
  114185. */
  114186. url: string);
  114187. /**
  114188. * Execute the current task
  114189. * @param scene defines the scene where you want your assets to be loaded
  114190. * @param onSuccess is a callback called when the task is successfully executed
  114191. * @param onError is a callback called if an error occurs
  114192. */
  114193. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  114194. }
  114195. /**
  114196. * Defines the interface used by texture loading tasks
  114197. */
  114198. export interface ITextureAssetTask<TEX extends BaseTexture> {
  114199. /**
  114200. * Gets the loaded texture
  114201. */
  114202. texture: TEX;
  114203. }
  114204. /**
  114205. * Define a task used by AssetsManager to load 2D textures
  114206. */
  114207. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  114208. /**
  114209. * Defines the name of the task
  114210. */
  114211. name: string;
  114212. /**
  114213. * Defines the location of the file to load
  114214. */
  114215. url: string;
  114216. /**
  114217. * Defines if mipmap should not be generated (default is false)
  114218. */
  114219. noMipmap?: boolean | undefined;
  114220. /**
  114221. * Defines if texture must be inverted on Y axis (default is false)
  114222. */
  114223. invertY?: boolean | undefined;
  114224. /**
  114225. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  114226. */
  114227. samplingMode: number;
  114228. /**
  114229. * Gets the loaded texture
  114230. */
  114231. texture: Texture;
  114232. /**
  114233. * Callback called when the task is successful
  114234. */
  114235. onSuccess: (task: TextureAssetTask) => void;
  114236. /**
  114237. * Callback called when the task is successful
  114238. */
  114239. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  114240. /**
  114241. * Creates a new TextureAssetTask object
  114242. * @param name defines the name of the task
  114243. * @param url defines the location of the file to load
  114244. * @param noMipmap defines if mipmap should not be generated (default is false)
  114245. * @param invertY defines if texture must be inverted on Y axis (default is false)
  114246. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  114247. */
  114248. constructor(
  114249. /**
  114250. * Defines the name of the task
  114251. */
  114252. name: string,
  114253. /**
  114254. * Defines the location of the file to load
  114255. */
  114256. url: string,
  114257. /**
  114258. * Defines if mipmap should not be generated (default is false)
  114259. */
  114260. noMipmap?: boolean | undefined,
  114261. /**
  114262. * Defines if texture must be inverted on Y axis (default is false)
  114263. */
  114264. invertY?: boolean | undefined,
  114265. /**
  114266. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  114267. */
  114268. samplingMode?: number);
  114269. /**
  114270. * Execute the current task
  114271. * @param scene defines the scene where you want your assets to be loaded
  114272. * @param onSuccess is a callback called when the task is successfully executed
  114273. * @param onError is a callback called if an error occurs
  114274. */
  114275. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  114276. }
  114277. /**
  114278. * Define a task used by AssetsManager to load cube textures
  114279. */
  114280. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  114281. /**
  114282. * Defines the name of the task
  114283. */
  114284. name: string;
  114285. /**
  114286. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  114287. */
  114288. url: string;
  114289. /**
  114290. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  114291. */
  114292. extensions?: string[] | undefined;
  114293. /**
  114294. * Defines if mipmaps should not be generated (default is false)
  114295. */
  114296. noMipmap?: boolean | undefined;
  114297. /**
  114298. * Defines the explicit list of files (undefined by default)
  114299. */
  114300. files?: string[] | undefined;
  114301. /**
  114302. * Gets the loaded texture
  114303. */
  114304. texture: CubeTexture;
  114305. /**
  114306. * Callback called when the task is successful
  114307. */
  114308. onSuccess: (task: CubeTextureAssetTask) => void;
  114309. /**
  114310. * Callback called when the task is successful
  114311. */
  114312. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  114313. /**
  114314. * Creates a new CubeTextureAssetTask
  114315. * @param name defines the name of the task
  114316. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  114317. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  114318. * @param noMipmap defines if mipmaps should not be generated (default is false)
  114319. * @param files defines the explicit list of files (undefined by default)
  114320. */
  114321. constructor(
  114322. /**
  114323. * Defines the name of the task
  114324. */
  114325. name: string,
  114326. /**
  114327. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  114328. */
  114329. url: string,
  114330. /**
  114331. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  114332. */
  114333. extensions?: string[] | undefined,
  114334. /**
  114335. * Defines if mipmaps should not be generated (default is false)
  114336. */
  114337. noMipmap?: boolean | undefined,
  114338. /**
  114339. * Defines the explicit list of files (undefined by default)
  114340. */
  114341. files?: string[] | undefined);
  114342. /**
  114343. * Execute the current task
  114344. * @param scene defines the scene where you want your assets to be loaded
  114345. * @param onSuccess is a callback called when the task is successfully executed
  114346. * @param onError is a callback called if an error occurs
  114347. */
  114348. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  114349. }
  114350. /**
  114351. * Define a task used by AssetsManager to load HDR cube textures
  114352. */
  114353. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  114354. /**
  114355. * Defines the name of the task
  114356. */
  114357. name: string;
  114358. /**
  114359. * Defines the location of the file to load
  114360. */
  114361. url: string;
  114362. /**
  114363. * Defines the desired size (the more it increases the longer the generation will be)
  114364. */
  114365. size: number;
  114366. /**
  114367. * Defines if mipmaps should not be generated (default is false)
  114368. */
  114369. noMipmap: boolean;
  114370. /**
  114371. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  114372. */
  114373. generateHarmonics: boolean;
  114374. /**
  114375. * 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)
  114376. */
  114377. gammaSpace: boolean;
  114378. /**
  114379. * Internal Use Only
  114380. */
  114381. reserved: boolean;
  114382. /**
  114383. * Gets the loaded texture
  114384. */
  114385. texture: HDRCubeTexture;
  114386. /**
  114387. * Callback called when the task is successful
  114388. */
  114389. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  114390. /**
  114391. * Callback called when the task is successful
  114392. */
  114393. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  114394. /**
  114395. * Creates a new HDRCubeTextureAssetTask object
  114396. * @param name defines the name of the task
  114397. * @param url defines the location of the file to load
  114398. * @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.
  114399. * @param noMipmap defines if mipmaps should not be generated (default is false)
  114400. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  114401. * @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)
  114402. * @param reserved Internal use only
  114403. */
  114404. constructor(
  114405. /**
  114406. * Defines the name of the task
  114407. */
  114408. name: string,
  114409. /**
  114410. * Defines the location of the file to load
  114411. */
  114412. url: string,
  114413. /**
  114414. * Defines the desired size (the more it increases the longer the generation will be)
  114415. */
  114416. size: number,
  114417. /**
  114418. * Defines if mipmaps should not be generated (default is false)
  114419. */
  114420. noMipmap?: boolean,
  114421. /**
  114422. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  114423. */
  114424. generateHarmonics?: boolean,
  114425. /**
  114426. * 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)
  114427. */
  114428. gammaSpace?: boolean,
  114429. /**
  114430. * Internal Use Only
  114431. */
  114432. reserved?: boolean);
  114433. /**
  114434. * Execute the current task
  114435. * @param scene defines the scene where you want your assets to be loaded
  114436. * @param onSuccess is a callback called when the task is successfully executed
  114437. * @param onError is a callback called if an error occurs
  114438. */
  114439. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  114440. }
  114441. /**
  114442. * Define a task used by AssetsManager to load Equirectangular cube textures
  114443. */
  114444. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  114445. /**
  114446. * Defines the name of the task
  114447. */
  114448. name: string;
  114449. /**
  114450. * Defines the location of the file to load
  114451. */
  114452. url: string;
  114453. /**
  114454. * Defines the desired size (the more it increases the longer the generation will be)
  114455. */
  114456. size: number;
  114457. /**
  114458. * Defines if mipmaps should not be generated (default is false)
  114459. */
  114460. noMipmap: boolean;
  114461. /**
  114462. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  114463. * but the standard material would require them in Gamma space) (default is true)
  114464. */
  114465. gammaSpace: boolean;
  114466. /**
  114467. * Gets the loaded texture
  114468. */
  114469. texture: EquiRectangularCubeTexture;
  114470. /**
  114471. * Callback called when the task is successful
  114472. */
  114473. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  114474. /**
  114475. * Callback called when the task is successful
  114476. */
  114477. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  114478. /**
  114479. * Creates a new EquiRectangularCubeTextureAssetTask object
  114480. * @param name defines the name of the task
  114481. * @param url defines the location of the file to load
  114482. * @param size defines the desired size (the more it increases the longer the generation will be)
  114483. * If the size is omitted this implies you are using a preprocessed cubemap.
  114484. * @param noMipmap defines if mipmaps should not be generated (default is false)
  114485. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  114486. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  114487. * (default is true)
  114488. */
  114489. constructor(
  114490. /**
  114491. * Defines the name of the task
  114492. */
  114493. name: string,
  114494. /**
  114495. * Defines the location of the file to load
  114496. */
  114497. url: string,
  114498. /**
  114499. * Defines the desired size (the more it increases the longer the generation will be)
  114500. */
  114501. size: number,
  114502. /**
  114503. * Defines if mipmaps should not be generated (default is false)
  114504. */
  114505. noMipmap?: boolean,
  114506. /**
  114507. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  114508. * but the standard material would require them in Gamma space) (default is true)
  114509. */
  114510. gammaSpace?: boolean);
  114511. /**
  114512. * Execute the current task
  114513. * @param scene defines the scene where you want your assets to be loaded
  114514. * @param onSuccess is a callback called when the task is successfully executed
  114515. * @param onError is a callback called if an error occurs
  114516. */
  114517. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  114518. }
  114519. /**
  114520. * This class can be used to easily import assets into a scene
  114521. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  114522. */
  114523. export class AssetsManager {
  114524. private _scene;
  114525. private _isLoading;
  114526. protected _tasks: AbstractAssetTask[];
  114527. protected _waitingTasksCount: number;
  114528. protected _totalTasksCount: number;
  114529. /**
  114530. * Callback called when all tasks are processed
  114531. */
  114532. onFinish: (tasks: AbstractAssetTask[]) => void;
  114533. /**
  114534. * Callback called when a task is successful
  114535. */
  114536. onTaskSuccess: (task: AbstractAssetTask) => void;
  114537. /**
  114538. * Callback called when a task had an error
  114539. */
  114540. onTaskError: (task: AbstractAssetTask) => void;
  114541. /**
  114542. * Callback called when a task is done (whatever the result is)
  114543. */
  114544. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  114545. /**
  114546. * Observable called when all tasks are processed
  114547. */
  114548. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  114549. /**
  114550. * Observable called when a task had an error
  114551. */
  114552. onTaskErrorObservable: Observable<AbstractAssetTask>;
  114553. /**
  114554. * Observable called when all tasks were executed
  114555. */
  114556. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  114557. /**
  114558. * Observable called when a task is done (whatever the result is)
  114559. */
  114560. onProgressObservable: Observable<IAssetsProgressEvent>;
  114561. /**
  114562. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  114563. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  114564. */
  114565. useDefaultLoadingScreen: boolean;
  114566. /**
  114567. * Creates a new AssetsManager
  114568. * @param scene defines the scene to work on
  114569. */
  114570. constructor(scene: Scene);
  114571. /**
  114572. * Add a MeshAssetTask to the list of active tasks
  114573. * @param taskName defines the name of the new task
  114574. * @param meshesNames defines the name of meshes to load
  114575. * @param rootUrl defines the root url to use to locate files
  114576. * @param sceneFilename defines the filename of the scene file
  114577. * @returns a new MeshAssetTask object
  114578. */
  114579. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  114580. /**
  114581. * Add a TextFileAssetTask to the list of active tasks
  114582. * @param taskName defines the name of the new task
  114583. * @param url defines the url of the file to load
  114584. * @returns a new TextFileAssetTask object
  114585. */
  114586. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  114587. /**
  114588. * Add a BinaryFileAssetTask to the list of active tasks
  114589. * @param taskName defines the name of the new task
  114590. * @param url defines the url of the file to load
  114591. * @returns a new BinaryFileAssetTask object
  114592. */
  114593. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  114594. /**
  114595. * Add a ImageAssetTask to the list of active tasks
  114596. * @param taskName defines the name of the new task
  114597. * @param url defines the url of the file to load
  114598. * @returns a new ImageAssetTask object
  114599. */
  114600. addImageTask(taskName: string, url: string): ImageAssetTask;
  114601. /**
  114602. * Add a TextureAssetTask to the list of active tasks
  114603. * @param taskName defines the name of the new task
  114604. * @param url defines the url of the file to load
  114605. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  114606. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  114607. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  114608. * @returns a new TextureAssetTask object
  114609. */
  114610. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  114611. /**
  114612. * Add a CubeTextureAssetTask to the list of active tasks
  114613. * @param taskName defines the name of the new task
  114614. * @param url defines the url of the file to load
  114615. * @param extensions defines the extension to use to load the cube map (can be null)
  114616. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  114617. * @param files defines the list of files to load (can be null)
  114618. * @returns a new CubeTextureAssetTask object
  114619. */
  114620. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  114621. /**
  114622. *
  114623. * Add a HDRCubeTextureAssetTask to the list of active tasks
  114624. * @param taskName defines the name of the new task
  114625. * @param url defines the url of the file to load
  114626. * @param size defines the size you want for the cubemap (can be null)
  114627. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  114628. * @param generateHarmonics defines if you want to automatically generate (true by default)
  114629. * @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)
  114630. * @param reserved Internal use only
  114631. * @returns a new HDRCubeTextureAssetTask object
  114632. */
  114633. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  114634. /**
  114635. *
  114636. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  114637. * @param taskName defines the name of the new task
  114638. * @param url defines the url of the file to load
  114639. * @param size defines the size you want for the cubemap (can be null)
  114640. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  114641. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  114642. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  114643. * @returns a new EquiRectangularCubeTextureAssetTask object
  114644. */
  114645. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  114646. /**
  114647. * Remove a task from the assets manager.
  114648. * @param task the task to remove
  114649. */
  114650. removeTask(task: AbstractAssetTask): void;
  114651. private _decreaseWaitingTasksCount;
  114652. private _runTask;
  114653. /**
  114654. * Reset the AssetsManager and remove all tasks
  114655. * @return the current instance of the AssetsManager
  114656. */
  114657. reset(): AssetsManager;
  114658. /**
  114659. * Start the loading process
  114660. * @return the current instance of the AssetsManager
  114661. */
  114662. load(): AssetsManager;
  114663. /**
  114664. * Start the loading process as an async operation
  114665. * @return a promise returning the list of failed tasks
  114666. */
  114667. loadAsync(): Promise<void>;
  114668. }
  114669. }
  114670. declare module BABYLON {
  114671. /**
  114672. * Wrapper class for promise with external resolve and reject.
  114673. */
  114674. export class Deferred<T> {
  114675. /**
  114676. * The promise associated with this deferred object.
  114677. */
  114678. readonly promise: Promise<T>;
  114679. private _resolve;
  114680. private _reject;
  114681. /**
  114682. * The resolve method of the promise associated with this deferred object.
  114683. */
  114684. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  114685. /**
  114686. * The reject method of the promise associated with this deferred object.
  114687. */
  114688. readonly reject: (reason?: any) => void;
  114689. /**
  114690. * Constructor for this deferred object.
  114691. */
  114692. constructor();
  114693. }
  114694. }
  114695. declare module BABYLON {
  114696. /**
  114697. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  114698. */
  114699. export class MeshExploder {
  114700. private _centerMesh;
  114701. private _meshes;
  114702. private _meshesOrigins;
  114703. private _toCenterVectors;
  114704. private _scaledDirection;
  114705. private _newPosition;
  114706. private _centerPosition;
  114707. /**
  114708. * Explodes meshes from a center mesh.
  114709. * @param meshes The meshes to explode.
  114710. * @param centerMesh The mesh to be center of explosion.
  114711. */
  114712. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  114713. private _setCenterMesh;
  114714. /**
  114715. * Get class name
  114716. * @returns "MeshExploder"
  114717. */
  114718. getClassName(): string;
  114719. /**
  114720. * "Exploded meshes"
  114721. * @returns Array of meshes with the centerMesh at index 0.
  114722. */
  114723. getMeshes(): Array<Mesh>;
  114724. /**
  114725. * Explodes meshes giving a specific direction
  114726. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  114727. */
  114728. explode(direction?: number): void;
  114729. }
  114730. }
  114731. declare module BABYLON {
  114732. /**
  114733. * Class used to help managing file picking and drag'n'drop
  114734. */
  114735. export class FilesInput {
  114736. /**
  114737. * List of files ready to be loaded
  114738. */
  114739. static readonly FilesToLoad: {
  114740. [key: string]: File;
  114741. };
  114742. /**
  114743. * Callback called when a file is processed
  114744. */
  114745. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  114746. private _engine;
  114747. private _currentScene;
  114748. private _sceneLoadedCallback;
  114749. private _progressCallback;
  114750. private _additionalRenderLoopLogicCallback;
  114751. private _textureLoadingCallback;
  114752. private _startingProcessingFilesCallback;
  114753. private _onReloadCallback;
  114754. private _errorCallback;
  114755. private _elementToMonitor;
  114756. private _sceneFileToLoad;
  114757. private _filesToLoad;
  114758. /**
  114759. * Creates a new FilesInput
  114760. * @param engine defines the rendering engine
  114761. * @param scene defines the hosting scene
  114762. * @param sceneLoadedCallback callback called when scene is loaded
  114763. * @param progressCallback callback called to track progress
  114764. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  114765. * @param textureLoadingCallback callback called when a texture is loading
  114766. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  114767. * @param onReloadCallback callback called when a reload is requested
  114768. * @param errorCallback callback call if an error occurs
  114769. */
  114770. 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);
  114771. private _dragEnterHandler;
  114772. private _dragOverHandler;
  114773. private _dropHandler;
  114774. /**
  114775. * Calls this function to listen to drag'n'drop events on a specific DOM element
  114776. * @param elementToMonitor defines the DOM element to track
  114777. */
  114778. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  114779. /**
  114780. * Release all associated resources
  114781. */
  114782. dispose(): void;
  114783. private renderFunction;
  114784. private drag;
  114785. private drop;
  114786. private _traverseFolder;
  114787. private _processFiles;
  114788. /**
  114789. * Load files from a drop event
  114790. * @param event defines the drop event to use as source
  114791. */
  114792. loadFiles(event: any): void;
  114793. private _processReload;
  114794. /**
  114795. * Reload the current scene from the loaded files
  114796. */
  114797. reload(): void;
  114798. }
  114799. }
  114800. declare module BABYLON {
  114801. /**
  114802. * Defines the root class used to create scene optimization to use with SceneOptimizer
  114803. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  114804. */
  114805. export class SceneOptimization {
  114806. /**
  114807. * Defines the priority of this optimization (0 by default which means first in the list)
  114808. */
  114809. priority: number;
  114810. /**
  114811. * Gets a string describing the action executed by the current optimization
  114812. * @returns description string
  114813. */
  114814. getDescription(): string;
  114815. /**
  114816. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  114817. * @param scene defines the current scene where to apply this optimization
  114818. * @param optimizer defines the current optimizer
  114819. * @returns true if everything that can be done was applied
  114820. */
  114821. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  114822. /**
  114823. * Creates the SceneOptimization object
  114824. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  114825. * @param desc defines the description associated with the optimization
  114826. */
  114827. constructor(
  114828. /**
  114829. * Defines the priority of this optimization (0 by default which means first in the list)
  114830. */
  114831. priority?: number);
  114832. }
  114833. /**
  114834. * Defines an optimization used to reduce the size of render target textures
  114835. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  114836. */
  114837. export class TextureOptimization extends SceneOptimization {
  114838. /**
  114839. * Defines the priority of this optimization (0 by default which means first in the list)
  114840. */
  114841. priority: number;
  114842. /**
  114843. * 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
  114844. */
  114845. maximumSize: number;
  114846. /**
  114847. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  114848. */
  114849. step: number;
  114850. /**
  114851. * Gets a string describing the action executed by the current optimization
  114852. * @returns description string
  114853. */
  114854. getDescription(): string;
  114855. /**
  114856. * Creates the TextureOptimization object
  114857. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  114858. * @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
  114859. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  114860. */
  114861. constructor(
  114862. /**
  114863. * Defines the priority of this optimization (0 by default which means first in the list)
  114864. */
  114865. priority?: number,
  114866. /**
  114867. * 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
  114868. */
  114869. maximumSize?: number,
  114870. /**
  114871. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  114872. */
  114873. step?: number);
  114874. /**
  114875. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  114876. * @param scene defines the current scene where to apply this optimization
  114877. * @param optimizer defines the current optimizer
  114878. * @returns true if everything that can be done was applied
  114879. */
  114880. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  114881. }
  114882. /**
  114883. * Defines an optimization used to increase or decrease the rendering resolution
  114884. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  114885. */
  114886. export class HardwareScalingOptimization extends SceneOptimization {
  114887. /**
  114888. * Defines the priority of this optimization (0 by default which means first in the list)
  114889. */
  114890. priority: number;
  114891. /**
  114892. * Defines the maximum scale to use (2 by default)
  114893. */
  114894. maximumScale: number;
  114895. /**
  114896. * Defines the step to use between two passes (0.5 by default)
  114897. */
  114898. step: number;
  114899. private _currentScale;
  114900. private _directionOffset;
  114901. /**
  114902. * Gets a string describing the action executed by the current optimization
  114903. * @return description string
  114904. */
  114905. getDescription(): string;
  114906. /**
  114907. * Creates the HardwareScalingOptimization object
  114908. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  114909. * @param maximumScale defines the maximum scale to use (2 by default)
  114910. * @param step defines the step to use between two passes (0.5 by default)
  114911. */
  114912. constructor(
  114913. /**
  114914. * Defines the priority of this optimization (0 by default which means first in the list)
  114915. */
  114916. priority?: number,
  114917. /**
  114918. * Defines the maximum scale to use (2 by default)
  114919. */
  114920. maximumScale?: number,
  114921. /**
  114922. * Defines the step to use between two passes (0.5 by default)
  114923. */
  114924. step?: number);
  114925. /**
  114926. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  114927. * @param scene defines the current scene where to apply this optimization
  114928. * @param optimizer defines the current optimizer
  114929. * @returns true if everything that can be done was applied
  114930. */
  114931. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  114932. }
  114933. /**
  114934. * Defines an optimization used to remove shadows
  114935. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  114936. */
  114937. export class ShadowsOptimization extends SceneOptimization {
  114938. /**
  114939. * Gets a string describing the action executed by the current optimization
  114940. * @return description string
  114941. */
  114942. getDescription(): string;
  114943. /**
  114944. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  114945. * @param scene defines the current scene where to apply this optimization
  114946. * @param optimizer defines the current optimizer
  114947. * @returns true if everything that can be done was applied
  114948. */
  114949. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  114950. }
  114951. /**
  114952. * Defines an optimization used to turn post-processes off
  114953. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  114954. */
  114955. export class PostProcessesOptimization extends SceneOptimization {
  114956. /**
  114957. * Gets a string describing the action executed by the current optimization
  114958. * @return description string
  114959. */
  114960. getDescription(): string;
  114961. /**
  114962. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  114963. * @param scene defines the current scene where to apply this optimization
  114964. * @param optimizer defines the current optimizer
  114965. * @returns true if everything that can be done was applied
  114966. */
  114967. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  114968. }
  114969. /**
  114970. * Defines an optimization used to turn lens flares off
  114971. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  114972. */
  114973. export class LensFlaresOptimization extends SceneOptimization {
  114974. /**
  114975. * Gets a string describing the action executed by the current optimization
  114976. * @return description string
  114977. */
  114978. getDescription(): string;
  114979. /**
  114980. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  114981. * @param scene defines the current scene where to apply this optimization
  114982. * @param optimizer defines the current optimizer
  114983. * @returns true if everything that can be done was applied
  114984. */
  114985. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  114986. }
  114987. /**
  114988. * Defines an optimization based on user defined callback.
  114989. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  114990. */
  114991. export class CustomOptimization extends SceneOptimization {
  114992. /**
  114993. * Callback called to apply the custom optimization.
  114994. */
  114995. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  114996. /**
  114997. * Callback called to get custom description
  114998. */
  114999. onGetDescription: () => string;
  115000. /**
  115001. * Gets a string describing the action executed by the current optimization
  115002. * @returns description string
  115003. */
  115004. getDescription(): string;
  115005. /**
  115006. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  115007. * @param scene defines the current scene where to apply this optimization
  115008. * @param optimizer defines the current optimizer
  115009. * @returns true if everything that can be done was applied
  115010. */
  115011. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  115012. }
  115013. /**
  115014. * Defines an optimization used to turn particles off
  115015. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  115016. */
  115017. export class ParticlesOptimization extends SceneOptimization {
  115018. /**
  115019. * Gets a string describing the action executed by the current optimization
  115020. * @return description string
  115021. */
  115022. getDescription(): string;
  115023. /**
  115024. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  115025. * @param scene defines the current scene where to apply this optimization
  115026. * @param optimizer defines the current optimizer
  115027. * @returns true if everything that can be done was applied
  115028. */
  115029. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  115030. }
  115031. /**
  115032. * Defines an optimization used to turn render targets off
  115033. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  115034. */
  115035. export class RenderTargetsOptimization extends SceneOptimization {
  115036. /**
  115037. * Gets a string describing the action executed by the current optimization
  115038. * @return description string
  115039. */
  115040. getDescription(): string;
  115041. /**
  115042. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  115043. * @param scene defines the current scene where to apply this optimization
  115044. * @param optimizer defines the current optimizer
  115045. * @returns true if everything that can be done was applied
  115046. */
  115047. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  115048. }
  115049. /**
  115050. * Defines an optimization used to merge meshes with compatible materials
  115051. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  115052. */
  115053. export class MergeMeshesOptimization extends SceneOptimization {
  115054. private static _UpdateSelectionTree;
  115055. /**
  115056. * Gets or sets a boolean which defines if optimization octree has to be updated
  115057. */
  115058. /**
  115059. * Gets or sets a boolean which defines if optimization octree has to be updated
  115060. */
  115061. static UpdateSelectionTree: boolean;
  115062. /**
  115063. * Gets a string describing the action executed by the current optimization
  115064. * @return description string
  115065. */
  115066. getDescription(): string;
  115067. private _canBeMerged;
  115068. /**
  115069. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  115070. * @param scene defines the current scene where to apply this optimization
  115071. * @param optimizer defines the current optimizer
  115072. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  115073. * @returns true if everything that can be done was applied
  115074. */
  115075. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  115076. }
  115077. /**
  115078. * Defines a list of options used by SceneOptimizer
  115079. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  115080. */
  115081. export class SceneOptimizerOptions {
  115082. /**
  115083. * Defines the target frame rate to reach (60 by default)
  115084. */
  115085. targetFrameRate: number;
  115086. /**
  115087. * Defines the interval between two checkes (2000ms by default)
  115088. */
  115089. trackerDuration: number;
  115090. /**
  115091. * Gets the list of optimizations to apply
  115092. */
  115093. optimizations: SceneOptimization[];
  115094. /**
  115095. * Creates a new list of options used by SceneOptimizer
  115096. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  115097. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  115098. */
  115099. constructor(
  115100. /**
  115101. * Defines the target frame rate to reach (60 by default)
  115102. */
  115103. targetFrameRate?: number,
  115104. /**
  115105. * Defines the interval between two checkes (2000ms by default)
  115106. */
  115107. trackerDuration?: number);
  115108. /**
  115109. * Add a new optimization
  115110. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  115111. * @returns the current SceneOptimizerOptions
  115112. */
  115113. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  115114. /**
  115115. * Add a new custom optimization
  115116. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  115117. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  115118. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  115119. * @returns the current SceneOptimizerOptions
  115120. */
  115121. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  115122. /**
  115123. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  115124. * @param targetFrameRate defines the target frame rate (60 by default)
  115125. * @returns a SceneOptimizerOptions object
  115126. */
  115127. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  115128. /**
  115129. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  115130. * @param targetFrameRate defines the target frame rate (60 by default)
  115131. * @returns a SceneOptimizerOptions object
  115132. */
  115133. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  115134. /**
  115135. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  115136. * @param targetFrameRate defines the target frame rate (60 by default)
  115137. * @returns a SceneOptimizerOptions object
  115138. */
  115139. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  115140. }
  115141. /**
  115142. * Class used to run optimizations in order to reach a target frame rate
  115143. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  115144. */
  115145. export class SceneOptimizer implements IDisposable {
  115146. private _isRunning;
  115147. private _options;
  115148. private _scene;
  115149. private _currentPriorityLevel;
  115150. private _targetFrameRate;
  115151. private _trackerDuration;
  115152. private _currentFrameRate;
  115153. private _sceneDisposeObserver;
  115154. private _improvementMode;
  115155. /**
  115156. * Defines an observable called when the optimizer reaches the target frame rate
  115157. */
  115158. onSuccessObservable: Observable<SceneOptimizer>;
  115159. /**
  115160. * Defines an observable called when the optimizer enables an optimization
  115161. */
  115162. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  115163. /**
  115164. * Defines an observable called when the optimizer is not able to reach the target frame rate
  115165. */
  115166. onFailureObservable: Observable<SceneOptimizer>;
  115167. /**
  115168. * Gets a boolean indicating if the optimizer is in improvement mode
  115169. */
  115170. readonly isInImprovementMode: boolean;
  115171. /**
  115172. * Gets the current priority level (0 at start)
  115173. */
  115174. readonly currentPriorityLevel: number;
  115175. /**
  115176. * Gets the current frame rate checked by the SceneOptimizer
  115177. */
  115178. readonly currentFrameRate: number;
  115179. /**
  115180. * Gets or sets the current target frame rate (60 by default)
  115181. */
  115182. /**
  115183. * Gets or sets the current target frame rate (60 by default)
  115184. */
  115185. targetFrameRate: number;
  115186. /**
  115187. * Gets or sets the current interval between two checks (every 2000ms by default)
  115188. */
  115189. /**
  115190. * Gets or sets the current interval between two checks (every 2000ms by default)
  115191. */
  115192. trackerDuration: number;
  115193. /**
  115194. * Gets the list of active optimizations
  115195. */
  115196. readonly optimizations: SceneOptimization[];
  115197. /**
  115198. * Creates a new SceneOptimizer
  115199. * @param scene defines the scene to work on
  115200. * @param options defines the options to use with the SceneOptimizer
  115201. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  115202. * @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)
  115203. */
  115204. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  115205. /**
  115206. * Stops the current optimizer
  115207. */
  115208. stop(): void;
  115209. /**
  115210. * Reset the optimizer to initial step (current priority level = 0)
  115211. */
  115212. reset(): void;
  115213. /**
  115214. * Start the optimizer. By default it will try to reach a specific framerate
  115215. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  115216. */
  115217. start(): void;
  115218. private _checkCurrentState;
  115219. /**
  115220. * Release all resources
  115221. */
  115222. dispose(): void;
  115223. /**
  115224. * Helper function to create a SceneOptimizer with one single line of code
  115225. * @param scene defines the scene to work on
  115226. * @param options defines the options to use with the SceneOptimizer
  115227. * @param onSuccess defines a callback to call on success
  115228. * @param onFailure defines a callback to call on failure
  115229. * @returns the new SceneOptimizer object
  115230. */
  115231. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  115232. }
  115233. }
  115234. declare module BABYLON {
  115235. /**
  115236. * Class used to serialize a scene into a string
  115237. */
  115238. export class SceneSerializer {
  115239. /**
  115240. * Clear cache used by a previous serialization
  115241. */
  115242. static ClearCache(): void;
  115243. /**
  115244. * Serialize a scene into a JSON compatible object
  115245. * @param scene defines the scene to serialize
  115246. * @returns a JSON compatible object
  115247. */
  115248. static Serialize(scene: Scene): any;
  115249. /**
  115250. * Serialize a mesh into a JSON compatible object
  115251. * @param toSerialize defines the mesh to serialize
  115252. * @param withParents defines if parents must be serialized as well
  115253. * @param withChildren defines if children must be serialized as well
  115254. * @returns a JSON compatible object
  115255. */
  115256. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  115257. }
  115258. }
  115259. declare module BABYLON {
  115260. /**
  115261. * Class used to host texture specific utilities
  115262. */
  115263. export class TextureTools {
  115264. /**
  115265. * Uses the GPU to create a copy texture rescaled at a given size
  115266. * @param texture Texture to copy from
  115267. * @param width defines the desired width
  115268. * @param height defines the desired height
  115269. * @param useBilinearMode defines if bilinear mode has to be used
  115270. * @return the generated texture
  115271. */
  115272. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  115273. }
  115274. }
  115275. declare module BABYLON {
  115276. /**
  115277. * This represents the different options avilable for the video capture.
  115278. */
  115279. export interface VideoRecorderOptions {
  115280. /** Defines the mime type of the video */
  115281. mimeType: string;
  115282. /** Defines the video the video should be recorded at */
  115283. fps: number;
  115284. /** Defines the chunk size for the recording data */
  115285. recordChunckSize: number;
  115286. /** The audio tracks to attach to the record */
  115287. audioTracks?: MediaStreamTrack[];
  115288. }
  115289. /**
  115290. * This can helps recording videos from BabylonJS.
  115291. * This is based on the available WebRTC functionalities of the browser.
  115292. *
  115293. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  115294. */
  115295. export class VideoRecorder {
  115296. private static readonly _defaultOptions;
  115297. /**
  115298. * Returns wehther or not the VideoRecorder is available in your browser.
  115299. * @param engine Defines the Babylon Engine to check the support for
  115300. * @returns true if supported otherwise false
  115301. */
  115302. static IsSupported(engine: Engine): boolean;
  115303. private readonly _options;
  115304. private _canvas;
  115305. private _mediaRecorder;
  115306. private _recordedChunks;
  115307. private _fileName;
  115308. private _resolve;
  115309. private _reject;
  115310. /**
  115311. * True wether a recording is already in progress.
  115312. */
  115313. readonly isRecording: boolean;
  115314. /**
  115315. * Create a new VideoCapture object which can help converting what you see in Babylon to
  115316. * a video file.
  115317. * @param engine Defines the BabylonJS Engine you wish to record
  115318. * @param options Defines options that can be used to customized the capture
  115319. */
  115320. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  115321. /**
  115322. * Stops the current recording before the default capture timeout passed in the startRecording
  115323. * functions.
  115324. */
  115325. stopRecording(): void;
  115326. /**
  115327. * Starts recording the canvas for a max duration specified in parameters.
  115328. * @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.
  115329. * @param maxDuration Defines the maximum recording time in seconds.
  115330. * It default to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  115331. * @return a promise callback at the end of the recording with the video data in Blob.
  115332. */
  115333. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  115334. /**
  115335. * Releases internal resources used during the recording.
  115336. */
  115337. dispose(): void;
  115338. private _handleDataAvailable;
  115339. private _handleError;
  115340. private _handleStop;
  115341. }
  115342. }
  115343. declare module BABYLON {
  115344. /**
  115345. * Class containing a set of static utilities functions for screenshots
  115346. */
  115347. export class ScreenshotTools {
  115348. /**
  115349. * Captures a screenshot of the current rendering
  115350. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  115351. * @param engine defines the rendering engine
  115352. * @param camera defines the source camera
  115353. * @param size This parameter can be set to a single number or to an object with the
  115354. * following (optional) properties: precision, width, height. If a single number is passed,
  115355. * it will be used for both width and height. If an object is passed, the screenshot size
  115356. * will be derived from the parameters. The precision property is a multiplier allowing
  115357. * rendering at a higher or lower resolution
  115358. * @param successCallback defines the callback receives a single parameter which contains the
  115359. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  115360. * src parameter of an <img> to display it
  115361. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  115362. * Check your browser for supported MIME types
  115363. */
  115364. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  115365. /**
  115366. * Generates an image screenshot from the specified camera.
  115367. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  115368. * @param engine The engine to use for rendering
  115369. * @param camera The camera to use for rendering
  115370. * @param size This parameter can be set to a single number or to an object with the
  115371. * following (optional) properties: precision, width, height. If a single number is passed,
  115372. * it will be used for both width and height. If an object is passed, the screenshot size
  115373. * will be derived from the parameters. The precision property is a multiplier allowing
  115374. * rendering at a higher or lower resolution
  115375. * @param successCallback The callback receives a single parameter which contains the
  115376. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  115377. * src parameter of an <img> to display it
  115378. * @param mimeType The MIME type of the screenshot image (default: image/png).
  115379. * Check your browser for supported MIME types
  115380. * @param samples Texture samples (default: 1)
  115381. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  115382. * @param fileName A name for for the downloaded file.
  115383. */
  115384. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  115385. }
  115386. }
  115387. declare module BABYLON {
  115388. /**
  115389. * A cursor which tracks a point on a path
  115390. */
  115391. export class PathCursor {
  115392. private path;
  115393. /**
  115394. * Stores path cursor callbacks for when an onchange event is triggered
  115395. */
  115396. private _onchange;
  115397. /**
  115398. * The value of the path cursor
  115399. */
  115400. value: number;
  115401. /**
  115402. * The animation array of the path cursor
  115403. */
  115404. animations: Animation[];
  115405. /**
  115406. * Initializes the path cursor
  115407. * @param path The path to track
  115408. */
  115409. constructor(path: Path2);
  115410. /**
  115411. * Gets the cursor point on the path
  115412. * @returns A point on the path cursor at the cursor location
  115413. */
  115414. getPoint(): Vector3;
  115415. /**
  115416. * Moves the cursor ahead by the step amount
  115417. * @param step The amount to move the cursor forward
  115418. * @returns This path cursor
  115419. */
  115420. moveAhead(step?: number): PathCursor;
  115421. /**
  115422. * Moves the cursor behind by the step amount
  115423. * @param step The amount to move the cursor back
  115424. * @returns This path cursor
  115425. */
  115426. moveBack(step?: number): PathCursor;
  115427. /**
  115428. * Moves the cursor by the step amount
  115429. * If the step amount is greater than one, an exception is thrown
  115430. * @param step The amount to move the cursor
  115431. * @returns This path cursor
  115432. */
  115433. move(step: number): PathCursor;
  115434. /**
  115435. * Ensures that the value is limited between zero and one
  115436. * @returns This path cursor
  115437. */
  115438. private ensureLimits;
  115439. /**
  115440. * Runs onchange callbacks on change (used by the animation engine)
  115441. * @returns This path cursor
  115442. */
  115443. private raiseOnChange;
  115444. /**
  115445. * Executes a function on change
  115446. * @param f A path cursor onchange callback
  115447. * @returns This path cursor
  115448. */
  115449. onchange(f: (cursor: PathCursor) => void): PathCursor;
  115450. }
  115451. }
  115452. declare module BABYLON {
  115453. /** @hidden */
  115454. export var blurPixelShader: {
  115455. name: string;
  115456. shader: string;
  115457. };
  115458. }
  115459. declare module BABYLON {
  115460. /** @hidden */
  115461. export var bones300Declaration: {
  115462. name: string;
  115463. shader: string;
  115464. };
  115465. }
  115466. declare module BABYLON {
  115467. /** @hidden */
  115468. export var instances300Declaration: {
  115469. name: string;
  115470. shader: string;
  115471. };
  115472. }
  115473. declare module BABYLON {
  115474. /** @hidden */
  115475. export var pointCloudVertexDeclaration: {
  115476. name: string;
  115477. shader: string;
  115478. };
  115479. }
  115480. // Mixins
  115481. interface Window {
  115482. mozIndexedDB: IDBFactory;
  115483. webkitIndexedDB: IDBFactory;
  115484. msIndexedDB: IDBFactory;
  115485. webkitURL: typeof URL;
  115486. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  115487. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  115488. WebGLRenderingContext: WebGLRenderingContext;
  115489. MSGesture: MSGesture;
  115490. CANNON: any;
  115491. AudioContext: AudioContext;
  115492. webkitAudioContext: AudioContext;
  115493. PointerEvent: any;
  115494. Math: Math;
  115495. Uint8Array: Uint8ArrayConstructor;
  115496. Float32Array: Float32ArrayConstructor;
  115497. mozURL: typeof URL;
  115498. msURL: typeof URL;
  115499. VRFrameData: any; // WebVR, from specs 1.1
  115500. DracoDecoderModule: any;
  115501. setImmediate(handler: (...args: any[]) => void): number;
  115502. }
  115503. interface HTMLCanvasElement {
  115504. requestPointerLock(): void;
  115505. msRequestPointerLock?(): void;
  115506. mozRequestPointerLock?(): void;
  115507. webkitRequestPointerLock?(): void;
  115508. /** Track wether a record is in progress */
  115509. isRecording: boolean;
  115510. /** Capture Stream method defined by some browsers */
  115511. captureStream(fps?: number): MediaStream;
  115512. }
  115513. interface CanvasRenderingContext2D {
  115514. msImageSmoothingEnabled: boolean;
  115515. }
  115516. interface MouseEvent {
  115517. mozMovementX: number;
  115518. mozMovementY: number;
  115519. webkitMovementX: number;
  115520. webkitMovementY: number;
  115521. msMovementX: number;
  115522. msMovementY: number;
  115523. }
  115524. interface Navigator {
  115525. mozGetVRDevices: (any: any) => any;
  115526. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  115527. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  115528. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  115529. webkitGetGamepads(): Gamepad[];
  115530. msGetGamepads(): Gamepad[];
  115531. webkitGamepads(): Gamepad[];
  115532. }
  115533. interface HTMLVideoElement {
  115534. mozSrcObject: any;
  115535. }
  115536. interface Math {
  115537. fround(x: number): number;
  115538. imul(a: number, b: number): number;
  115539. }
  115540. interface WebGLProgram {
  115541. context?: WebGLRenderingContext;
  115542. vertexShader?: WebGLShader;
  115543. fragmentShader?: WebGLShader;
  115544. isParallelCompiled: boolean;
  115545. onCompiled?: () => void;
  115546. }
  115547. interface WebGLRenderingContext {
  115548. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  115549. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  115550. vertexAttribDivisor(index: number, divisor: number): void;
  115551. createVertexArray(): any;
  115552. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  115553. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  115554. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  115555. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  115556. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  115557. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  115558. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  115559. // Queries
  115560. createQuery(): WebGLQuery;
  115561. deleteQuery(query: WebGLQuery): void;
  115562. beginQuery(target: number, query: WebGLQuery): void;
  115563. endQuery(target: number): void;
  115564. getQueryParameter(query: WebGLQuery, pname: number): any;
  115565. getQuery(target: number, pname: number): any;
  115566. MAX_SAMPLES: number;
  115567. RGBA8: number;
  115568. READ_FRAMEBUFFER: number;
  115569. DRAW_FRAMEBUFFER: number;
  115570. UNIFORM_BUFFER: number;
  115571. HALF_FLOAT_OES: number;
  115572. RGBA16F: number;
  115573. RGBA32F: number;
  115574. R32F: number;
  115575. RG32F: number;
  115576. RGB32F: number;
  115577. R16F: number;
  115578. RG16F: number;
  115579. RGB16F: number;
  115580. RED: number;
  115581. RG: number;
  115582. R8: number;
  115583. RG8: number;
  115584. UNSIGNED_INT_24_8: number;
  115585. DEPTH24_STENCIL8: number;
  115586. /* Multiple Render Targets */
  115587. drawBuffers(buffers: number[]): void;
  115588. readBuffer(src: number): void;
  115589. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  115590. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  115591. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  115592. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  115593. // Occlusion Query
  115594. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  115595. ANY_SAMPLES_PASSED: number;
  115596. QUERY_RESULT_AVAILABLE: number;
  115597. QUERY_RESULT: number;
  115598. }
  115599. interface WebGLBuffer {
  115600. references: number;
  115601. capacity: number;
  115602. is32Bits: boolean;
  115603. }
  115604. interface WebGLProgram {
  115605. transformFeedback?: WebGLTransformFeedback | null;
  115606. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  115607. }
  115608. interface EXT_disjoint_timer_query {
  115609. QUERY_COUNTER_BITS_EXT: number;
  115610. TIME_ELAPSED_EXT: number;
  115611. TIMESTAMP_EXT: number;
  115612. GPU_DISJOINT_EXT: number;
  115613. QUERY_RESULT_EXT: number;
  115614. QUERY_RESULT_AVAILABLE_EXT: number;
  115615. queryCounterEXT(query: WebGLQuery, target: number): void;
  115616. createQueryEXT(): WebGLQuery;
  115617. beginQueryEXT(target: number, query: WebGLQuery): void;
  115618. endQueryEXT(target: number): void;
  115619. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  115620. deleteQueryEXT(query: WebGLQuery): void;
  115621. }
  115622. interface WebGLUniformLocation {
  115623. _currentState: any;
  115624. }
  115625. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  115626. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  115627. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  115628. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  115629. interface WebGLRenderingContext {
  115630. readonly RASTERIZER_DISCARD: number;
  115631. readonly DEPTH_COMPONENT24: number;
  115632. readonly TEXTURE_3D: number;
  115633. readonly TEXTURE_2D_ARRAY: number;
  115634. readonly TEXTURE_COMPARE_FUNC: number;
  115635. readonly TEXTURE_COMPARE_MODE: number;
  115636. readonly COMPARE_REF_TO_TEXTURE: number;
  115637. readonly TEXTURE_WRAP_R: number;
  115638. readonly HALF_FLOAT: number;
  115639. readonly RGB8: number;
  115640. readonly RED_INTEGER: number;
  115641. readonly RG_INTEGER: number;
  115642. readonly RGB_INTEGER: number;
  115643. readonly RGBA_INTEGER: number;
  115644. readonly R8_SNORM: number;
  115645. readonly RG8_SNORM: number;
  115646. readonly RGB8_SNORM: number;
  115647. readonly RGBA8_SNORM: number;
  115648. readonly R8I: number;
  115649. readonly RG8I: number;
  115650. readonly RGB8I: number;
  115651. readonly RGBA8I: number;
  115652. readonly R8UI: number;
  115653. readonly RG8UI: number;
  115654. readonly RGB8UI: number;
  115655. readonly RGBA8UI: number;
  115656. readonly R16I: number;
  115657. readonly RG16I: number;
  115658. readonly RGB16I: number;
  115659. readonly RGBA16I: number;
  115660. readonly R16UI: number;
  115661. readonly RG16UI: number;
  115662. readonly RGB16UI: number;
  115663. readonly RGBA16UI: number;
  115664. readonly R32I: number;
  115665. readonly RG32I: number;
  115666. readonly RGB32I: number;
  115667. readonly RGBA32I: number;
  115668. readonly R32UI: number;
  115669. readonly RG32UI: number;
  115670. readonly RGB32UI: number;
  115671. readonly RGBA32UI: number;
  115672. readonly RGB10_A2UI: number;
  115673. readonly R11F_G11F_B10F: number;
  115674. readonly RGB9_E5: number;
  115675. readonly RGB10_A2: number;
  115676. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  115677. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  115678. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  115679. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  115680. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  115681. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  115682. 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;
  115683. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  115684. readonly TRANSFORM_FEEDBACK: number;
  115685. readonly INTERLEAVED_ATTRIBS: number;
  115686. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  115687. createTransformFeedback(): WebGLTransformFeedback;
  115688. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  115689. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  115690. beginTransformFeedback(primitiveMode: number): void;
  115691. endTransformFeedback(): void;
  115692. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  115693. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  115694. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  115695. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  115696. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  115697. }
  115698. interface ImageBitmap {
  115699. readonly width: number;
  115700. readonly height: number;
  115701. close(): void;
  115702. }
  115703. interface WebGLQuery extends WebGLObject {
  115704. }
  115705. declare var WebGLQuery: {
  115706. prototype: WebGLQuery;
  115707. new(): WebGLQuery;
  115708. };
  115709. interface WebGLSampler extends WebGLObject {
  115710. }
  115711. declare var WebGLSampler: {
  115712. prototype: WebGLSampler;
  115713. new(): WebGLSampler;
  115714. };
  115715. interface WebGLSync extends WebGLObject {
  115716. }
  115717. declare var WebGLSync: {
  115718. prototype: WebGLSync;
  115719. new(): WebGLSync;
  115720. };
  115721. interface WebGLTransformFeedback extends WebGLObject {
  115722. }
  115723. declare var WebGLTransformFeedback: {
  115724. prototype: WebGLTransformFeedback;
  115725. new(): WebGLTransformFeedback;
  115726. };
  115727. interface WebGLVertexArrayObject extends WebGLObject {
  115728. }
  115729. declare var WebGLVertexArrayObject: {
  115730. prototype: WebGLVertexArrayObject;
  115731. new(): WebGLVertexArrayObject;
  115732. };
  115733. // Type definitions for WebVR API
  115734. // Project: https://w3c.github.io/webvr/
  115735. // Definitions by: six a <https://github.com/lostfictions>
  115736. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  115737. interface VRDisplay extends EventTarget {
  115738. /**
  115739. * Dictionary of capabilities describing the VRDisplay.
  115740. */
  115741. readonly capabilities: VRDisplayCapabilities;
  115742. /**
  115743. * z-depth defining the far plane of the eye view frustum
  115744. * enables mapping of values in the render target depth
  115745. * attachment to scene coordinates. Initially set to 10000.0.
  115746. */
  115747. depthFar: number;
  115748. /**
  115749. * z-depth defining the near plane of the eye view frustum
  115750. * enables mapping of values in the render target depth
  115751. * attachment to scene coordinates. Initially set to 0.01.
  115752. */
  115753. depthNear: number;
  115754. /**
  115755. * An identifier for this distinct VRDisplay. Used as an
  115756. * association point in the Gamepad API.
  115757. */
  115758. readonly displayId: number;
  115759. /**
  115760. * A display name, a user-readable name identifying it.
  115761. */
  115762. readonly displayName: string;
  115763. readonly isConnected: boolean;
  115764. readonly isPresenting: boolean;
  115765. /**
  115766. * If this VRDisplay supports room-scale experiences, the optional
  115767. * stage attribute contains details on the room-scale parameters.
  115768. */
  115769. readonly stageParameters: VRStageParameters | null;
  115770. /**
  115771. * Passing the value returned by `requestAnimationFrame` to
  115772. * `cancelAnimationFrame` will unregister the callback.
  115773. * @param handle Define the hanle of the request to cancel
  115774. */
  115775. cancelAnimationFrame(handle: number): void;
  115776. /**
  115777. * Stops presenting to the VRDisplay.
  115778. * @returns a promise to know when it stopped
  115779. */
  115780. exitPresent(): Promise<void>;
  115781. /**
  115782. * Return the current VREyeParameters for the given eye.
  115783. * @param whichEye Define the eye we want the parameter for
  115784. * @returns the eye parameters
  115785. */
  115786. getEyeParameters(whichEye: string): VREyeParameters;
  115787. /**
  115788. * Populates the passed VRFrameData with the information required to render
  115789. * the current frame.
  115790. * @param frameData Define the data structure to populate
  115791. * @returns true if ok otherwise false
  115792. */
  115793. getFrameData(frameData: VRFrameData): boolean;
  115794. /**
  115795. * Get the layers currently being presented.
  115796. * @returns the list of VR layers
  115797. */
  115798. getLayers(): VRLayer[];
  115799. /**
  115800. * Return a VRPose containing the future predicted pose of the VRDisplay
  115801. * when the current frame will be presented. The value returned will not
  115802. * change until JavaScript has returned control to the browser.
  115803. *
  115804. * The VRPose will contain the position, orientation, velocity,
  115805. * and acceleration of each of these properties.
  115806. * @returns the pose object
  115807. */
  115808. getPose(): VRPose;
  115809. /**
  115810. * Return the current instantaneous pose of the VRDisplay, with no
  115811. * prediction applied.
  115812. * @returns the current instantaneous pose
  115813. */
  115814. getImmediatePose(): VRPose;
  115815. /**
  115816. * The callback passed to `requestAnimationFrame` will be called
  115817. * any time a new frame should be rendered. When the VRDisplay is
  115818. * presenting the callback will be called at the native refresh
  115819. * rate of the HMD. When not presenting this function acts
  115820. * identically to how window.requestAnimationFrame acts. Content should
  115821. * make no assumptions of frame rate or vsync behavior as the HMD runs
  115822. * asynchronously from other displays and at differing refresh rates.
  115823. * @param callback Define the eaction to run next frame
  115824. * @returns the request handle it
  115825. */
  115826. requestAnimationFrame(callback: FrameRequestCallback): number;
  115827. /**
  115828. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  115829. * Repeat calls while already presenting will update the VRLayers being displayed.
  115830. * @param layers Define the list of layer to present
  115831. * @returns a promise to know when the request has been fulfilled
  115832. */
  115833. requestPresent(layers: VRLayer[]): Promise<void>;
  115834. /**
  115835. * Reset the pose for this display, treating its current position and
  115836. * orientation as the "origin/zero" values. VRPose.position,
  115837. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  115838. * updated when calling resetPose(). This should be called in only
  115839. * sitting-space experiences.
  115840. */
  115841. resetPose(): void;
  115842. /**
  115843. * The VRLayer provided to the VRDisplay will be captured and presented
  115844. * in the HMD. Calling this function has the same effect on the source
  115845. * canvas as any other operation that uses its source image, and canvases
  115846. * created without preserveDrawingBuffer set to true will be cleared.
  115847. * @param pose Define the pose to submit
  115848. */
  115849. submitFrame(pose?: VRPose): void;
  115850. }
  115851. declare var VRDisplay: {
  115852. prototype: VRDisplay;
  115853. new(): VRDisplay;
  115854. };
  115855. interface VRLayer {
  115856. leftBounds?: number[] | Float32Array | null;
  115857. rightBounds?: number[] | Float32Array | null;
  115858. source?: HTMLCanvasElement | null;
  115859. }
  115860. interface VRDisplayCapabilities {
  115861. readonly canPresent: boolean;
  115862. readonly hasExternalDisplay: boolean;
  115863. readonly hasOrientation: boolean;
  115864. readonly hasPosition: boolean;
  115865. readonly maxLayers: number;
  115866. }
  115867. interface VREyeParameters {
  115868. /** @deprecated */
  115869. readonly fieldOfView: VRFieldOfView;
  115870. readonly offset: Float32Array;
  115871. readonly renderHeight: number;
  115872. readonly renderWidth: number;
  115873. }
  115874. interface VRFieldOfView {
  115875. readonly downDegrees: number;
  115876. readonly leftDegrees: number;
  115877. readonly rightDegrees: number;
  115878. readonly upDegrees: number;
  115879. }
  115880. interface VRFrameData {
  115881. readonly leftProjectionMatrix: Float32Array;
  115882. readonly leftViewMatrix: Float32Array;
  115883. readonly pose: VRPose;
  115884. readonly rightProjectionMatrix: Float32Array;
  115885. readonly rightViewMatrix: Float32Array;
  115886. readonly timestamp: number;
  115887. }
  115888. interface VRPose {
  115889. readonly angularAcceleration: Float32Array | null;
  115890. readonly angularVelocity: Float32Array | null;
  115891. readonly linearAcceleration: Float32Array | null;
  115892. readonly linearVelocity: Float32Array | null;
  115893. readonly orientation: Float32Array | null;
  115894. readonly position: Float32Array | null;
  115895. readonly timestamp: number;
  115896. }
  115897. interface VRStageParameters {
  115898. sittingToStandingTransform?: Float32Array;
  115899. sizeX?: number;
  115900. sizeY?: number;
  115901. }
  115902. interface Navigator {
  115903. getVRDisplays(): Promise<VRDisplay[]>;
  115904. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  115905. }
  115906. interface Window {
  115907. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  115908. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  115909. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  115910. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  115911. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  115912. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  115913. }
  115914. interface Gamepad {
  115915. readonly displayId: number;
  115916. }
  115917. interface XRDevice {
  115918. requestSession(options: XRSessionCreationOptions): Promise<XRSession>;
  115919. supportsSession(options: XRSessionCreationOptions): Promise<void>;
  115920. }
  115921. interface XRSession {
  115922. getInputSources(): Array<any>;
  115923. baseLayer: XRWebGLLayer;
  115924. requestFrameOfReference(type: string): Promise<void>;
  115925. requestHitTest(origin: Float32Array, direction: Float32Array, frameOfReference: any): any;
  115926. end(): Promise<void>;
  115927. requestAnimationFrame: Function;
  115928. addEventListener: Function;
  115929. }
  115930. interface XRSessionCreationOptions {
  115931. outputContext?: WebGLRenderingContext | null;
  115932. immersive?: boolean;
  115933. environmentIntegration?: boolean;
  115934. }
  115935. interface XRLayer {
  115936. getViewport: Function;
  115937. framebufferWidth: number;
  115938. framebufferHeight: number;
  115939. }
  115940. interface XRView {
  115941. projectionMatrix: Float32Array;
  115942. }
  115943. interface XRFrame {
  115944. getDevicePose: Function;
  115945. getInputPose: Function;
  115946. views: Array<XRView>;
  115947. baseLayer: XRLayer;
  115948. }
  115949. interface XRFrameOfReference {
  115950. }
  115951. interface XRWebGLLayer extends XRLayer {
  115952. framebuffer: WebGLFramebuffer;
  115953. }
  115954. declare var XRWebGLLayer: {
  115955. prototype: XRWebGLLayer;
  115956. new(session: XRSession, context?: WebGLRenderingContext): XRWebGLLayer;
  115957. };